def test_list_candidates_default(sagemaker_session): auto_ml = AutoML( role=ROLE, target_attribute_name=TARGET_ATTRIBUTE_NAME, sagemaker_session=sagemaker_session ) auto_ml.current_job_name = "current_job_name" auto_ml.list_candidates() sagemaker_session.list_candidates.assert_called_once() sagemaker_session.list_candidates.assert_called_with(job_name=auto_ml.current_job_name)
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)
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_list_candidates(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) assert len(candidates) == 3
def test_candidate_estimator_get_steps(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) steps = candidate_estimator.get_steps() assert len(steps) == 3
def test_list_candidates_with_optional_args(sagemaker_session): auto_ml = AutoML(role=ROLE, target_attribute_name=TARGET_ATTRIBUTE_NAME, sagemaker_session=sagemaker_session) auto_ml.list_candidates( job_name=JOB_NAME, status_equals="Completed", candidate_name="candidate-name", candidate_arn="candidate-arn", sort_order="Ascending", sort_by="Status", max_results=99, ) sagemaker_session.list_candidates.assert_called_once() _, args = sagemaker_session.list_candidates.call_args assert args == { "job_name": JOB_NAME, "status_equals": "Completed", "candidate_name": "candidate-name", "candidate_arn": "candidate-arn", "sort_order": "Ascending", "sort_by": "Status", "max_results": 99, }