Skip to content

Commit 7d7bf2c

Browse files
committed
fix: double Run create on load_run
fixes aws#3673
1 parent 4884d18 commit 7d7bf2c

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

src/sagemaker/experiments/run.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -633,7 +633,10 @@ def _extract_run_name_from_tc_name(trial_component_name: str, experiment_name: s
633633
Returns:
634634
str: The name of the Run object supplied by a user.
635635
"""
636-
return trial_component_name.replace("{}{}".format(experiment_name, DELIMITER), "", 1)
636+
# TODO: we should revert the lower casting once backend fix reaches prod
637+
return trial_component_name.replace(
638+
"{}{}".format(experiment_name.lower(), DELIMITER), "", 1
639+
)
637640

638641
@staticmethod
639642
def _append_run_tc_label_to_tags(tags: Optional[List[Dict[str, str]]] = None) -> list:
@@ -869,6 +872,8 @@ def list_runs(
869872
Returns:
870873
list: A list of ``Run`` objects.
871874
"""
875+
876+
# all trial components retrieved by default
872877
tc_summaries = _TrialComponent.list(
873878
experiment_name=experiment_name,
874879
created_before=created_before,

tests/unit/sagemaker/experiments/helpers.py

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818

1919
TEST_EXP_NAME = "my-experiment"
20+
TEST_EXP_NAME_MIXED_CASE = "My-eXpeRiMeNt"
2021
TEST_RUN_NAME = "my-run"
2122
TEST_EXP_DISPLAY_NAME = "my-experiment-display-name"
2223
TEST_RUN_DISPLAY_NAME = "my-run-display-name"

tests/unit/sagemaker/experiments/test_run.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@
4848
mock_trial_load_or_create_func,
4949
mock_tc_load_or_create_func,
5050
TEST_EXP_NAME,
51+
TEST_EXP_NAME_MIXED_CASE,
5152
TEST_RUN_NAME,
5253
TEST_EXP_DISPLAY_NAME,
5354
TEST_RUN_DISPLAY_NAME,
@@ -779,7 +780,7 @@ def test_list(mock_tc_search, mock_tc_list, mock_tc_load, run_obj, sagemaker_ses
779780
]
780781
mock_tc_list.return_value = [
781782
TrialComponentSummary(
782-
trial_component_name=Run._generate_trial_component_name("A" + str(i), TEST_EXP_NAME),
783+
trial_component_name=Run._generate_trial_component_name("A" + str(i), TEST_EXP_NAME_MIXED_CASE),
783784
trial_component_arn="b" + str(i),
784785
display_name="C" + str(i),
785786
source_arn="D" + str(i),
@@ -798,7 +799,7 @@ def test_list(mock_tc_search, mock_tc_list, mock_tc_load, run_obj, sagemaker_ses
798799
(
799800
_TrialComponent(
800801
trial_component_name=Run._generate_trial_component_name(
801-
"a" + str(i), TEST_EXP_NAME
802+
"a" + str(i), TEST_EXP_NAME_MIXED_CASE
802803
),
803804
trial_component_arn="b" + str(i),
804805
display_name="C" + str(i),
@@ -818,14 +819,14 @@ def test_list(mock_tc_search, mock_tc_list, mock_tc_load, run_obj, sagemaker_ses
818819
]
819820

820821
run_list = list_runs(
821-
experiment_name=TEST_EXP_NAME,
822+
experiment_name=TEST_EXP_NAME_MIXED_CASE,
822823
sort_by=SortByType.CREATION_TIME,
823824
sort_order=SortOrderType.ASCENDING,
824825
sagemaker_session=sagemaker_session,
825826
)
826827

827828
mock_tc_list.assert_called_once_with(
828-
experiment_name=TEST_EXP_NAME,
829+
experiment_name=TEST_EXP_NAME_MIXED_CASE,
829830
created_before=None,
830831
created_after=None,
831832
sort_by="CreationTime",

0 commit comments

Comments
 (0)