Skip to content

Commit d8e33ea

Browse files
author
Ruban Hussain
committed
change: rename fetch_sagemaker_config to load_sagemaker_config
1 parent fc18316 commit d8e33ea

File tree

7 files changed

+30
-30
lines changed

7 files changed

+30
-30
lines changed

src/sagemaker/config/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"""This module configures the default values for SageMaker Python SDK."""
1414

1515
from __future__ import absolute_import
16-
from sagemaker.config.config import fetch_sagemaker_config, validate_sagemaker_config # noqa: F401
16+
from sagemaker.config.config import load_sagemaker_config, validate_sagemaker_config # noqa: F401
1717
from sagemaker.config.config_schema import ( # noqa: F401
1818
KEY,
1919
TRAINING_JOB,

src/sagemaker/config/config.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
S3_PREFIX = "s3://"
5252

5353

54-
def fetch_sagemaker_config(
54+
def load_sagemaker_config(
5555
additional_config_paths: List[str] = None, s3_resource=_DEFAULT_S3_RESOURCE
5656
) -> dict:
5757
"""Helper method that loads config files and merges them.

src/sagemaker/local/local_session.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
import boto3
2222
from botocore.exceptions import ClientError
2323

24-
from sagemaker.config import fetch_sagemaker_config, validate_sagemaker_config
24+
from sagemaker.config import load_sagemaker_config, validate_sagemaker_config
2525
from sagemaker.local.image import _SageMakerContainer
2626
from sagemaker.local.utils import get_docker_host
2727
from sagemaker.local.entities import (
@@ -626,7 +626,7 @@ def __init__(
626626
SAGEMAKER_ADMIN_CONFIG_OVERRIDE and SAGEMAKER_USER_CONFIG_OVERRIDE),
627627
a new dictionary will be generated from those configuration files. Alternatively,
628628
this dictionary can be generated by calling
629-
:func:`~sagemaker.config.fetch_sagemaker_config` and then be provided to the
629+
:func:`~sagemaker.config.load_sagemaker_config` and then be provided to the
630630
Session.
631631
"""
632632
self.s3_endpoint_url = s3_endpoint_url
@@ -684,11 +684,11 @@ def _initialize(
684684
self.sagemaker_config = (
685685
sagemaker_config
686686
if sagemaker_config
687-
else fetch_sagemaker_config(s3_resource=self.s3_resource)
687+
else load_sagemaker_config(s3_resource=self.s3_resource)
688688
)
689689
else:
690690
self.sagemaker_config = (
691-
sagemaker_config if sagemaker_config else fetch_sagemaker_config()
691+
sagemaker_config if sagemaker_config else load_sagemaker_config()
692692
)
693693

694694
sagemaker_config_file = os.path.join(os.path.expanduser("~"), ".sagemaker", "config.yaml")

src/sagemaker/session.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import sagemaker.logs
3434
from sagemaker import vpc_utils
3535
from sagemaker._studio import _append_project_tags
36-
from sagemaker.config import fetch_sagemaker_config, validate_sagemaker_config # noqa: F401
36+
from sagemaker.config import load_sagemaker_config, validate_sagemaker_config # noqa: F401
3737
from sagemaker.config import (
3838
KEY,
3939
TRAINING_JOB,
@@ -197,7 +197,7 @@ def __init__(
197197
SAGEMAKER_ADMIN_CONFIG_OVERRIDE and SAGEMAKER_USER_CONFIG_OVERRIDE),
198198
a new dictionary will be generated from those configuration files. Alternatively,
199199
this dictionary can be generated by calling
200-
:func:`~sagemaker.config.fetch_sagemaker_config` and then be provided to the
200+
:func:`~sagemaker.config.load_sagemaker_config` and then be provided to the
201201
Session.
202202
"""
203203
self._default_bucket = None
@@ -274,7 +274,7 @@ def _initialize(
274274
s3 = self.boto_session.resource("s3", region_name=self.boto_region_name)
275275
else:
276276
s3 = self.s3_resource
277-
self.sagemaker_config = fetch_sagemaker_config(s3_resource=s3)
277+
self.sagemaker_config = load_sagemaker_config(s3_resource=s3)
278278

279279
@property
280280
def boto_region_name(self):

src/sagemaker/workflow/pipeline_context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ def __init__(
140140
SAGEMAKER_ADMIN_CONFIG_OVERRIDE and SAGEMAKER_USER_CONFIG_OVERRIDE),
141141
a new dictionary will be generated from those configuration files. Alternatively,
142142
this dictionary can be generated by calling
143-
:func:`~sagemaker.config.fetch_sagemaker_config` and then be provided to the
143+
:func:`~sagemaker.config.load_sagemaker_config` and then be provided to the
144144
Session.
145145
"""
146146
super().__init__(

tests/integ/test_sagemaker_config.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
Predictor,
2828
Session,
2929
)
30-
from sagemaker.config import fetch_sagemaker_config
30+
from sagemaker.config import load_sagemaker_config
3131
from sagemaker.model_monitor import DataCaptureConfig
3232
from sagemaker.s3 import S3Uploader
3333
from sagemaker.sparkml import SparkMLModel
@@ -144,7 +144,7 @@ def sagemaker_session_with_dynamically_generated_sagemaker_config(
144144
sagemaker_client=sagemaker_client,
145145
sagemaker_runtime_client=runtime_client,
146146
sagemaker_metrics_client=metrics_client,
147-
sagemaker_config=fetch_sagemaker_config([dynamic_sagemaker_config_yaml_path]),
147+
sagemaker_config=load_sagemaker_config([dynamic_sagemaker_config_yaml_path]),
148148
)
149149

150150
return session
@@ -173,7 +173,7 @@ def test_config_download_from_s3_and_merge(
173173
)
174174

175175
# The thing being tested.
176-
sagemaker_config = fetch_sagemaker_config(
176+
sagemaker_config = load_sagemaker_config(
177177
additional_config_paths=[s3_uri_config_1, config_file_2_local_path]
178178
)
179179

tests/unit/sagemaker/config/test_config.py

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
import yaml
1818
from mock import Mock, MagicMock
1919

20-
from sagemaker.config.config import fetch_sagemaker_config
20+
from sagemaker.config.config import load_sagemaker_config
2121
from jsonschema import exceptions
2222
from yaml.constructor import ConstructorError
2323

@@ -37,14 +37,14 @@ def expected_merged_config(get_data_dir):
3737

3838

3939
def test_config_when_default_config_file_and_user_config_file_is_not_found():
40-
assert fetch_sagemaker_config() == {}
40+
assert load_sagemaker_config() == {}
4141

4242

4343
def test_config_when_overriden_default_config_file_is_not_found(get_data_dir):
4444
fake_config_file_path = os.path.join(get_data_dir, "config-not-found.yaml")
4545
os.environ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE"] = fake_config_file_path
4646
with pytest.raises(ValueError):
47-
fetch_sagemaker_config()
47+
load_sagemaker_config()
4848
del os.environ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE"]
4949

5050

@@ -55,14 +55,14 @@ def test_invalid_config_file_which_has_python_code(get_data_dir):
5555
# PyYAML will throw exceptions for yaml.safe_load. SageMaker Config is using
5656
# yaml.safe_load internally
5757
with pytest.raises(ConstructorError) as exception_info:
58-
fetch_sagemaker_config(additional_config_paths=[invalid_config_file_path])
58+
load_sagemaker_config(additional_config_paths=[invalid_config_file_path])
5959
assert "python/object/apply:eval" in str(exception_info.value)
6060

6161

6262
def test_config_when_additional_config_file_path_is_not_found(get_data_dir):
6363
fake_config_file_path = os.path.join(get_data_dir, "config-not-found.yaml")
6464
with pytest.raises(ValueError):
65-
fetch_sagemaker_config(additional_config_paths=[fake_config_file_path])
65+
load_sagemaker_config(additional_config_paths=[fake_config_file_path])
6666

6767

6868
def test_config_factory_when_override_user_config_file_is_not_found(get_data_dir):
@@ -71,15 +71,15 @@ def test_config_factory_when_override_user_config_file_is_not_found(get_data_dir
7171
)
7272
os.environ["SAGEMAKER_USER_CONFIG_OVERRIDE"] = fake_additional_override_config_file_path
7373
with pytest.raises(ValueError):
74-
fetch_sagemaker_config()
74+
load_sagemaker_config()
7575
del os.environ["SAGEMAKER_USER_CONFIG_OVERRIDE"]
7676

7777

7878
def test_default_config_file_with_invalid_schema(get_data_dir):
7979
config_file_path = os.path.join(get_data_dir, "invalid_config_file.yaml")
8080
os.environ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE"] = config_file_path
8181
with pytest.raises(exceptions.ValidationError):
82-
fetch_sagemaker_config()
82+
load_sagemaker_config()
8383
del os.environ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE"]
8484

8585

@@ -90,7 +90,7 @@ def test_default_config_file_when_directory_is_provided_as_the_path(
9090
expected_config = base_config_with_schema
9191
expected_config["SageMaker"] = valid_config_with_all_the_scopes
9292
os.environ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE"] = get_data_dir
93-
assert expected_config == fetch_sagemaker_config()
93+
assert expected_config == load_sagemaker_config()
9494
del os.environ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE"]
9595

9696

@@ -100,7 +100,7 @@ def test_additional_config_paths_when_directory_is_provided(
100100
# This will try to load config.yaml file from that directory if present.
101101
expected_config = base_config_with_schema
102102
expected_config["SageMaker"] = valid_config_with_all_the_scopes
103-
assert expected_config == fetch_sagemaker_config(additional_config_paths=[get_data_dir])
103+
assert expected_config == load_sagemaker_config(additional_config_paths=[get_data_dir])
104104

105105

106106
def test_default_config_file_when_path_is_provided_as_environment_variable(
@@ -110,7 +110,7 @@ def test_default_config_file_when_path_is_provided_as_environment_variable(
110110
# This will try to load config.yaml file from that directory if present.
111111
expected_config = base_config_with_schema
112112
expected_config["SageMaker"] = valid_config_with_all_the_scopes
113-
assert expected_config == fetch_sagemaker_config()
113+
assert expected_config == load_sagemaker_config()
114114
del os.environ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE"]
115115

116116

@@ -123,7 +123,7 @@ def test_merge_behavior_when_additional_config_file_path_is_not_found(
123123
)
124124
os.environ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE"] = valid_config_file_path
125125
with pytest.raises(ValueError):
126-
fetch_sagemaker_config(additional_config_paths=[fake_additional_override_config_file_path])
126+
load_sagemaker_config(additional_config_paths=[fake_additional_override_config_file_path])
127127
del os.environ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE"]
128128

129129

@@ -133,11 +133,11 @@ def test_merge_behavior(get_data_dir, expected_merged_config):
133133
get_data_dir, "sample_additional_config_for_merge.yaml"
134134
)
135135
os.environ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE"] = valid_config_file_path
136-
assert expected_merged_config == fetch_sagemaker_config(
136+
assert expected_merged_config == load_sagemaker_config(
137137
additional_config_paths=[additional_override_config_file_path]
138138
)
139139
os.environ["SAGEMAKER_USER_CONFIG_OVERRIDE"] = additional_override_config_file_path
140-
assert expected_merged_config == fetch_sagemaker_config()
140+
assert expected_merged_config == load_sagemaker_config()
141141
del os.environ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE"]
142142
del os.environ["SAGEMAKER_USER_CONFIG_OVERRIDE"]
143143

@@ -160,7 +160,7 @@ def test_s3_config_file(
160160
config_file_s3_uri = "s3://{}/{}".format(config_file_bucket, config_file_s3_prefix)
161161
expected_config = base_config_with_schema
162162
expected_config["SageMaker"] = valid_config_with_all_the_scopes
163-
assert expected_config == fetch_sagemaker_config(
163+
assert expected_config == load_sagemaker_config(
164164
additional_config_paths=[config_file_s3_uri], s3_resource=s3_resource_mock
165165
)
166166

@@ -174,7 +174,7 @@ def test_config_factory_when_default_s3_config_file_is_not_found(s3_resource_moc
174174
).all.return_value = []
175175
config_file_s3_uri = "s3://{}/{}".format(config_file_bucket, config_file_s3_prefix)
176176
with pytest.raises(ValueError):
177-
fetch_sagemaker_config(
177+
load_sagemaker_config(
178178
additional_config_paths=[config_file_s3_uri], s3_resource=s3_resource_mock
179179
)
180180

@@ -204,7 +204,7 @@ def test_s3_config_file_when_uri_provided_corresponds_to_a_path(
204204
config_file_s3_uri = "s3://{}/{}".format(config_file_bucket, config_file_s3_prefix)
205205
expected_config = base_config_with_schema
206206
expected_config["SageMaker"] = valid_config_with_all_the_scopes
207-
assert expected_config == fetch_sagemaker_config(
207+
assert expected_config == load_sagemaker_config(
208208
additional_config_paths=[config_file_s3_uri], s3_resource=s3_resource_mock
209209
)
210210

@@ -231,7 +231,7 @@ def test_merge_of_s3_default_config_file_and_regular_config_file(
231231
get_data_dir, "sample_additional_config_for_merge.yaml"
232232
)
233233
os.environ["SAGEMAKER_ADMIN_CONFIG_OVERRIDE"] = config_file_s3_uri
234-
assert expected_merged_config == fetch_sagemaker_config(
234+
assert expected_merged_config == load_sagemaker_config(
235235
additional_config_paths=[additional_override_config_file_path],
236236
s3_resource=s3_resource_mock,
237237
)

0 commit comments

Comments
 (0)