IMPORTANT NOTE: These assays were run in a Wallaroo environment with canned historical data. See the Wallaroo Assay Tutorial for details on setting up this environment. This historical data is required for these examples.
Create a new array in a specified pipeline.
"input|output field_name field_index
.As noted this example requires the Wallaroo Assay Tutorial for historical data. Before running this example, set the sample pipeline id, pipeline, name, model name, and workspace id in the code sample below.
For our example, we will be using the output of the field dense_2
at the index 0 for the iopath.
For more information on retrieving this information, see the Wallaroo Developer Guides.
# Retrieve information for the housepricedrift workspace
# List workspaces
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/workspaces/list"
data = {
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
assay_workspace = next(workspace for workspace in response["workspaces"] if workspace["name"] == "housepricedrift")
assay_workspace_id = assay_workspace['id']
assay_pipeline_id = assay_workspace['pipelines'][0]
## Create assay
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/assays/create"
exampleAssayName = "api assay"
## Now get all of the assays for the pipeline in workspace 4 `housepricedrift`
exampleAssayPipelineId = assay_pipeline_id
exampleAssayPipelineName = "housepricepipe"
exampleAssayModelName = "housepricemodel"
exampleAssayWorkspaceId = assay_workspace_id
# iopath can be input 00 or output 0 0
data = {
'name': exampleAssayName,
'pipeline_id': exampleAssayPipelineId,
'pipeline_name': exampleAssayPipelineName,
'active': True,
'status': 'active',
'iopath': "output dense_2 0",
'baseline': {
'Fixed': {
'pipeline': exampleAssayPipelineName,
'model': exampleAssayModelName,
'start_at': '2023-01-01T00:00:00-05:00',
'end_at': '2023-01-02T00:00:00-05:00'
}
},
'window': {
'pipeline': exampleAssayPipelineName,
'model': exampleAssayModelName,
'width': '24 hours',
'start': None,
'interval': None
},
'summarizer': {
'type': 'UnivariateContinuous',
'bin_mode': 'Quantile',
'aggregation': 'Density',
'metric': 'PSI',
'num_bins': 5,
'bin_weights': None,
'bin_width': None,
'provided_edges': None,
'add_outlier_edges': True
},
'warning_threshold': 0,
'alert_threshold': 0.1,
'run_until': None,
'workspace_id': exampleAssayWorkspaceId
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
example_assay_id = response['assay_id']
response
{'assay_id': 5}
Lists all assays in the specified pipeline.
Example: Display a list of all assays in a workspace. This will assume we have a workspace with an existing Assay and the associated data has been upload. See the tutorial Wallaroo Assays Tutorial.
For this reason, these values are hard coded for now.
# Get assays
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/assays/list"
data = {
"pipeline_id": exampleAssayPipelineId
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
response
[{'id': 5,
'name': 'api assay',
'active': True,
'status': 'created',
'warning_threshold': 0.0,
'alert_threshold': 0.1,
'pipeline_id': 1,
'pipeline_name': 'housepricepipe',
'last_run': None,
'next_run': '2023-05-19T17:26:51.743327+00:00',
'run_until': None,
'updated_at': '2023-05-19T17:26:51.745495+00:00',
'baseline': {'Fixed': {'pipeline': 'housepricepipe',
'model': 'housepricemodel',
'start_at': '2023-01-01T00:00:00-05:00',
'end_at': '2023-01-02T00:00:00-05:00'}},
'window': {'pipeline': 'housepricepipe',
'model': 'housepricemodel',
'width': '24 hours',
'start': None,
'interval': None},
'summarizer': {'type': 'UnivariateContinuous',
'bin_mode': 'Quantile',
'aggregation': 'Density',
'metric': 'PSI',
'num_bins': 5,
'bin_weights': None,
'provided_edges': None}},
{'id': 2,
'name': 'onmyexample assay',
'active': True,
'status': 'created',
'warning_threshold': None,
'alert_threshold': 0.5,
'pipeline_id': 1,
'pipeline_name': 'housepricepipe',
'last_run': None,
'next_run': '2023-05-17T21:46:58.633746+00:00',
'run_until': None,
'updated_at': '2023-05-17T21:46:58.636786+00:00',
'baseline': {'Fixed': {'pipeline': 'housepricepipe',
'model': 'housepricemodel',
'start_at': '2023-01-01T00:00:00+00:00',
'end_at': '2023-01-02T00:00:00+00:00'}},
'window': {'pipeline': 'housepricepipe',
'model': 'housepricemodel',
'width': '24 hours',
'start': None,
'interval': None},
'summarizer': {'type': 'UnivariateContinuous',
'bin_mode': 'Quantile',
'aggregation': 'Density',
'metric': 'PSI',
'num_bins': 5,
'bin_weights': None,
'provided_edges': None}},
{'id': 1,
'name': 'api_assay',
'active': True,
'status': 'created',
'warning_threshold': 0.0,
'alert_threshold': 0.1,
'pipeline_id': 1,
'pipeline_name': 'housepricepipe',
'last_run': None,
'next_run': '2023-05-17T20:54:09.27658+00:00',
'run_until': None,
'updated_at': '2023-05-17T20:54:09.27932+00:00',
'baseline': {'Fixed': {'pipeline': 'housepricepipe',
'model': 'housepricemodel',
'start_at': '2023-01-01T00:00:00-05:00',
'end_at': '2023-01-02T00:00:00-05:00'}},
'window': {'pipeline': 'housepricepipe',
'model': 'housepricemodel',
'width': '24 hours',
'start': None,
'interval': None},
'summarizer': {'type': 'UnivariateContinuous',
'bin_mode': 'Quantile',
'aggregation': 'Density',
'metric': 'PSI',
'num_bins': 5,
'bin_weights': None,
'provided_edges': None}}]
Activates or deactivates an existing assay.
Example: Assay 8 “House Output Assay” will be deactivated then activated.
# Deactivate assay
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/assays/set_active"
data = {
'id': example_assay_id,
'active': False
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
response
{'id': 5, 'active': False}
# Activate assay
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/assays/set_active"
data = {
'id': example_assay_id,
'active': True
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
response
{'id': 5, 'active': True}
Creates an interactive assay baseline.
Example: An interactive assay baseline will be set for the assay “Test Assay” on Pipeline 4.
## Run interactive baseline
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/assays/run_interactive_baseline"
data = {
'id': example_assay_id,
'name': exampleAssayName,
'pipeline_id': exampleAssayPipelineId,
'pipeline_name': exampleAssayPipelineName,
'active': True,
'status': 'active',
'iopath': "output dense_2 0",
'baseline': {
'Fixed': {
'pipeline': exampleAssayPipelineName,
'model': exampleAssayModelName,
'start_at': '2023-01-01T00:00:00-05:00',
'end_at': '2023-01-02T00:00:00-05:00'
}
},
'window': {
'pipeline': exampleAssayPipelineName,
'model': exampleAssayModelName,
'width': '24 hours',
'start': None,
'interval': None
},
'summarizer': {
'type': 'UnivariateContinuous',
'bin_mode': 'Quantile',
'aggregation': 'Density',
'metric': 'PSI',
'num_bins': 5,
'bin_weights': None,
'bin_width': None,
'provided_edges': None,
'add_outlier_edges': True
},
'warning_threshold': 0,
'alert_threshold': 0.1,
'run_until': None,
'workspace_id': exampleAssayWorkspaceId
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
response
{'id': None,
'assay_id': 5,
'window_start': '2023-01-01T05:00:00Z',
'analyzed_at': '2023-05-19T17:26:59.664583293Z',
'elapsed_millis': 0,
'iopath': 'output dense_2 0',
'pipeline_id': None,
'baseline_summary': {'count': 181,
'min': 12.002464294433594,
'max': 14.095687866210938,
'mean': 12.892810610776449,
'median': 12.862584114074709,
'std': 0.4259400394014014,
'edges': [12.002464294433594,
12.525982856750488,
12.772802352905272,
12.960931777954102,
13.246906280517578,
14.095687866210938,
None],
'edge_names': ['left_outlier',
'q_20',
'q_40',
'q_60',
'q_80',
'q_100',
'right_outlier'],
'aggregated_values': [0.0,
0.19889502762430936,
0.19889502762430936,
0.20441988950276244,
0.19889502762430936,
0.19889502762430936,
0.0],
'aggregation': 'Density',
'start': '2023-01-01T05:00:00Z',
'end': '2023-01-02T05:00:00Z'},
'window_summary': {'count': 181,
'min': 12.002464294433594,
'max': 14.095687866210938,
'mean': 12.892810610776449,
'median': 12.862584114074709,
'std': 0.4259400394014014,
'edges': [12.002464294433594,
12.525982856750488,
12.772802352905272,
12.960931777954102,
13.246906280517578,
14.095687866210938,
None],
'edge_names': ['left_outlier',
'e_1.25e1',
'e_1.28e1',
'e_1.30e1',
'e_1.32e1',
'e_1.41e1',
'right_outlier'],
'aggregated_values': [0.0,
0.19889502762430936,
0.19889502762430936,
0.20441988950276244,
0.19889502762430936,
0.19889502762430936,
0.0],
'aggregation': 'Density',
'start': '2023-01-01T05:00:00Z',
'end': '2023-01-02T05:00:00Z'},
'warning_threshold': 0.0,
'alert_threshold': 0.1,
'score': 0.0,
'scores': [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0],
'bin_index': None,
'summarizer': {'type': 'UnivariateContinuous',
'bin_mode': 'Quantile',
'aggregation': 'Density',
'metric': 'PSI',
'num_bins': 5,
'bin_weights': None,
'provided_edges': None},
'status': 'BaselineRun',
'created_at': None}
Retrieve an assay baseline.
Example: 3 assay baselines for Workspace 6 and pipeline houseprice-pipe
will be retrieved.
## Get Assay Baseline
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/assays/get_baseline"
data = {
'workspace_id': exampleAssayWorkspaceId,
'pipeline_name': exampleAssayPipelineName,
'limit': 3
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
response[0:2]
[{'time': 1672531200000,
'in.tensor': [0.6752651953165153,
-0.4732014898144956,
-1.0785881334179752,
0.25006446993148707,
-0.08666382440547035,
0.012211745933432551,
-0.1904726364343265,
-0.9179715198382244,
-0.305653139057544,
0.905425782569012,
-0.5584151415472702,
-0.8905121321380776,
1.7014907488187343,
-0.03617359856638,
-0.20817781526102327,
-0.4017891748132812,
-0.19176790501742016],
'out.dense_2': [12.529610633850098],
'metadata.last_model': '{"model_name": "housepricemodel", "model_sha": "test_version"}',
'metadata.profile': '{"elapsed_ns": 243}'},
{'time': 1672531676753,
'in.tensor': [-0.39764636440424433,
-0.4732014898144956,
0.5769261528142077,
0.07215545493232875,
-0.08666382440547035,
0.5668723158705202,
0.0035716408873876734,
-0.9179715198382244,
-0.305653139057544,
0.905425782569012,
0.29288456205300767,
-0.10763168763453018,
1.3841294506067472,
-0.13822039562434324,
-0.20817781526102327,
1.392623186456163,
0.0831911918963078],
'out.dense_2': [13.355737686157228],
'metadata.last_model': '{"model_name": "housepricemodel", "model_sha": "test_version"}',
'metadata.profile': '{"elapsed_ns": 216}'}]
Runs an assay.
Example: An interactive assay will be run for Assay exampleAssayId exampleAssayName. Depending on the number of assay results and the data window, this may take some time. This returns all of the results for this assay at this time. The total number of responses will be displayed after.
## Run interactive assay
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/assays/run_interactive"
data = {
'id': example_assay_id,
'name': exampleAssayName,
'pipeline_id': exampleAssayPipelineId,
'pipeline_name': exampleAssayPipelineName,
'active': True,
'status': 'active',
'iopath': "output dense_2 0",
'baseline': {
'Fixed': {
'pipeline': exampleAssayPipelineName,
'model': exampleAssayModelName,
'start_at': '2023-01-01T00:00:00-05:00',
'end_at': '2023-01-02T00:00:00-05:00'
}
},
'window': {
'pipeline': exampleAssayPipelineName,
'model': exampleAssayModelName,
'width': '24 hours',
'start': None,
'interval': None
},
'summarizer': {
'type': 'UnivariateContinuous',
'bin_mode': 'Quantile',
'aggregation': 'Density',
'metric': 'PSI',
'num_bins': 5,
'bin_weights': None,
'bin_width': None,
'provided_edges': None,
'add_outlier_edges': True
},
'warning_threshold': 0,
'alert_threshold': 0.1,
'run_until': None,
'workspace_id': exampleAssayWorkspaceId
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
response[0]
{'id': None,
'assay_id': 1,
'window_start': '2023-01-02T05:00:00Z',
'analyzed_at': '2023-05-17T20:54:19.568121901Z',
'elapsed_millis': 578,
'iopath': 'output dense_2 0',
'pipeline_id': None,
'baseline_summary': {'count': 181,
'min': 12.002464294433594,
'max': 14.095687866210938,
'mean': 12.892810610776449,
'median': 12.862584114074709,
'std': 0.4259400394014014,
'edges': [12.002464294433594,
12.525982856750488,
12.772802352905272,
12.960931777954102,
13.246906280517578,
14.095687866210938,
None],
'edge_names': ['left_outlier',
'q_20',
'q_40',
'q_60',
'q_80',
'q_100',
'right_outlier'],
'aggregated_values': [0.0,
0.19889502762430936,
0.19889502762430936,
0.20441988950276244,
0.19889502762430936,
0.19889502762430936,
0.0],
'aggregation': 'Density',
'start': '2023-01-01T05:00:00Z',
'end': '2023-01-02T05:00:00Z'},
'window_summary': {'count': 182,
'min': 12.037200927734377,
'max': 14.712774276733398,
'mean': 12.966292286967184,
'median': 12.895143508911133,
'std': 0.4705339357836451,
'edges': [12.002464294433594,
12.525982856750488,
12.772802352905272,
12.960931777954102,
13.246906280517578,
14.095687866210938,
None],
'edge_names': ['left_outlier',
'e_1.25e1',
'e_1.28e1',
'e_1.30e1',
'e_1.32e1',
'e_1.41e1',
'right_outlier'],
'aggregated_values': [0.0,
0.17032967032967034,
0.17582417582417584,
0.23626373626373623,
0.1978021978021978,
0.1978021978021978,
0.02197802197802198],
'aggregation': 'Density',
'start': '2023-01-02T05:00:00Z',
'end': '2023-01-03T05:00:00Z'},
'warning_threshold': 0.0,
'alert_threshold': 0.1,
'score': 0.037033182069201614,
'scores': [0.0,
0.0044288126945783235,
0.00284446741288289,
0.004610114809454446,
6.021116179797982e-06,
6.021116179797982e-06,
0.02513774491992636],
'bin_index': None,
'summarizer': {'type': 'UnivariateContinuous',
'bin_mode': 'Quantile',
'aggregation': 'Density',
'metric': 'PSI',
'num_bins': 5,
'bin_weights': None,
'provided_edges': None},
'status': 'Warning',
'created_at': None}
print(len(response))
30
Retrieve the results for an assay.
# Get Assay Results
# Retrieve the token
headers = wl.auth.auth_header()
api_request = f"{APIURL}/v1/api/assays/get_results"
data = {
'assay_id': example_assay_id,
'pipeline_id': exampleAssayPipelineId
}
response = requests.post(api_request, json=data, headers=headers, verify=True).json()
response