def wait_anomaly_detector()

in getting_started/utility.py [0:0]


def wait_anomaly_detector( lookoutmetrics_client, arn ):
    
    prev_status = None
    while True:

        response = lookoutmetrics_client.describe_anomaly_detector( AnomalyDetectorArn = arn )
        status = response["Status"]

        if status != prev_status:
            if prev_status:
                sys.stdout.write("\n")
            sys.stdout.write( status + " " )
            sys.stdout.flush()
            prev_status = status

        if status in ( "ACTIVATING", "BACK_TEST_ACTIVATING", "BACK_TEST_ACTIVE" ):
            sys.stdout.write(".")
            sys.stdout.flush()
            time.sleep(5)
            continue

        break

    return response