Skip to content

Commit 1e8e693

Browse files
committed
fix: address review comments (iteration #1)
1 parent 862ff2d commit 1e8e693

File tree

1 file changed

+4
-9
lines changed
  • sagemaker-train/src/sagemaker/train

1 file changed

+4
-9
lines changed

sagemaker-train/src/sagemaker/train/tuner.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1504,12 +1504,9 @@ def _build_training_job_definition(self, inputs):
15041504
model_trainer.stopping_condition.max_wait_time_in_seconds
15051505
)
15061506

1507-
# Get environment variables from model_trainer.
1508-
# environment is a defined attribute on ModelTrainer (typed as dict | None).
1509-
# We access it directly (consistent with how role, compute, etc. are accessed).
1510-
# We pass it through as-is when it's a dict — even an empty dict is valid for the API.
1511-
# When it's None or not a dict, we omit it from the constructor so the Pydantic
1512-
# model keeps its default (Unassigned), which is then excluded during serialization.
1507+
# Propagate environment variables from ModelTrainer.
1508+
# Only include when it's a dict (even empty); omit otherwise so the
1509+
# Pydantic field stays Unassigned and is excluded during serialization.
15131510
env = model_trainer.environment
15141511

15151512
# Build base kwargs for the definition
@@ -1524,9 +1521,7 @@ def _build_training_job_definition(self, inputs):
15241521
enable_managed_spot_training=model_trainer.compute.enable_managed_spot_training,
15251522
)
15261523

1527-
# Only include environment when it's a dict (including empty dict).
1528-
# This avoids Pydantic validation errors for non-dict values and keeps
1529-
# the field as Unassigned (excluded from serialization) when not set.
1524+
# Include environment only when it's a dict (including empty).
15301525
if isinstance(env, dict):
15311526
definition_kwargs["environment"] = env
15321527

0 commit comments

Comments
 (0)