c93feefef7496e761869af788358e9145d6b1794,tests/integ/test_experiments_analytics.py,,test_experiment_analytics_search_by_nested_filter_sort_descending,#Any#,140

Before Change




def test_experiment_analytics_search_by_nested_filter_sort_descending(sagemaker_session):
    sm = sagemaker_session.sagemaker_client

    experiment_name = "experiment" + str(uuid.uuid4())
    sm.create_experiment(ExperimentName=experiment_name)

    for i in range(20):
        trial_name = "trial-" + str(uuid.uuid4())
        sm.create_trial(TrialName=trial_name, ExperimentName=experiment_name)
        trial_component_name = "tc-" + str(uuid.uuid4())
        sm.create_trial_component(TrialComponentName=trial_component_name, DisplayName="Training")
        sm.update_trial_component(
            TrialComponentName=trial_component_name, Parameters={"hp1": {"NumberValue": i}}
        )
        sm.associate_trial_component(TrialComponentName=trial_component_name, TrialName=trial_name)

    time.sleep(15)  // wait for search to get updated  TODO [owen-t]: Replace with retry

    search_exp = {
        "Filters": [
            {"Name": "Parents.ExperimentName", "Operator": "Equals", "Value": experiment_name},
            {"Name": "Parameters.hp1", "Operator": "GreaterThanOrEqualTo", "Value": "10"},
        ]
    }

    analytics = ExperimentAnalytics(
        sagemaker_session=sagemaker_session, search_expression=search_exp, sort_by="Parameters.hp1"
    )

    assert list(analytics.dataframe().columns) == ["TrialComponentName", "DisplayName", "hp1"]
    assert (
        len(analytics.dataframe()) > 5

After Change




def test_experiment_analytics_search_by_nested_filter_sort_descending(sagemaker_session):
    with experiment(sagemaker_session) as experiment_name:
        search_exp = {
            "Filters": [
                {"Name": "Parents.ExperimentName", "Operator": "Equals", "Value": experiment_name},
                {"Name": "Parameters.hp1", "Operator": "GreaterThanOrEqualTo", "Value": "10"},
            ]
        }

        analytics = ExperimentAnalytics(
            sagemaker_session=sagemaker_session,
            search_expression=search_exp,
            sort_by="Parameters.hp1",
        )

        assert list(analytics.dataframe().columns) == ["TrialComponentName", "DisplayName", "hp1"]
        assert (
            len(analytics.dataframe()) > 5
        )  // TODO [owen-t] Replace with == 10 and put test in retry block
        assert (
            list(analytics.dataframe()["hp1"].values)
            == sorted(analytics.dataframe()["hp1"].values)[::-1]
        )


def _delete_resources(sagemaker_client, experiment_name, trials):
    for trial, tc in trials.items():
        with _ignore_resource_not_found(sagemaker_client):
            sagemaker_client.disassociate_trial_component(TrialName=trial, TrialComponentName=tc)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 32

Instances


Project Name: aws/sagemaker-python-sdk
Commit Name: c93feefef7496e761869af788358e9145d6b1794
Time: 2020-01-20
Author: 6631887+laurenyu@users.noreply.github.com
File Name: tests/integ/test_experiments_analytics.py
Class Name:
Method Name: test_experiment_analytics_search_by_nested_filter_sort_descending


Project Name: aws/sagemaker-python-sdk
Commit Name: c93feefef7496e761869af788358e9145d6b1794
Time: 2020-01-20
Author: 6631887+laurenyu@users.noreply.github.com
File Name: tests/integ/test_experiments_analytics.py
Class Name:
Method Name: test_experiment_analytics_search_by_nested_filter


Project Name: aws/sagemaker-python-sdk
Commit Name: c93feefef7496e761869af788358e9145d6b1794
Time: 2020-01-20
Author: 6631887+laurenyu@users.noreply.github.com
File Name: tests/integ/test_experiments_analytics.py
Class Name:
Method Name: test_experiment_analytics_search_by_nested_filter_sort_ascending


Project Name: aws/sagemaker-python-sdk
Commit Name: c93feefef7496e761869af788358e9145d6b1794
Time: 2020-01-20
Author: 6631887+laurenyu@users.noreply.github.com
File Name: tests/integ/test_experiments_analytics.py
Class Name:
Method Name: test_experiment_analytics_search_by_nested_filter_sort_descending