コード例 #1
0
def monitor_frequency(interval=frequency, hour_interval=None, starting_hour=None):

    # this allows users to define the frequency of data drift monitoring

    if interval == "daily":
        monitoring_frequency = CronExpressionGenerator.daily()
    if interval == "hourly":
        monitoring_frequency = CronExpressionGenerator.hourly()
    if interval == "others":
        monitoring_frequency = CronExpressionGenerator.daily_every_x_hours(
            hour_interval, starting_hour
        )
    return monitoring_frequency
コード例 #2
0
from tests.integ.retry import retries

XGBOOST_DATA_PATH = os.path.join(DATA_DIR, "xgboost_model")
ENDPOINT_INPUT_LOCAL_PATH = "/opt/ml/processing/input/endpoint"
PROBABILITY_THRESHOLD = 0.5005
PROBLEM_TYPE = "Regression"
INFERENCE_ATTRIBUTE = "0"
HEADER_OF_LABEL = "Label"
HEADER_OF_PREDICTED_LABEL = "Prediction"
HEADERS_OF_FEATURES = ["F1", "F2", "F3", "F4", "F5", "F6", "F7"]
ALL_HEADERS = [
    *HEADERS_OF_FEATURES, HEADER_OF_LABEL, HEADER_OF_PREDICTED_LABEL
]

CRON = "cron(0 * * * ? *)"
UPDATED_CRON = CronExpressionGenerator.daily()
MAX_RUNTIME_IN_SECONDS = 30 * 60
UPDATED_MAX_RUNTIME_IN_SECONDS = 25 * 60
ROLE = "SageMakerRole"
INSTANCE_COUNT = 1
INSTANCE_TYPE = "ml.c5.xlarge"
VOLUME_SIZE_IN_GB = 100
START_TIME_OFFSET = "-PT1H"
END_TIME_OFFSET = "-PT0H"
TEST_TAGS = [{"Key": "integration", "Value": "test"}]
# TODO: Remove this workaround once the API service fix is deployed to Prod
TEST_ENV = {"problem_type": PROBLEM_TYPE}


@pytest.yield_fixture(scope="module")
def endpoint_name(sagemaker_session):
コード例 #3
0
print('Model data baseline suggested at {}'.format(baseline_results_uri))

import datetime as datetime
from time import gmtime, strftime

mon_schedule_name = '{}-{}'.format(mon_schedule_name_base, datetime.datetime.now().strftime("%Y-%m-%d-%H%M%S"))

s3_report_path = f's3://{bucket}/{prefix}/monitor/report'

# Setup daily Cron job schedule 
print(f"Attempting to create monitoring schedule as {mon_schedule_name} \n")

try:
    my_default_monitor.create_monitoring_schedule(
        monitor_schedule_name=mon_schedule_name,
        endpoint_input=endpoint_name,
        output_s3_uri=s3_report_path,
        statistics=my_default_monitor.baseline_statistics(),
        constraints=my_default_monitor.suggested_constraints(),
        schedule_cron_expression=CronExpressionGenerator.daily(),
        enable_cloudwatch_metrics=True,
    )
    desc_schedule_result = my_default_monitor.describe_schedule()
    print('Created monitoring schedule. Schedule status: {}'.format(desc_schedule_result['MonitoringScheduleStatus']))
    
except:
    my_default_monitor.update_monitoring_schedule(
        endpoint_input=endpoint_name,
        schedule_cron_expression=CronExpressionGenerator.daily()
    )
    print("Monitoring schedule already exists for endpoint. Updating schedule.")
コード例 #4
0
def test_cron_expression_generator_daily_returns_expected_value_when_called_with_parameters():
    assert CronExpressionGenerator.daily(hour=5) == "cron(0 5 ? * * *)"