Skip to content

Commit 49cf33e

Browse files
authored
Refactoring Intelligent Defaults for parity with documentations (#304)
* Refactoring Intelligent Defaults term for parity with documentations * Refactoring Intelligent Defaults term for parity with documentations * Refactoring Intelligent Defaults term for parity with documentations * Refactoring Intelligent Defaults term for parity with documentations
1 parent f907185 commit 49cf33e

File tree

8 files changed

+36
-36
lines changed

8 files changed

+36
-36
lines changed

README.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@ Key Features
3131
* **Abstraction of Low-Level Details**: Automatically handles resource state transitions and polling logic, freeing developers from managing these intricacies and allowing them to focus on higher-level tasks.
3232
* **Auto Code Completion**: Enhances the developer experience by offering real-time suggestions and completions in popular IDEs, reducing syntax errors and speeding up the coding process.
3333
* **Comprehensive Documentation and Type Hints**: Provides detailed guidance and type hints to help developers understand functionalities, write code faster, and reduce errors without complex API navigation.
34-
* **Incorporation of Intelligent Defaults**: Integrates the previous SageMaker SDK feature of intelligent defaults, allowing developers to set default values for parameters like IAM roles and VPC configurations. This streamlines the setup process, enabling developers to focus on customizations specific to their use case.
34+
* **Incorporation of Default Configs**: Integrates the previous SageMaker SDK feature of default configs, allowing developers to set default values for parameters like IAM roles and VPC configurations. This streamlines the setup process, enabling developers to focus on customizations specific to their use case.
3535

3636

3737
Benefits
3838
--------
3939

40-
* **Simplified Development**: By abstracting low-level details and providing intelligent defaults, developers can focus on building and deploying machine learning models without getting bogged down by repetitive tasks.
40+
* **Simplified Development**: By abstracting low-level details and providing default configs, developers can focus on building and deploying machine learning models without getting bogged down by repetitive tasks.
4141
* **Increased Productivity**: The SDK's features, such as auto code completion and type hints, help developers write code faster and with fewer errors.
4242
* **Enhanced Readability**: Resource chaining and dedicated resource classes result in more readable and maintainable code.
4343

example_notebooks/intelligent_defaults_and_logging.ipynb renamed to example_notebooks/default_configs_and_logging.ipynb

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"cell_type": "markdown",
55
"metadata": {},
66
"source": [
7-
"# Intelligent Defaults and Logging Configuration in SageMakerCore"
7+
"# Default Configs and Logging Configuration in SageMakerCore"
88
]
99
},
1010
{
@@ -14,21 +14,21 @@
1414
"---\n",
1515
"## Introductions\n",
1616
"\n",
17-
"In this notebook, we will walkthrough the setup and usage of intelligent defaults in the SageMakerCore SDK. Additionally, this notebook contains a section with the steps required for configuring logging levels to assist in the debugging of issues that arise while using the SDK.\n",
17+
"In this notebook, we will walkthrough the setup and usage of default configs in the SageMakerCore SDK. Additionally, this notebook contains a section with the steps required for configuring logging levels to assist in the debugging of issues that arise while using the SDK.\n",
1818
"\n"
1919
]
2020
},
2121
{
2222
"cell_type": "markdown",
2323
"metadata": {},
2424
"source": [
25-
"### Intelligent Defaults\n",
25+
"### Default Configs\n",
2626
"\n",
27-
"Intelligent Defaults is a feature provided by the SageMakerCore SDK to assist users in defining default values to be auto populated into the AWS API Request parameters. For example, if a user/admin wants all of their AWS Resources to use a specific VPC Config during creation this can be defined in the Intelligent Defaults Configs. Intelligent Defaults supports:\n",
27+
"Default Configs is a feature provided by the SageMakerCore SDK to assist users in defining default values to be auto populated into the AWS API Request parameters. For example, if a user/admin wants all of their AWS Resources to use a specific VPC Config during creation this can be defined in the Default Configs Configs. Default Configs supports:\n",
2828
"1. GlobalDefaults - default values applied across SageMaker API calls\n",
2929
"2. Resource Specific Defaults - defaults applied only when creating a specific resource\n",
3030
"\n",
31-
"An Example of the strucuture of the Intelligent Defaults Config is below:"
31+
"An Example of the strucuture of the Default Configs Config is below:"
3232
]
3333
},
3434
{
@@ -280,16 +280,16 @@
280280
"cell_type": "markdown",
281281
"metadata": {},
282282
"source": [
283-
"## Intelligent Defaults"
283+
"## Default Configs"
284284
]
285285
},
286286
{
287287
"cell_type": "markdown",
288288
"metadata": {},
289289
"source": [
290-
"### Create Intelligent Defaults JSON\n",
290+
"### Create Default Configs JSON\n",
291291
"\n",
292-
"In order for SageMakerCore to pick up the Intelligent Defaults Configs to populate API calls, we first must create the json config file and set the `SAGEMAKER_CORE_ADMIN_CONFIG_OVERRIDE` enviornment variable.\n",
292+
"In order for SageMakerCore to pick up the Default Configs Configs to populate API calls, we first must create the json config file and set the `SAGEMAKER_CORE_ADMIN_CONFIG_OVERRIDE` enviornment variable.\n",
293293
"\n",
294294
"Below we will create the config file at `data/defaults.json` and assign this path to the `SAGEMAKER_CORE_ADMIN_CONFIG_OVERRIDE` enviornment variable."
295295
]
@@ -367,7 +367,7 @@
367367
" \n",
368368
"cluster_name_v3 = 'xgboost-cluster-' + time.strftime(\"%Y-%m-%d-%H-%M-%S\", time.gmtime())\n",
369369
"\n",
370-
"# Use vpc_config from Intelligent Defaults JSON config file under the SageMaker.PythonSDK.Resources.GlobalDefaults key\n",
370+
"# Use vpc_config from Default Configs JSON config file under the SageMaker.PythonSDK.Resources.GlobalDefaults key\n",
371371
"cluster = Cluster.create(\n",
372372
" cluster_name=cluster_name_v3,\n",
373373
" instance_groups=[\n",
@@ -413,8 +413,8 @@
413413
"\n",
414414
"job_name_v3 = 'xgboost-iris-' + time.strftime(\"%Y-%m-%d-%H-%M-%S\", time.gmtime())\n",
415415
"\n",
416-
"# Use role and output_data_config from Intelligent Defaults JSON config file under the SageMaker.PythonSDK.Resources.TrainingJob key\n",
417-
"# Use vpc_config from Intelligent Defaults JSON config file under the SageMaker.PythonSDK.Resources.GlobalDefaults key\n",
416+
"# Use role and output_data_config from Default Configs JSON config file under the SageMaker.PythonSDK.Resources.TrainingJob key\n",
417+
"# Use vpc_config from Default Configs JSON config file under the SageMaker.PythonSDK.Resources.GlobalDefaults key\n",
418418
"\n",
419419
"training_job = TrainingJob.create(\n",
420420
" training_job_name=job_name_v3,\n",

integ/test_codegen.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -153,11 +153,11 @@ def test_training_and_inference(self):
153153
)
154154
endpoint.wait_for_status("InService")
155155

156-
def test_intelligent_defaults(self):
156+
def test_default_configs(self):
157157
os.environ["SAGEMAKER_CORE_ADMIN_CONFIG_OVERRIDE"] = (
158-
self._setup_intelligent_default_configs_and_fetch_path()
158+
self._setup_default_configs_and_fetch_path()
159159
)
160-
job_name_v3 = "xgboost-test-intelligent-default-" + time.strftime(
160+
job_name_v3 = "xgboost-test-default-configs-" + time.strftime(
161161
"%Y-%m-%d-%H-%M-%S", time.gmtime()
162162
)
163163

@@ -207,7 +207,7 @@ def test_intelligent_defaults(self):
207207
def tearDown(self) -> None:
208208
handle_cleanup()
209209

210-
def _setup_intelligent_default_configs_and_fetch_path(self) -> str:
210+
def _setup_default_configs_and_fetch_path(self) -> str:
211211
DEFAULTS_CONTENT = {
212212
"SchemaVesion": "1.0",
213213
"SageMaker": {

src/sagemaker_core/main/intelligent_defaults_helper.py renamed to src/sagemaker_core/main/default_configs_helper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
from sagemaker_core.main.exceptions import (
3030
LocalConfigNotFoundError,
3131
S3ConfigNotFoundError,
32-
IntelligentDefaultsError,
32+
DefaultConfigsError,
3333
ConfigSchemaValidationError,
3434
)
3535
from sagemaker_core.main.utils import get_textual_rich_logger
@@ -116,7 +116,7 @@ def _load_config_from_s3(s3_uri, s3_resource_for_config) -> dict:
116116
boto_session = boto3.DEFAULT_SESSION or boto3.Session()
117117
boto_region_name = boto_session.region_name
118118
if boto_region_name is None:
119-
raise IntelligentDefaultsError(
119+
raise DefaultConfigsError(
120120
message=(
121121
"Valid region is not provided in the Boto3 session."
122122
+ "Setup local AWS configuration with a valid region supported by SageMaker."

src/sagemaker_core/main/exceptions.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -91,21 +91,21 @@ def __init__(self, resource_type="(Unkown)", status="(Unkown)", reason="(Unkown)
9191
super().__init__(resource_type=resource_type, status=status, reason=reason)
9292

9393

94-
### Intelligent Defaults Errors
95-
class IntelligentDefaultsError(SageMakerCoreError):
96-
"""Raised when an error occurs in the Intelligent Defaults"""
94+
### Default Configs Errors
95+
class DefaultConfigsError(SageMakerCoreError):
96+
"""Raised when an error occurs in the Default Configs"""
9797

98-
fmt = "An error occurred while loading Intelligent Default. {message}"
98+
fmt = "An error occurred while loading Default Configs. {message}"
9999

100100
def __init__(self, message="", **kwargs):
101-
"""Initialize an IntelligentDefaultsError exception.
101+
"""Initialize an DefaultConfigsError exception.
102102
Args:
103103
message (str): A message describing the error.
104104
"""
105105
super().__init__(message=message, **kwargs)
106106

107107

108-
class LocalConfigNotFoundError(IntelligentDefaultsError):
108+
class LocalConfigNotFoundError(DefaultConfigsError):
109109
"""Raised when a configuration file is not found in local file system"""
110110

111111
fmt = "Failed to load configuration file from location: {file_path}. {message}"
@@ -119,7 +119,7 @@ def __init__(self, file_path="(Unkown)", message=""):
119119
super().__init__(file_path=file_path, message=message)
120120

121121

122-
class S3ConfigNotFoundError(IntelligentDefaultsError):
122+
class S3ConfigNotFoundError(DefaultConfigsError):
123123
"""Raised when a configuration file is not found in S3"""
124124

125125
fmt = "Failed to load configuration file from S3 location: {s3_uri}. {message}"
@@ -133,7 +133,7 @@ def __init__(self, s3_uri="(Unkown)", message=""):
133133
super().__init__(s3_uri=s3_uri, message=message)
134134

135135

136-
class ConfigSchemaValidationError(IntelligentDefaultsError, ValidationError):
136+
class ConfigSchemaValidationError(DefaultConfigsError, ValidationError):
137137
"""Raised when a configuration file does not adhere to the schema"""
138138

139139
fmt = "Failed to validate configuration file from location: {file_path}. {message}"

src/sagemaker_core/main/resources.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737
is_primitive_list,
3838
serialize,
3939
)
40-
from sagemaker_core.main.intelligent_defaults_helper import (
40+
from sagemaker_core.main.default_configs_helper import (
4141
load_default_configs_for_resource_name,
4242
get_config_value,
4343
)

src/sagemaker_core/tools/constants.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888

8989
GENERATED_CLASSES_LOCATION = os.getcwd() + "/src/sagemaker_core/main"
9090
UTILS_CODEGEN_FILE_NAME = "utils.py"
91-
INTELLIGENT_DEFAULTS_HELPER_CODEGEN_FILE_NAME = "intelligent_defaults_helper.py"
91+
DEFAULT_CONFIGS_CODEGEN_FILE_NAME = "default_configs_helper.py"
9292

9393
RESOURCES_CODEGEN_FILE_NAME = "resources.py"
9494

src/sagemaker_core/tools/resources_codegen.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import json
1818
from sagemaker_core.main.code_injection.codec import pascal_to_snake
1919
from sagemaker_core.main.config_schema import SAGEMAKER_PYTHON_SDK_CONFIG_SCHEMA
20-
from sagemaker_core.main.exceptions import IntelligentDefaultsError
20+
from sagemaker_core.main.exceptions import DefaultConfigsError
2121
from sagemaker_core.main.utils import get_textual_rich_logger
2222
from sagemaker_core.tools.constants import (
2323
BASIC_RETURN_TYPES,
@@ -190,7 +190,7 @@ def generate_imports(self) -> str:
190190
"from sagemaker_core.main.code_injection.constants import Color",
191191
"from sagemaker_core.main.utils import SageMakerClient, ResourceIterator, Unassigned, get_textual_rich_logger, "
192192
"snake_to_pascal, pascal_to_snake, is_not_primitive, is_not_str_dict, is_primitive_list, serialize",
193-
"from sagemaker_core.main.intelligent_defaults_helper import load_default_configs_for_resource_name, get_config_value",
193+
"from sagemaker_core.main.default_configs_helper import load_default_configs_for_resource_name, get_config_value",
194194
"from sagemaker_core.main.logs import MultiLogStreamHandler",
195195
"from sagemaker_core.main.exceptions import *",
196196
"import sagemaker_core.main.shapes as shapes",
@@ -859,7 +859,7 @@ def generate_create_method(self, resource_name: str, **kwargs) -> str:
859859
operation_input_shape_name=operation_input_shape_name,
860860
include_session_region=True,
861861
include_return_resource_docstring=True,
862-
include_intelligent_defaults_errors=True,
862+
include_default_configs_errors=True,
863863
)
864864

865865
if "Describe" + resource_name in self.operations:
@@ -956,7 +956,7 @@ def _generate_docstring(
956956
include_session_region: bool = False,
957957
include_return_resource_docstring: bool = False,
958958
return_string: str = None,
959-
include_intelligent_defaults_errors: bool = False,
959+
include_default_configs_errors: bool = False,
960960
exclude_resource_attrs: list = None,
961961
) -> str:
962962
"""
@@ -970,7 +970,7 @@ def _generate_docstring(
970970
include_session_region (bool): Whether to include session and region documentation.
971971
include_return_resource_docstring (bool): Whether to include resource-specific documentation.
972972
return_string (str): The return string.
973-
include_intelligent_defaults_errors (bool): Whether to include intelligent defaults errors.
973+
include_default_configs_errors (bool): Whether to include default configs errors.
974974
exclude_resource_attrs (list): A list of attributes to exclude from the docstring.
975975
976976
Returns:
@@ -1000,8 +1000,8 @@ def _generate_docstring(
10001000

10011001
docstring += self._exception_docstring(operation_name)
10021002

1003-
if include_intelligent_defaults_errors:
1004-
subclasses = set(IntelligentDefaultsError.__subclasses__())
1003+
if include_default_configs_errors:
1004+
subclasses = set(DefaultConfigsError.__subclasses__())
10051005
_id_exception_docstrings = [
10061006
f"\n {subclass.__name__}: {subclass.__doc__}" for subclass in subclasses
10071007
]

0 commit comments

Comments
 (0)