Skip to content

Commit f6ab044

Browse files
authored
Merge branch 'master' into amtviz
2 parents 10b6bee + 844b558 commit f6ab044

File tree

14 files changed

+98
-23
lines changed

14 files changed

+98
-23
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
# Changelog
22

3+
## v2.246.0 (2025-06-04)
4+
5+
### Features
6+
7+
* Triton v25.04 DLC
8+
9+
### Bug Fixes and Other Changes
10+
11+
* Update Attrs version to widen support
12+
* update estimator documentation regarding hyperparameters for source_dir
13+
314
## v2.245.0 (2025-05-28)
415

516
### Features

VERSION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
2.245.1.dev0
1+
2.246.1.dev0

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ classifiers = [
3131
"Programming Language :: Python :: 3.12",
3232
]
3333
dependencies = [
34-
"attrs>=23.1.0,<24",
34+
"attrs>=24,<26",
3535
"boto3>=1.35.75,<2.0",
3636
"cloudpickle>=2.2.1",
3737
"docker",

requirements/extras/test_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ stopit==1.1.2
1717
apache-airflow==2.10.4
1818
apache-airflow-providers-amazon==7.2.1
1919
Flask-Limiter==3.11
20-
attrs>=23.1.0,<24
20+
attrs>=24,<26
2121
fabric==3.2.2
2222
requests==2.32.2
2323
sagemaker-experiments==0.1.35

src/sagemaker/estimator.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -456,6 +456,9 @@ def __init__(
456456
A dictionary containing the hyperparameters to
457457
initialize this estimator with. (Default: None).
458458
459+
If a source directory is specified, the set_hyperparameters method escapes
460+
the dict argument as JSON, and updates the private hyperparameter attribute.
461+
459462
.. caution::
460463
You must not include any security-sensitive information, such as
461464
account access IDs, secrets, and tokens, in the dictionary for configuring

src/sagemaker/modules/configs.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
from __future__ import absolute_import
2323

24-
from typing import Optional, Union
24+
from typing import Optional, Union, List
2525
from pydantic import BaseModel, model_validator, ConfigDict
2626

2727
import sagemaker_core.shapes as shapes
@@ -96,12 +96,23 @@ class SourceCode(BaseConfig):
9696
command (Optional[str]):
9797
The command(s) to execute in the training job container. Example: "python my_script.py".
9898
If not specified, entry_script must be provided.
99+
ignore_patterns: (Optional[List[str]]) :
100+
The ignore patterns to ignore specific files/folders when uploading to S3. If not specified,
101+
default to: ['.env', '.git', '__pycache__', '.DS_Store', '.cache', '.ipynb_checkpoints'].
99102
"""
100103

101104
source_dir: Optional[str] = None
102105
requirements: Optional[str] = None
103106
entry_script: Optional[str] = None
104107
command: Optional[str] = None
108+
ignore_patterns: Optional[List[str]] = [
109+
".env",
110+
".git",
111+
"__pycache__",
112+
".DS_Store",
113+
".cache",
114+
".ipynb_checkpoints",
115+
]
105116

106117

107118
class Compute(shapes.ResourceConfig):

src/sagemaker/modules/train/model_trainer.py

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ class ModelTrainer(BaseModel):
119119
from sagemaker.modules.train import ModelTrainer
120120
from sagemaker.modules.configs import SourceCode, Compute, InputData
121121
122-
source_code = SourceCode(source_dir="source", entry_script="train.py")
122+
ignore_patterns = ['.env', '.git', '__pycache__', '.DS_Store', 'data']
123+
source_code = SourceCode(source_dir="source", entry_script="train.py", ignore_patterns=ignore_patterns)
123124
training_image = "123456789012.dkr.ecr.us-west-2.amazonaws.com/my-training-image"
124125
model_trainer = ModelTrainer(
125126
training_image=training_image,
@@ -654,6 +655,7 @@ def train(
654655
channel_name=SM_CODE,
655656
data_source=self.source_code.source_dir,
656657
key_prefix=input_data_key_prefix,
658+
ignore_patterns=self.source_code.ignore_patterns,
657659
)
658660
final_input_data_config.append(source_code_channel)
659661

@@ -675,6 +677,7 @@ def train(
675677
channel_name=SM_DRIVERS,
676678
data_source=tmp_dir.name,
677679
key_prefix=input_data_key_prefix,
680+
ignore_patterns=self.source_code.ignore_patterns,
678681
)
679682
final_input_data_config.append(sm_drivers_channel)
680683

@@ -755,7 +758,11 @@ def train(
755758
local_container.train(wait)
756759

757760
def create_input_data_channel(
758-
self, channel_name: str, data_source: DataSourceType, key_prefix: Optional[str] = None
761+
self,
762+
channel_name: str,
763+
data_source: DataSourceType,
764+
key_prefix: Optional[str] = None,
765+
ignore_patterns: Optional[List[str]] = None,
759766
) -> Channel:
760767
"""Create an input data channel for the training job.
761768
@@ -771,6 +778,10 @@ def create_input_data_channel(
771778
772779
If specified, local data will be uploaded to:
773780
``s3://<default_bucket_path>/<key_prefix>/<channel_name>/``
781+
ignore_patterns: (Optional[List[str]]) :
782+
The ignore patterns to ignore specific files/folders when uploading to S3.
783+
If not specified, default to: ['.env', '.git', '__pycache__', '.DS_Store',
784+
'.cache', '.ipynb_checkpoints'].
774785
"""
775786
channel = None
776787
if isinstance(data_source, str):
@@ -810,11 +821,28 @@ def create_input_data_channel(
810821
)
811822
if self.sagemaker_session.default_bucket_prefix:
812823
key_prefix = f"{self.sagemaker_session.default_bucket_prefix}/{key_prefix}"
813-
s3_uri = self.sagemaker_session.upload_data(
814-
path=data_source,
815-
bucket=self.sagemaker_session.default_bucket(),
816-
key_prefix=key_prefix,
817-
)
824+
if ignore_patterns and _is_valid_path(data_source, path_type="Directory"):
825+
tmp_dir = TemporaryDirectory()
826+
copied_path = os.path.join(
827+
tmp_dir.name, os.path.basename(os.path.normpath(data_source))
828+
)
829+
shutil.copytree(
830+
data_source,
831+
copied_path,
832+
dirs_exist_ok=True,
833+
ignore=shutil.ignore_patterns(*ignore_patterns),
834+
)
835+
s3_uri = self.sagemaker_session.upload_data(
836+
path=copied_path,
837+
bucket=self.sagemaker_session.default_bucket(),
838+
key_prefix=key_prefix,
839+
)
840+
else:
841+
s3_uri = self.sagemaker_session.upload_data(
842+
path=data_source,
843+
bucket=self.sagemaker_session.default_bucket(),
844+
key_prefix=key_prefix,
845+
)
818846
channel = Channel(
819847
channel_name=channel_name,
820848
data_source=DataSource(
@@ -861,7 +889,9 @@ def _get_input_data_config(
861889
channels.append(input_data)
862890
elif isinstance(input_data, InputData):
863891
channel = self.create_input_data_channel(
864-
input_data.channel_name, input_data.data_source, key_prefix=key_prefix
892+
input_data.channel_name,
893+
input_data.data_source,
894+
key_prefix=key_prefix,
865895
)
866896
channels.append(channel)
867897
else:

src/sagemaker/serve/utils/conda_in_process.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ dependencies:
88
- fastapi>=0.111.0
99
- nest-asyncio
1010
- pip>=23.0.1
11-
- attrs>=23.1.0,<24
11+
- attrs>=24,<26
1212
- boto3>=1.34.142,<2.0
1313
- cloudpickle==2.2.1
1414
- google-pasta

src/sagemaker/session.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7509,7 +7509,7 @@ def get_model_package_args(
75097509
if source_uri is not None:
75107510
model_package_args["source_uri"] = source_uri
75117511
if model_life_cycle is not None:
7512-
model_package_args["model_life_cycle"] = model_life_cycle
7512+
model_package_args["model_life_cycle"] = model_life_cycle._to_request_dict()
75137513
if model_card is not None:
75147514
original_req = model_card._create_request_args()
75157515
if original_req.get("ModelCardName") is not None:

src/sagemaker/workflow/utilities.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,15 @@
2121
import hashlib
2222
from urllib.parse import unquote, urlparse
2323
from contextlib import contextmanager
24-
from _hashlib import HASH as Hash
24+
25+
try:
26+
# _hashlib is an internal python module, and is not present in
27+
# statically linked interpreters.
28+
from _hashlib import HASH as Hash
29+
except ImportError:
30+
import typing
31+
32+
Hash = typing.Any
2533

2634
from sagemaker.utils import base_from_name
2735
from sagemaker.workflow.parameters import Parameter

0 commit comments

Comments
 (0)