Skip to content

Commit d7f3ed6

Browse files
authored
Merge branch 'master' into fix-localmode-subprocess-termination
2 parents 9207f5b + 0fb0822 commit d7f3ed6

File tree

12 files changed

+119
-24
lines changed

12 files changed

+119
-24
lines changed

CHANGELOG.md

+16
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,21 @@
11
# Changelog
22

3+
## v2.54.0 (2021-08-16)
4+
5+
### Features
6+
7+
* add pytorch 1.5.1 eia configuration
8+
9+
### Bug Fixes and Other Changes
10+
11+
* issue #2253 where Processing job in Local mode would call Describe…
12+
13+
## v2.53.0 (2021-08-12)
14+
15+
### Features
16+
17+
* support tuning step parameter range parameterization + support retry strategy in tuner
18+
319
## v2.52.2.post0 (2021-08-11)
420

521
### Documentation Changes

VERSION

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.52.3.dev0
1+
2.54.1.dev0

src/sagemaker/automl/automl.py

+1
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,7 @@ def create_model(
328328
predictor_cls=predictor_cls,
329329
name=name,
330330
vpc_config=vpc_config,
331+
enable_network_isolation=enable_network_isolation,
331332
sagemaker_session=sagemaker_session or self.sagemaker_session,
332333
)
333334
return pipeline

src/sagemaker/feature_store/feature_group.py

+32-10
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ def _ingest_single_batch(
207207
for row in data_frame[start_index:end_index].itertuples():
208208
record = [
209209
FeatureValue(
210-
feature_name=data_frame.columns[index - 1], value_as_string=str(row[index])
210+
feature_name=data_frame.columns[index - 1],
211+
value_as_string=str(row[index]),
211212
)
212213
for index in range(1, len(row))
213214
if pd.notna(row[index])
@@ -270,13 +271,24 @@ def _run_multi_process(self, data_frame: DataFrame, wait=True, timeout=None):
270271
timeout (Union[int, float]): ``concurrent.futures.TimeoutError`` will be raised
271272
if timeout is reached.
272273
"""
274+
# pylint: disable=I1101
273275
batch_size = math.ceil(data_frame.shape[0] / self.max_processes)
276+
# pylint: enable=I1101
274277

275278
args = []
276279
for i in range(self.max_processes):
277280
start_index = min(i * batch_size, data_frame.shape[0])
278281
end_index = min(i * batch_size + batch_size, data_frame.shape[0])
279-
args += [(data_frame[start_index:end_index], start_index, timeout)]
282+
args += [
283+
(
284+
self.max_workers,
285+
self.feature_group_name,
286+
self.sagemaker_fs_runtime_client_config,
287+
data_frame[start_index:end_index],
288+
start_index,
289+
timeout,
290+
)
291+
]
280292

281293
def init_worker():
282294
# ignore keyboard interrupts in child processes.
@@ -285,13 +297,21 @@ def init_worker():
285297
self._processing_pool = ProcessingPool(self.max_processes, init_worker)
286298
self._processing_pool.restart(force=True)
287299

288-
f = lambda x: self._run_multi_threaded(*x) # noqa: E731
300+
f = lambda x: IngestionManagerPandas._run_multi_threaded(*x) # noqa: E731
289301
self._async_result = self._processing_pool.amap(f, args)
290302

291303
if wait:
292304
self.wait(timeout=timeout)
293305

294-
def _run_multi_threaded(self, data_frame: DataFrame, row_offset=0, timeout=None) -> List[int]:
306+
@staticmethod
307+
def _run_multi_threaded(
308+
max_workers: int,
309+
feature_group_name: str,
310+
sagemaker_fs_runtime_client_config: Config,
311+
data_frame: DataFrame,
312+
row_offset=0,
313+
timeout=None,
314+
) -> List[int]:
295315
"""Start the ingestion process.
296316
297317
Args:
@@ -305,21 +325,23 @@ def _run_multi_threaded(self, data_frame: DataFrame, row_offset=0, timeout=None)
305325
Returns:
306326
List of row indices that failed to be ingested.
307327
"""
308-
executor = ThreadPoolExecutor(max_workers=self.max_workers)
309-
batch_size = math.ceil(data_frame.shape[0] / self.max_workers)
328+
executor = ThreadPoolExecutor(max_workers=max_workers)
329+
# pylint: disable=I1101
330+
batch_size = math.ceil(data_frame.shape[0] / max_workers)
331+
# pylint: enable=I1101
310332

311333
futures = {}
312-
for i in range(self.max_workers):
334+
for i in range(max_workers):
313335
start_index = min(i * batch_size, data_frame.shape[0])
314336
end_index = min(i * batch_size + batch_size, data_frame.shape[0])
315337
futures[
316338
executor.submit(
317-
self._ingest_single_batch,
318-
feature_group_name=self.feature_group_name,
339+
IngestionManagerPandas._ingest_single_batch,
340+
feature_group_name=feature_group_name,
319341
data_frame=data_frame,
320342
start_index=start_index,
321343
end_index=end_index,
322-
client_config=self.sagemaker_fs_runtime_client_config,
344+
client_config=sagemaker_fs_runtime_client_config,
323345
)
324346
] = (start_index + row_offset, end_index + row_offset)
325347

src/sagemaker/image_uri_config/model-monitor.json

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
"ap-east-1": "001633400207",
88
"ap-northeast-1": "574779866223",
99
"ap-northeast-2": "709848358524",
10+
"ap-northeast-3": "990339680094",
1011
"ap-south-1": "126357580389",
1112
"ap-southeast-1": "245545462676",
1213
"ap-southeast-2": "563025443158",

src/sagemaker/image_uri_config/pytorch.json

+16-11
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,15 @@
44
"cpu"
55
],
66
"version_aliases": {
7-
"1.3": "1.3.1"
7+
"1.3": "1.3.1",
8+
"1.5": "1.5.1"
89
},
910
"versions": {
1011
"1.3.1": {
1112
"py_versions": [
1213
"py3"
1314
],
1415
"registries": {
15-
"af-south-1": "626614931356",
16-
"ap-east-1": "871362719292",
1716
"ap-northeast-1": "763104351884",
1817
"ap-northeast-2": "763104351884",
1918
"ap-northeast-3": "364406365360",
@@ -26,16 +25,22 @@
2625
"eu-central-1": "763104351884",
2726
"eu-north-1": "763104351884",
2827
"eu-west-1": "763104351884",
29-
"eu-west-2": "763104351884",
30-
"eu-west-3": "763104351884",
31-
"eu-south-1": "692866216735",
32-
"me-south-1": "217643126080",
33-
"sa-east-1": "763104351884",
3428
"us-east-1": "763104351884",
3529
"us-east-2": "763104351884",
36-
"us-gov-west-1": "442386744353",
37-
"us-iso-east-1": "886529160074",
38-
"us-west-1": "763104351884",
30+
"us-west-2": "763104351884"
31+
},
32+
"repository": "pytorch-inference-eia"
33+
},
34+
"1.5.1": {
35+
"py_versions": [
36+
"py3"
37+
],
38+
"registries": {
39+
"ap-northeast-1": "763104351884",
40+
"ap-northeast-2": "763104351884",
41+
"eu-west-1": "763104351884",
42+
"us-east-1": "763104351884",
43+
"us-east-2": "763104351884",
3944
"us-west-2": "763104351884"
4045
},
4146
"repository": "pytorch-inference-eia"

src/sagemaker/lineage/association.py

+11
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,14 @@
1515

1616
from typing import Optional, Iterator
1717
from datetime import datetime
18+
import logging
1819

1920
from sagemaker.apiutils import _base_types
2021
from sagemaker.lineage import _api_types
2122
from sagemaker.lineage._api_types import AssociationSummary
2223

24+
logger = logging.getLogger(__name__)
25+
2326

2427
class Association(_base_types.Record):
2528
"""An Amazon SageMaker artifact, which is part of a SageMaker lineage.
@@ -73,6 +76,10 @@ def set_tag(self, tag=None):
7376
Returns:
7477
list({str:str}): a list of key value pairs
7578
"""
79+
logger.warning(
80+
"set_tag on Association is deprecated. Use set_tag on the source or destination\
81+
entity instead."
82+
)
7683
return self._set_tags(resource_arn=self.source_arn, tags=[tag])
7784

7885
def set_tags(self, tags=None):
@@ -84,6 +91,10 @@ def set_tags(self, tags=None):
8491
Returns:
8592
list({str:str}): a list of key value pairs
8693
"""
94+
logger.warning(
95+
"set_tags on Association is deprecated. Use set_tags on the source or destination\
96+
entity instead."
97+
)
8798
return self._set_tags(resource_arn=self.source_arn, tags=tags)
8899

89100
@classmethod

src/sagemaker/local/local_session.py

+15
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,21 @@ def logs_for_job(self, job_name, wait=False, poll=5, log_type="All"):
571571
# on local mode.
572572
pass # pylint: disable=unnecessary-pass
573573

574+
def logs_for_processing_job(self, job_name, wait=False, poll=10):
575+
"""A no-op method meant to override the sagemaker client.
576+
577+
Args:
578+
job_name:
579+
wait: (Default value = False)
580+
poll: (Default value = 10)
581+
582+
Returns:
583+
584+
"""
585+
# override logs_for_job() as it doesn't need to perform any action
586+
# on local mode.
587+
pass # pylint: disable=unnecessary-pass
588+
574589

575590
class file_input(object):
576591
"""Amazon SageMaker channel configuration for FILE data sources, used in local mode."""

src/sagemaker/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,7 @@ def create_tar_file(source_files, target=None):
331331
else:
332332
_, filename = tempfile.mkstemp()
333333

334-
with tarfile.open(filename, mode="w:gz") as t:
334+
with tarfile.open(filename, mode="w:gz", dereference=True) as t:
335335
for sf in source_files:
336336
# Add all files from the directory into the root of the directory structure of the tar
337337
t.add(sf, arcname=os.path.basename(sf))

tests/unit/sagemaker/image_uris/test_dlc_frameworks.py

+10-1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@
4242
"us-gov-west-1": "246785580436",
4343
"us-iso-east-1": "744548109606",
4444
}
45+
ELASTIC_INFERENCE_REGIONS = [
46+
"ap-northeast-1",
47+
"ap-northeast-2",
48+
"eu-west-1",
49+
"us-east-1",
50+
"us-east-2",
51+
"us-west-2",
52+
]
4553

4654

4755
def _test_image_uris(
@@ -385,8 +393,9 @@ def test_pytorch_eia(pytorch_eia_version, pytorch_eia_py_version):
385393
)
386394
assert expected == uri
387395

388-
for region, account in DLC_ALTERNATE_REGION_ACCOUNTS.items():
396+
for region in ELASTIC_INFERENCE_REGIONS:
389397
uri = image_uris.retrieve(region=region, **base_args)
398+
account = DLC_ALTERNATE_REGION_ACCOUNTS.get(region, DLC_ACCOUNT)
390399

391400
expected = expected_uris.framework_uri(
392401
"pytorch-inference-eia",

tests/unit/sagemaker/image_uris/test_model_monitor.py

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"ap-east-1": "001633400207",
2121
"ap-northeast-1": "574779866223",
2222
"ap-northeast-2": "709848358524",
23+
"ap-northeast-3": "990339680094",
2324
"ap-south-1": "126357580389",
2425
"ap-southeast-1": "245545462676",
2526
"ap-southeast-2": "563025443158",

tests/unit/test_local_session.py

+14
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,20 @@ def test_describe_transform_job_does_not_exist(LocalSession, _LocalTransformJob)
551551
local_sagemaker_client.describe_transform_job("transform-job-does-not-exist")
552552

553553

554+
@patch("sagemaker.local.image._SageMakerContainer.process")
555+
@patch("sagemaker.local.local_session.LocalSession")
556+
def test_logs_for_job(process, LocalSession):
557+
local_job_logs = LocalSession.logs_for_job("my-processing-job")
558+
assert local_job_logs is not None
559+
560+
561+
@patch("sagemaker.local.image._SageMakerContainer.process")
562+
@patch("sagemaker.local.local_session.LocalSession")
563+
def test_logs_for_processing_job(process, LocalSession):
564+
local_processing_job_logs = LocalSession.logs_for_processing_job("my-processing-job")
565+
assert local_processing_job_logs is not None
566+
567+
554568
@patch("sagemaker.local.local_session.LocalSession")
555569
def test_describe_endpoint_config(LocalSession):
556570
local_sagemaker_client = sagemaker.local.local_session.LocalSagemakerClient()

0 commit comments

Comments
 (0)