Skip to content

change: remove slow test_run_xxx_monitor_baseline tests #2148

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Feb 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sagemaker/analytics.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ class AnalyticsMetricsBase(with_metaclass(ABCMeta, object)):
"""

def __init__(self):
"""Initializes ``AnalyticsMetricsBase`` instance."""
self._dataframe = None

def export_csv(self, filename):
Expand Down
122 changes: 0 additions & 122 deletions tests/integ/test_clarify_model_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,76 +304,6 @@ def test_run_bias_monitor(
scheduled_bias_monitor.delete_monitoring_schedule()


@pytest.mark.skipif(
tests.integ.test_region() in tests.integ.NO_MODEL_MONITORING_REGIONS,
reason="ModelMonitoring is not yet supported in this region.",
)
def test_run_bias_monitor_baseline(
sagemaker_session,
data_config,
model_config,
bias_config,
model_predicted_label_config,
endpoint_name,
ground_truth_input,
upload_actual_data,
):
monitor = ModelBiasMonitor(
role=ROLE,
instance_count=INSTANCE_COUNT,
instance_type=INSTANCE_TYPE,
volume_size_in_gb=VOLUME_SIZE_IN_GB,
max_runtime_in_seconds=MAX_RUNTIME_IN_SECONDS,
sagemaker_session=sagemaker_session,
tags=TEST_TAGS,
)

baselining_job_name = utils.unique_name_from_base("bias-baselining-job")
print("Creating baselining job: {}".format(baselining_job_name))
monitor.suggest_baseline(
data_config=data_config,
bias_config=bias_config,
model_config=model_config,
model_predicted_label_config=model_predicted_label_config,
job_name=baselining_job_name,
)
assert (
monitor.latest_baselining_job_config.probability_threshold_attribute
== BIAS_PROBABILITY_THRESHOLD
)
monitoring_schedule_name = utils.unique_name_from_base("bias-suggest-baseline")
s3_uri_monitoring_output = os.path.join(
"s3://",
sagemaker_session.default_bucket(),
endpoint_name,
monitoring_schedule_name,
"monitor_output",
)
# Let's test if the schedule can pick up analysis_config from baselining job
monitor.create_monitoring_schedule(
output_s3_uri=s3_uri_monitoring_output,
monitor_schedule_name=monitoring_schedule_name,
endpoint_input=EndpointInput(
endpoint_name=endpoint_name,
destination=ENDPOINT_INPUT_LOCAL_PATH,
start_time_offset=START_TIME_OFFSET,
end_time_offset=END_TIME_OFFSET,
),
ground_truth_input=ground_truth_input,
schedule_cron_expression=CRON,
)
_verify_execution_status(monitor)

_verify_bias_job_description(
sagemaker_session=sagemaker_session,
monitor=monitor,
endpoint_name=endpoint_name,
ground_truth_input=ground_truth_input,
)

monitor.delete_monitoring_schedule()


@pytest.fixture
def explainability_monitor(sagemaker_session):
monitor = ModelExplainabilityMonitor(
Expand Down Expand Up @@ -485,58 +415,6 @@ def test_run_explainability_monitor(
scheduled_explainability_monitor.delete_monitoring_schedule()


@pytest.mark.skipif(
tests.integ.test_region() in tests.integ.NO_MODEL_MONITORING_REGIONS,
reason="ModelMonitoring is not yet supported in this region.",
)
def test_run_explainability_monitor_baseline(
sagemaker_session, shap_config, data_config, model_config, endpoint_name, upload_actual_data
):
monitor = ModelExplainabilityMonitor(
role=ROLE,
instance_count=INSTANCE_COUNT,
instance_type=INSTANCE_TYPE,
volume_size_in_gb=VOLUME_SIZE_IN_GB,
max_runtime_in_seconds=MAX_RUNTIME_IN_SECONDS,
sagemaker_session=sagemaker_session,
tags=TEST_TAGS,
)

baselining_job_name = utils.unique_name_from_base("explainability-baselining-job")
print("Creating baselining job: {}".format(baselining_job_name))
monitor.suggest_baseline(
data_config=data_config,
explainability_config=shap_config,
model_config=model_config,
job_name=baselining_job_name,
)
monitoring_schedule_name = utils.unique_name_from_base("explainability-suggest-baseline")
s3_uri_monitoring_output = os.path.join(
"s3://",
sagemaker_session.default_bucket(),
endpoint_name,
monitoring_schedule_name,
"monitor_output",
)
# Let's test if the schedule can pick up analysis_config from baselining job
monitor.create_monitoring_schedule(
output_s3_uri=s3_uri_monitoring_output,
monitor_schedule_name=monitoring_schedule_name,
endpoint_input=endpoint_name,
schedule_cron_expression=CRON,
)

_verify_execution_status(monitor)

_verify_explainability_job_description(
sagemaker_session=sagemaker_session,
monitor=monitor,
endpoint_name=endpoint_name,
)

monitor.delete_monitoring_schedule()


def _verify_monitoring_schedule(monitor, schedule_status, schedule_cron_expression=CRON):
desc = monitor.describe_schedule()
assert desc["MonitoringScheduleName"] == monitor.monitoring_schedule_name
Expand Down