Skip to content

Commit 9e29e94

Browse files
danabensDewen Qi
authored and
Dewen Qi
committed
lowercase trial component name (aws#776)
1 parent 4bd423e commit 9e29e94

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/sagemaker/experiments/run.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757

5858
logger = logging.getLogger(__name__)
5959

60-
RUN_NAME_BASE = "Sagemaker-Run"
60+
RUN_NAME_BASE = "Sagemaker-Run".lower()
6161
TRIAL_NAME_TEMPLATE = "Default-Run-Group-{}"
6262
MAX_RUN_TC_ARTIFACTS_LEN = 30
6363
MAX_NAME_LEN_IN_BACKEND = 120
@@ -140,6 +140,10 @@ def __init__(
140140
self.experiment_name = experiment_name
141141
sagemaker_session = sagemaker_session or _utils.default_session()
142142
self.run_name = run_name or unique_name_from_base(RUN_NAME_BASE)
143+
144+
# avoid confusion due to mis-match in casing between run name and TC name
145+
self.run_name = self.run_name.lower()
146+
143147
trial_component_name = Run._generate_trial_component_name(
144148
run_name=self.run_name, experiment_name=self.experiment_name
145149
)
@@ -597,7 +601,10 @@ def _generate_trial_component_name(run_name: str, experiment_name: str) -> str:
597601
raise ValueError(
598602
err_msg_template.format("experiment_name", len(experiment_name), max_len)
599603
)
600-
return "{}{}{}".format(experiment_name, DELIMITER, run_name)
604+
trial_component_name = "{}{}{}".format(experiment_name, DELIMITER, run_name)
605+
# due to mixed-case concerns on the backend
606+
trial_component_name = trial_component_name.lower()
607+
return trial_component_name
601608

602609
@staticmethod
603610
def _extract_run_name_from_tc_name(trial_component_name: str, experiment_name: str) -> str:

tests/unit/sagemaker/experiments/test_run.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -710,9 +710,9 @@ def test_list(mock_tc_search, mock_tc_list, mock_tc_load, run_obj, sagemaker_ses
710710
[
711711
TrialComponentSearchResult(
712712
trial_component_name=Run._generate_trial_component_name(
713-
"A" + str(i), TEST_EXP_NAME
713+
"a" + str(i), TEST_EXP_NAME
714714
),
715-
trial_component_arn="B" + str(i),
715+
trial_component_arn="b" + str(i),
716716
display_name="C" + str(i),
717717
creation_time=creation_time + datetime.timedelta(hours=i),
718718
last_modified_time=last_modified_time + datetime.timedelta(hours=i),
@@ -725,7 +725,7 @@ def test_list(mock_tc_search, mock_tc_list, mock_tc_load, run_obj, sagemaker_ses
725725
mock_tc_list.return_value = [
726726
TrialComponentSummary(
727727
trial_component_name=Run._generate_trial_component_name("A" + str(i), TEST_EXP_NAME),
728-
trial_component_arn="B" + str(i),
728+
trial_component_arn="b" + str(i),
729729
display_name="C" + str(i),
730730
source_arn="D" + str(i),
731731
status=TrialComponentStatus(
@@ -743,9 +743,9 @@ def test_list(mock_tc_search, mock_tc_list, mock_tc_load, run_obj, sagemaker_ses
743743
(
744744
_TrialComponent(
745745
trial_component_name=Run._generate_trial_component_name(
746-
"A" + str(i), TEST_EXP_NAME
746+
"a" + str(i), TEST_EXP_NAME
747747
),
748-
trial_component_arn="B" + str(i),
748+
trial_component_arn="b" + str(i),
749749
display_name="C" + str(i),
750750
source_arn="D" + str(i),
751751
status=TrialComponentStatus(
@@ -783,12 +783,12 @@ def test_list(mock_tc_search, mock_tc_list, mock_tc_load, run_obj, sagemaker_ses
783783
for i in range(tc_list_len_half):
784784
run = run_list[i]
785785
assert run.experiment_name == TEST_EXP_NAME
786-
assert run.run_name == "A" + str(i)
786+
assert run.run_name == "a" + str(i)
787787
assert run._experiment
788788
assert run._trial
789789
assert isinstance(run._trial_component, _TrialComponent)
790790
assert run._trial_component.trial_component_name == Run._generate_trial_component_name(
791-
"A" + str(i), TEST_EXP_NAME
791+
"a" + str(i), TEST_EXP_NAME
792792
)
793793
assert run._in_load is False
794794
assert run._inside_load_context is False

0 commit comments

Comments
 (0)