Пример #1
0
def test_candidate_estimator_default_rerun_and_deploy(sagemaker_session,
                                                      cpu_instance_type):
    auto_ml_utils.create_auto_ml_job_if_not_exist(sagemaker_session)

    auto_ml = AutoML(role=ROLE,
                     target_attribute_name=TARGET_ATTRIBUTE_NAME,
                     sagemaker_session=sagemaker_session)

    candidates = auto_ml.list_candidates(job_name=AUTO_ML_JOB_NAME)
    candidate = candidates[1]

    candidate_estimator = CandidateEstimator(candidate, sagemaker_session)
    inputs = sagemaker_session.upload_data(path=TEST_DATA,
                                           key_prefix=PREFIX + "/input")
    endpoint_name = unique_name_from_base(
        "sagemaker-auto-ml-rerun-candidate-test")
    with timeout(minutes=AUTO_ML_DEFAULT_TIMEMOUT_MINUTES):
        candidate_estimator.fit(inputs)
        auto_ml.deploy(
            initial_instance_count=INSTANCE_COUNT,
            instance_type=cpu_instance_type,
            candidate=candidate,
            endpoint_name=endpoint_name,
        )

    endpoint_status = sagemaker_session.sagemaker_client.describe_endpoint(
        EndpointName=endpoint_name)["EndpointStatus"]
    assert endpoint_status == "InService"
    sagemaker_session.sagemaker_client.delete_endpoint(
        EndpointName=endpoint_name)
Пример #2
0
def test_candidate_estimator_rerun_with_optional_args(sagemaker_session):
    auto_ml = AutoML(role=ROLE,
                     target_attribute_name=TARGET_ATTRIBUTE_NAME,
                     sagemaker_session=sagemaker_session)

    candidates = auto_ml.list_candidates(job_name=AUTO_ML_JOB_NAME)
    candidate = candidates[1]

    candidate_estimator = CandidateEstimator(candidate, sagemaker_session)
    inputs = sagemaker_session.upload_data(path=TEST_DATA,
                                           key_prefix=PREFIX + "/input")
    endpoint_name = unique_name_from_base(
        "sagemaker-auto-ml-rerun-candidate-test")
    with timeout(minutes=AUTO_ML_DEFAULT_TIMEMOUT_MINUTES):
        candidate_estimator.fit(inputs, encrypt_inter_container_traffic=True)
        auto_ml.deploy(
            initial_instance_count=INSTANCE_COUNT,
            instance_type=HOSTING_INSTANCE_TYPE,
            candidate=candidate,
            endpoint_name=endpoint_name,
        )

    endpoint_status = sagemaker_session.sagemaker_client.describe_endpoint(
        EndpointName=endpoint_name)["EndpointStatus"]
    assert endpoint_status == "InService"
    sagemaker_session.sagemaker_client.delete_endpoint(
        EndpointName=endpoint_name)
def test_candidate_estimator_fit(sagemaker_session):
    candidate_estimator = CandidateEstimator(
        CANDIDATE_DICT, sagemaker_session=sagemaker_session)
    candidate_estimator._check_all_job_finished = Mock(
        name="_check_all_job_finished", return_value=True)
    inputs = DEFAULT_S3_INPUT_DATA
    candidate_estimator.fit(inputs)
    sagemaker_session.train.assert_called()
    sagemaker_session.transform.assert_called()