Wallaroo MLOps API Essentials Guide: User Management
How to use the Wallaroo API for User Management
This tutorial and the assets can be downloaded as part of the Wallaroo Tutorials repository.
The Wallaroo MLOps API allows organizations to submit requests to their Wallaroo instance to perform such actions as:
The following examples will show how to submit queries to the Wallaroo MLOps API and the types of responses returned.
The following references are available for more information about Wallaroo and the Wallaroo MLOps API:
https://{Wallaroo Prefix}.api.{Wallaroo Suffix}/v1/api/docs
. For example, if the Wallaroo Instance is YOUR SUFFIX with the prefix {lovely-rhino-5555}
, then the Wallaroo MLOps API Documentation would be available at https://lovely-rhino-5555.api.example.wallaroo.ai/v1/api/docs
. For another example, a Wallaroo Enterprise users who do not use a prefix and has the suffix wallaroo.example.wallaroo.ai
, the the Wallaroo MLOps API Documentation would be available at https://api.wallaroo.example.wallaroo.ai/v1/api/docs
. For more information, see the Wallaroo Documentation Site.IMPORTANT NOTE: The Wallaroo MLOps API is provided as an early access features. Future iterations may adjust the methods and returns to provide a better user experience. Please refer to this guide for updates.
The following demonstrates how to use each command in the Wallaroo MLOps API, and can be modified as best fits your organization’s needs.
For the examples, the Python requests
library will be used to make the REST HTTP(S) connections.
# Requires requests and requests-toolbelt with either:
# pip install requests-toolbelt
# conda install -c conda-forge requests-toolbelt
import requests
import json
from requests.auth import HTTPBasicAuth
Wallaroo comes pre-installed with a confidential OpenID Connect client. The default client is api-client
, but other clients may be created and configured.
As it is a confidential client, api-client requires its secret to be supplied when requesting a token. Administrators may obtain their API client credentials from Keycloak from the Keycloak Service URL as listed above and the prefix /auth/admin/master/console/#/realms/master/clients
.
For example, if the YOUR SUFFIX instance DNS address is https://magical-rhino-5555.example.wallaroo.ai
, then the direct path to the Keycloak API client credentials would be:
https://magical-rhino-5555.keycloak.example.wallaroo.ai/auth/admin/master/console/#/realms/master/clients
Then select the client, in this case api-client, then Credentials.
By default, tokens issued for api-client are valid for up to 60 minutes. Refresh tokens are supported.
The API token can be retrieved using the Wallaroo SDK through the wallaroo.client.mlops()
command. In the following example, the token will be retrieved and stored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4dG0tkoRW1eD-aKBpsHf9nKKzxcSsjeXDQF6iQAONCGmC40oqHQ'
The following variables are used for the example and should be modified to fit your organization.
## Variables
URLPREFIX='YOURPREFIX'
URLSUFFIX='YOURSUFFIX'
SECRET="YOUR SECRET"
TOKENURL=f'https://{URLPREFIX}.keycloak.{URLSUFFIX}/auth/realms/master/protocol/openid-connect/token'
CLIENT="api-client"
USERNAME="YOUR EMAIL"
PASSWORD="YOUR PASSWORD"
APIURL=f"https://{URLPREFIX}.api.{URLSUFFIX}/v1/api"
newUser="NEW USER EMAIL"
newPassword="NEW USER PASSWORD"
The following is an output of the TOKENURL
variable to verify it matches your Wallaroo instance’s Keycloak API client credentials URL.
TOKENURL
The following methods are used to retrieve the MLOPs API Token from the Wallaroo instance’s Keycloak service, and submit MLOps API requests through the Wallaroo instance’s MLOps API.
MLOps API requests are always POST
, and are either submitted as 'Content-Type':'application/json'
or as a multipart submission including a file.
def get_jwt_token(url, client, secret, username, password):
auth = HTTPBasicAuth(client, secret)
data = {
'grant_type': 'password',
'username': username,
'password': password
}
response = requests.post(url, auth=auth, data=data, verify=True)
return response.json()['access_token']
# This can either submit a plain POST request ('Content-Type':'application/json'), or with a file.
def get_wallaroo_response(url, api_request, token, data, files=None, contentType='application/json', params=None):
apiUrl=f"{url}{api_request}"
if files is None:
# Regular POST request
headers= {
'Authorization': 'Bearer ' + token,
'Content-Type':contentType
}
response = requests.post(apiUrl, json=data, headers=headers, verify=True)
elif contentType == 'application/octet-stream':
# Post request as octet-stream
headers= {
'Authorization': 'Bearer ' + token,
'Content-Type':contentType
}
response = requests.post(apiUrl, data=files, headers=headers, params=params)
#response = requests.post(apiUrl, data=data, headers=headers, files=files, verify=True)
else:
# POST request with file
headers= {
'Authorization': 'Bearer ' + token
}
response = requests.post(apiUrl, data=data, headers=headers, files=files, verify=True)
return response.json()
To retrieve an API token for a specific user with the Client Secret, request the token from the Wallaroo instance using the client secret and provide the following:
The following sample uses the variables set above to request the token, then displays it.
TOKEN=get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MzAtM2FiNzNiY2IwNjM3IiwiZW1haWxfdmVyaWZpZWQiOmZhbHNlLCJodHRwczovL2hhc3VyYS5pby9qd3QvY2xhaW1zIjp7IngtaGFzdXJhLXVzZXItaWQiOiJjYTdkNzA0My04ZTk0LTQyZDUtOWYzYS04ZjU1YzJlNDI4MTQiLCJ4LWhhc3VyYS1kZWZhdWx0LXJvbGUiOiJ1c2VyIiwieC1oYXN1cmEtYWxsb3dlZC1yb2xlcyI6WyJ1c2VyIl0sIngtaGFzdXJhLXVzZXItZ3JvdXBzIjoie30ifSwibmFtZSI6IkpvaG4gSGFuc2FyaWNrIiwicHJlZmVycmVkX3VzZXJuYW1lIjoiam9obi5odW1tZWxAd2FsbGFyb28uYWkiLCJnaXZlbl9uYW1lIjoiSm9obiIsImZhbWlseV9uYW1lIjoiSGFuc2FyaWNrIiwiZW1haWwiOiJqb2huLmh1bW1lbEB3YWxsYXJvby5haSJ9.Qxhsu1lbhWpVZyUjKLqsr47j-ybjVB28jEXPcyb8m4NlzYDSfWHH2Wc7i1RMLV4IUe4td8ujPQJjkan2zatoHhSNqWYwEziwgFwIcP-uYqDcBhIIkNIu3Shw8f9FxAt3UtEc0twTXNED4ak2cfTs9nNwF2v_ZRcKMsrWObAfm2Iuly2tKuu6TlK_3Nbi6DTip4rXTO5AavIhjqKZn7ofuJ-NhOBh9s9gZPIZpWQ-klk-zeM7mzzulD8THBTCITvEpmMSJf9qI24-QXQWhpRFEpmUh8gy6GkQs1lEcjvt8NzLP5mf9L7fmgQZCgvETLwuA9dmp7BPYS_G3pamDGqDoA'
Users can be retrieved either by their Keycloak user id, or return all users if an empty set {}
is submitted.
{}
: Empty set, returns all users.Example: The first example will submit an empty set {}
to return all users, then submit the first user’s user id and request only that user’s details.
# Get all users
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/users/query"
data = {
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
{'users': {'9727c4a8-d6fc-4aad-894f-9ee69801d2dd': {'access': {'manageGroupMembership': True,
'impersonate': False,
'view': True,
'mapRoles': True,
'manage': True},
'createdTimestamp': 1677704075554,
'disableableCredentialTypes': [],
'emailVerified': False,
'enabled': True,
'id': '9727c4a8-d6fc-4aad-894f-9ee69801d2dd',
'notBefore': 0,
'requiredActions': [],
'username': 'admin'},
'ca7d7043-8e94-42d5-9f3a-8f55c2e42814': {'access': {'impersonate': False,
'manage': True,
'mapRoles': True,
'manageGroupMembership': True,
'view': True},
'createdTimestamp': 1677704179667,
'disableableCredentialTypes': [],
'email': 'john.hummel@wallaroo.ai',
'emailVerified': False,
'enabled': True,
'firstName': 'John',
'id': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'lastName': 'Hansarick',
'notBefore': 0,
'requiredActions': [],
'username': 'john.hummel@wallaroo.ai'}}}
# Get first user Keycloak id
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
firstUserKeycloak = list(response['users'])[1]
apiRequest = "/users/query"
data = {
"user_ids": [
firstUserKeycloak
]
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
{'users': {'ca7d7043-8e94-42d5-9f3a-8f55c2e42814': {'access': {'impersonate': False,
'view': True,
'mapRoles': True,
'manage': True,
'manageGroupMembership': True},
'createdTimestamp': 1677704179667,
'disableableCredentialTypes': [],
'email': 'john.hummel@wallaroo.ai',
'emailVerified': False,
'enabled': True,
'federatedIdentities': [{'identityProvider': 'google',
'userId': '117610299312093432527',
'userName': 'john.hummel@wallaroo.ai'}],
'firstName': 'John',
'id': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'lastName': 'Hansarick',
'notBefore': 0,
'requiredActions': [],
'username': 'john.hummel@wallaroo.ai'}}}
IMPORTANT NOTE: This command is for YOUR SUFFIX only. For more details on user management, see Wallaroo User Management.
Users can be invited through /users/invite
. When using YOUR SUFFIX, this will send an invitation email to the email address listed. Note that the user must not already be a member of the Wallaroo instance, and email addresses must be unique. If the email address is already in use for another user, the request will generate an error.
Example: In this example, a new user will be invited to the Wallaroo instance and assigned a password.
# invite users
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/users/invite"
data = {
"email": newUser,
"password":newPassword
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
Users can be deactivated so they can not login to their Wallaroo instance. Deactivated users do not count against the Wallaroo license count.
Example: In this example, the newUser
will be deactivated.
# Deactivate users
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/users/deactivate"
data = {
"email": newUser
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
A deactivated user can be reactivated to allow them access to their Wallaroo instance. Activated users count against the Wallaroo license count.
Example: In this example, the newUser
will be activated.
# Activate users
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/users/activate"
data = {
"email": newUser
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
List the workspaces for a specific user.
Example: In this example, the workspaces for the a specific user will be displayed, then workspaces for all users will be displayed.
# List workspaces by user id
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/workspaces/list"
data = {
"user_id":firstUserKeycloak
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
{'workspaces': [{'id': 1,
'name': 'john.hummel@wallaroo.ai - Default Workspace',
'created_at': '2023-03-01T20:56:22.658436+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [],
'pipelines': []},
{'id': 4,
'name': 'anomalyexampletest3',
'created_at': '2023-03-01T20:56:32.632146+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [1],
'pipelines': [1]},
{'id': 5,
'name': 'ccfraudcomparisondemo',
'created_at': '2023-03-01T21:02:40.955593+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [2, 3, 4],
'pipelines': [3]},
{'id': 6,
'name': 'rlhxccfraudworkspace',
'created_at': '2023-03-01T21:30:28.848609+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [5],
'pipelines': [5]},
{'id': 7,
'name': 'mlflowstatsmodelworkspace',
'created_at': '2023-03-02T18:06:42.074341+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [6, 7],
'pipelines': [8]},
{'id': 8,
'name': 'mobilenetworkspace',
'created_at': '2023-03-02T18:24:27.304478+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [8, 9],
'pipelines': [10]},
{'id': 9,
'name': 'mobilenetworkspacetest',
'created_at': '2023-03-02T19:21:36.309503+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [10, 12],
'pipelines': [13]},
{'id': 10,
'name': 'resnetworkspace',
'created_at': '2023-03-02T19:22:28.371499+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [11],
'pipelines': [14]},
{'id': 11,
'name': 'resnetworkspacetest',
'created_at': '2023-03-02T19:35:30.236438+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [13],
'pipelines': [18]},
{'id': 12,
'name': 'shadowimageworkspacetest',
'created_at': '2023-03-02T19:37:23.348346+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [14, 15],
'pipelines': [20]}]}
# List workspaces
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/workspaces/list"
data = {
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
{'workspaces': [{'id': 1,
'name': 'john.hummel@wallaroo.ai - Default Workspace',
'created_at': '2023-03-01T20:56:22.658436+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [],
'pipelines': []},
{'id': 4,
'name': 'anomalyexampletest3',
'created_at': '2023-03-01T20:56:32.632146+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [1],
'pipelines': [1]},
{'id': 5,
'name': 'ccfraudcomparisondemo',
'created_at': '2023-03-01T21:02:40.955593+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [2, 3, 4],
'pipelines': [3]},
{'id': 6,
'name': 'rlhxccfraudworkspace',
'created_at': '2023-03-01T21:30:28.848609+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [5],
'pipelines': [5]},
{'id': 7,
'name': 'mlflowstatsmodelworkspace',
'created_at': '2023-03-02T18:06:42.074341+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [6, 7],
'pipelines': [8]},
{'id': 8,
'name': 'mobilenetworkspace',
'created_at': '2023-03-02T18:24:27.304478+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [8, 9],
'pipelines': [10]},
{'id': 9,
'name': 'mobilenetworkspacetest',
'created_at': '2023-03-02T19:21:36.309503+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [10, 12],
'pipelines': [13]},
{'id': 10,
'name': 'resnetworkspace',
'created_at': '2023-03-02T19:22:28.371499+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [11],
'pipelines': [14]},
{'id': 11,
'name': 'resnetworkspacetest',
'created_at': '2023-03-02T19:35:30.236438+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [13],
'pipelines': [18]},
{'id': 12,
'name': 'shadowimageworkspacetest',
'created_at': '2023-03-02T19:37:23.348346+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [14, 15],
'pipelines': [20]}]}
A new workspace will be created in the Wallaroo instance. Upon creating, the workspace owner will be assigned as the user making the MLOps API request.
Example: In this example, a workspace with the name testapiworkspace
will be created, and the newly created workspace’s workspace_id
saved as the variable exampleWorkspaceId
for use in other code examples. After the request is complete, the List Workspaces command will be issued to demonstrate the new workspace has been created.
# Create workspace
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/workspaces/create"
exampleWorkspaceName = "testapiworkspace"
data = {
"workspace_name": exampleWorkspaceName
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
# Stored for future examples
exampleWorkspaceId = response['workspace_id']
response
{'workspace_id': 13}
# List workspaces
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/workspaces/list"
data = {
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
{'workspaces': [{'id': 1,
'name': 'john.hummel@wallaroo.ai - Default Workspace',
'created_at': '2023-03-01T20:56:22.658436+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [],
'pipelines': []},
{'id': 4,
'name': 'anomalyexampletest3',
'created_at': '2023-03-01T20:56:32.632146+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [1],
'pipelines': [1]},
{'id': 5,
'name': 'ccfraudcomparisondemo',
'created_at': '2023-03-01T21:02:40.955593+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [2, 3, 4],
'pipelines': [3]},
{'id': 6,
'name': 'rlhxccfraudworkspace',
'created_at': '2023-03-01T21:30:28.848609+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [5],
'pipelines': [5]},
{'id': 7,
'name': 'mlflowstatsmodelworkspace',
'created_at': '2023-03-02T18:06:42.074341+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [6, 7],
'pipelines': [8]},
{'id': 8,
'name': 'mobilenetworkspace',
'created_at': '2023-03-02T18:24:27.304478+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [8, 9],
'pipelines': [10]},
{'id': 9,
'name': 'mobilenetworkspacetest',
'created_at': '2023-03-02T19:21:36.309503+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [10, 12],
'pipelines': [13]},
{'id': 10,
'name': 'resnetworkspace',
'created_at': '2023-03-02T19:22:28.371499+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [11],
'pipelines': [14]},
{'id': 11,
'name': 'resnetworkspacetest',
'created_at': '2023-03-02T19:35:30.236438+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [13],
'pipelines': [18]},
{'id': 12,
'name': 'shadowimageworkspacetest',
'created_at': '2023-03-02T19:37:23.348346+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [14, 15],
'pipelines': [20]},
{'id': 13,
'name': 'testapiworkspace',
'created_at': '2023-03-02T19:44:20.279346+00:00',
'created_by': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'archived': False,
'models': [],
'pipelines': []}]}
Existing users of the Wallaroo instance can be added to an existing workspace.
Example: The following example adds the user created in Invite Users request to the workspace created in the Create Workspace request.
# Add existing user to existing workspace
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/workspaces/add_user"
data = {
"email":newUser,
"workspace_id": exampleWorkspaceId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
Lists the users who are either owners or collaborators of a workspace.
Example: The following example will list all users part of the workspace created in the Create Workspace request.
# List users in a workspace
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/workspaces/list_users"
data = {
"workspace_id": exampleWorkspaceId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
{'users': [{'user_id': 'ca7d7043-8e94-42d5-9f3a-8f55c2e42814',
'user_type': 'OWNER'}]}
Removes the user from the given workspace. In this request, either the user’s Keycloak ID is required OR the user’s email address is required.
email
is not provided, then this parameter is REQUIRED.user_id
is not provided, then this parameter is REQUIRED.Example: The following example will remove the newUser
from workspace created in the Create Workspace request. Then the users for that workspace will be listed to verify newUser
has been removed.
# Remove existing user from an existing workspace
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/workspaces/remove_user"
data = {
"email":newUser,
"workspace_id": exampleWorkspaceId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
# List users in a workspace
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/workspaces/list_users"
data = {
"workspace_id": exampleWorkspaceId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
{'users': [{'user_id': '5abe33ef-90d2-49bd-8f6a-21ef20c383e8',
'user_type': 'OWNER'}]}
Uploads a ML Model to a Wallaroo workspace via POST with Content-Type: multipart/form-data
.
public
or private
.Example: This example will upload the sample file ccfraud.onnx
to the workspace created in the Create Workspace step as apitestmodel
. The model name will be saved as exampleModelName
for use in other examples. The id of the uploaded model will be saved as exampleModelId
for use in later examples.
# upload model - uses multiform data through a Python `request`
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/models/upload"
exampleModelName = "apitestmodel"
data = {
"name":exampleModelName,
"visibility":"public",
"workspace_id": exampleWorkspaceId
}
files = {
"file": ('ccfraud.onnx', open('./models/ccfraud.onnx','rb'))
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data, files)
response
{'insert_models': {'returning': [{'models': [{'id': 16}]}]}}
exampleModelId=response['insert_models']['returning'][0]['models'][0]['id']
exampleModelId
16
Streams a potentially large ML Model to a Wallaroo workspace via POST with Content-Type: multipart/form-data
.
public
or private
.Example: This example will upload the sample file ccfraud.onnx
to the workspace created in the Create Workspace step as apitestmodel
.
# stream upload model - next test is adding arbitrary chunks to the stream
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/models/upload_stream"
exampleModelName = "apitestmodelstream"
filename = 'streamfile.onnx'
data = {
"name":exampleModelName,
"filename": 'streamfile.onnx',
"visibility":"public",
"workspace_id": exampleWorkspaceId
}
contentType='application/octet-stream'
file = open('./models/ccfraud.onnx','rb')
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data=None, files=file, contentType='application/octet-stream', params=data)
response
{'insert_models': {'returning': [{'models': [{'id': 17}]}]}}
Returns a list of models added to a specific workspace.
Example: Display the models for the workspace used in the Upload Model to Workspace step. The model id and model name will be saved as exampleModelId
and exampleModelName
variables for other examples.
# List models in a workspace
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/models/list"
data = {
"workspace_id": exampleWorkspaceId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
{'models': [{'id': 17,
'name': 'apitestmodelstream',
'owner_id': '""',
'created_at': '2023-03-02T19:44:56.549555+00:00',
'updated_at': '2023-03-02T19:44:56.549555+00:00'},
{'id': 16,
'name': 'apitestmodel',
'owner_id': '""',
'created_at': '2023-03-02T19:44:53.173913+00:00',
'updated_at': '2023-03-02T19:44:53.173913+00:00'}]}
exampleModelId = response['models'][0]['id']
exampleModelName = response['models'][0]['name']
Returns the model details by the specific model id.
Example: Retrieve the details for the model uploaded in the Upload Model to Workspace step.
# Get model details by id
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/models/get_by_id"
data = {
"id": exampleModelId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
{'id': 17,
'owner_id': '""',
'workspace_id': 13,
'name': 'apitestmodelstream',
'updated_at': '2023-03-02T19:44:56.549555+00:00',
'created_at': '2023-03-02T19:44:56.549555+00:00',
'model_config': None}
Retrieves all versions of a model based on either the name of the model or the model_pk_id
.
sha
hash of the model version.Example: Retrieve the versions for a previously uploaded model. The variables exampleModelVersion
and exampleModelSha
will store the model’s version and SHA values for use in other examples.
# List models in a workspace
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/models/list_versions"
data = {
"model_id": exampleModelName,
"models_pk_id": exampleModelId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
[{'sha': 'bc85ce596945f876256f41515c7501c399fd97ebcb9ab3dd41bf03f8937b4507',
'models_pk_id': 17,
'model_version': '0396de99-0a55-4880-9f53-8fdcd1b3357a',
'owner_id': '""',
'model_id': 'apitestmodelstream',
'id': 17,
'file_name': 'streamfile.onnx',
'image_path': None}]
# Stored for future examples
exampleModelVersion = response[0]['model_version']
exampleModelSha = response[0]['sha']
Returns the model’s configuration details.
Example: Submit the model id for the model uploaded in the Upload Model to Workspace step to retrieve configuration details.
# Get model config by id
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/models/get_config_by_id"
data = {
"model_id": exampleModelId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
{'model_config': None}
Returns details regarding a single model, including versions.
Returns the model’s configuration details.
Example: Submit the model id for the model uploaded in the Upload Model to Workspace step to retrieve configuration details.
# Get model config by id
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/models/get"
data = {
"id": exampleModelId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
{'id': 17,
'name': 'apitestmodelstream',
'owner_id': '""',
'created_at': '2023-03-02T19:44:56.549555+00:00',
'updated_at': '2023-03-02T19:44:56.549555+00:00',
'models': [{'sha': 'bc85ce596945f876256f41515c7501c399fd97ebcb9ab3dd41bf03f8937b4507',
'models_pk_id': 17,
'model_version': '0396de99-0a55-4880-9f53-8fdcd1b3357a',
'owner_id': '""',
'model_id': 'apitestmodelstream',
'id': 17,
'file_name': 'streamfile.onnx',
'image_path': None}]}
Pipelines can be managed through the Wallaroo API. Pipelines are the vehicle used for deploying, serving, and monitoring ML models. For more information, see the Wallaroo Glossary.
Creates a new pipeline in the specified workspace.
{}
for none.Example: Two pipelines are created in the workspace created in the step Create Workspace. One will be an empty pipeline without any models, the other will be created using the uploaded models in the Upload Model to Workspace step and no configuration details. The pipeline id, variant id, and variant version of each pipeline will be stored for later examples.
# Create pipeline in a workspace
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/pipelines/create"
exampleEmptyPipelineName="emptypipeline"
data = {
"pipeline_id": exampleEmptyPipelineName,
"workspace_id": exampleWorkspaceId,
"definition": {}
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
exampleEmptyPipelineId = response['pipeline_pk_id']
exampleEmptyPipelineVariantId=response['pipeline_variant_pk_id']
emptyExamplePipelineVariantVersion=['pipeline_variant_version']
response
{'pipeline_pk_id': 22,
'pipeline_variant_pk_id': 22,
'pipeline_variant_version': 'e4c3a3dc-97ee-4020-88ce-3bf059b772ef'}
# Create pipeline in a workspace with models
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/pipelines/create"
exampleModelPipelineName="pipelinewithmodel"
data = {
"pipeline_id": exampleModelPipelineName,
"workspace_id": exampleWorkspaceId,
"definition": {}
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
exampleModelPipelineId = response['pipeline_pk_id']
exampleModelPipelineVariantId=response['pipeline_variant_pk_id']
emptyModelPipelineVariantVersion=['pipeline_variant_version']
response
{'pipeline_pk_id': 25,
'pipeline_variant_pk_id': 25,
'pipeline_variant_version': '8eaa146e-1bfb-4786-9969-4264877db7d2'}
Deploy a an existing pipeline. Note that for any pipeline that has model steps, they must be included either in model_configs
, model_ids
or models
.
models
are provided as a parameter.
Examples: Both the empty pipeline and pipeline with model created in the step Create Pipeline in a Workspace will be deployed and their deployment information saved for later examples.
# Deploy empty pipeline
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/pipelines/deploy"
exampleEmptyDeployId = "emptydeploy"
data = {
"deploy_id": exampleEmptyDeployId,
"pipeline_version_pk_id": exampleEmptyPipelineVariantId,
"pipeline_id": exampleEmptyPipelineId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
exampleEmptyDeploymentId=response['id']
response
{'id': 14}
# Deploy a pipeline with models
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/pipelines/deploy"
exampleModelDeployId="modeldeploy"
data = {
"deploy_id": exampleModelDeployId,
"pipeline_version_pk_id": exampleModelPipelineVariantId,
"models": [
{
"name":exampleModelName,
"version":exampleModelVersion,
"sha":exampleModelSha
}
],
"pipeline_id": exampleModelPipelineId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
exampleModelDeploymentId=response['id']
response
{'id': 17}
Returns the deployment status.
Example: The deployed empty and model pipelines status will be displayed.
# Get empty pipeline deployment
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/status/get_deployment"
data = {
"name": f"{exampleEmptyDeployId}-{exampleEmptyDeploymentId}"
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
{'status': 'Starting',
'details': [],
'engines': [{'ip': None,
'name': 'engine-7c44d857cb-995p7',
'status': 'Pending',
'reason': None,
'details': ['containers with unready status: [engine]',
'containers with unready status: [engine]'],
'pipeline_statuses': None,
'model_statuses': None}],
'engine_lbs': [{'ip': '10.244.12.53',
'name': 'engine-lb-ddd995646-vjz7f',
'status': 'Running',
'reason': None,
'details': []}],
'sidekicks': []}
# Get model pipeline deployment
apiRequest = "/status/get_deployment"
data = {
"name": f"{exampleModelDeployId}-{exampleModelDeploymentId}"
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
{'status': 'Running',
'details': [],
'engines': [{'ip': '10.244.13.27',
'name': 'engine-7df9567698-m7zdx',
'status': 'Running',
'reason': None,
'details': [],
'pipeline_statuses': {'pipelines': [{'id': 'pipelinewithmodel',
'status': 'Running'}]},
'model_statuses': {'models': [{'name': 'apitestmodelstream',
'version': '0396de99-0a55-4880-9f53-8fdcd1b3357a',
'sha': 'bc85ce596945f876256f41515c7501c399fd97ebcb9ab3dd41bf03f8937b4507',
'status': 'Running'}]}}],
'engine_lbs': [{'ip': '10.244.12.55',
'name': 'engine-lb-ddd995646-qk6tj',
'status': 'Running',
'reason': None,
'details': []}],
'sidekicks': []}
The API command /admin/get_pipeline_external_url
retrieves the external inference URL for a specific pipeline in a workspace.
In this example, a list of the workspaces will be retrieved. Based on the setup from the Internal Pipeline Deployment URL Tutorial, the workspace matching urlworkspace
will have it’s workspace id stored and used for the /admin/get_pipeline_external_url
request with the pipeline urlpipeline
.
The External Inference URL will be stored as a variable for the next step.
## Retrieve the pipeline's External Inference URL
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/admin/get_pipeline_external_url"
data = {
"workspace_id": exampleWorkspaceId,
"pipeline_name": exampleModelDeployId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
print(response)
externalUrl = response['url']
externalUrl
{'url': 'https://doc-test.api.example.com/v1/api/pipelines/infer/modeldeploy-15'}
‘https://doc-test.api.example.com/v1/api/pipelines/infer/modeldeploy-15'
The inference can now be performed through the External Inference URL. This URL will accept the same inference data file that is used with the Wallaroo SDK, or with an Internal Inference URL as used in the Internal Pipeline Inference URL Tutorial.
For this example, the externalUrl
retrieved through the Get External Inference URL is used to submit a single inference request.
If the Wallaroo instance has been configured to enable Arrow support, then the file cc_data_1k.df.json
will be used. This is a DataFrame object. If Arrow support has not been enabled, then the inference request is used with the Wallaroo proprietary JSON data file cc_data_1k.json
.
#TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
# if Arrow has been enabled, set this to True. Otherwise, leave as False.
arrowEnabled = True
## Inference through external URL
# retrieve the json data to submit
if arrowEnabled is True:
dataFile = './data/cc_data_1k.df.json'
data = json.load(open('./data/cc_data_1k.df.json','rb'))
contentType="application/json; format=pandas-records"
else:
dataFile = './data/cc_data_1k.json'
data = json.load(open('./data/cc_data_1k.json','rb'))
contentType="application/json"
# set the headers
headers= {
'Authorization': 'Bearer ' + TOKEN,
'Content-Type': contentType
}
# submit the request via POST
response = requests.post(externalUrl, json=data, headers=headers)
# Only the first 300 characters will be displayed for brevity
printResponse = json.dumps(response.json())
print(printResponse[0:300])
[{"time": 1677788050393, "in": {"tensor": [-1.0603297501, 2.3544967095, -3.5638788326, 5.1387348926, -1.2308457019, -0.7687824608, -3.5881228109, 1.8880837663, -3.2789674274, -3.9563254554, 4.0993439118, -5.6539176395, -0.8775733373, -9.131571192, -0.6093537873, -3.7480276773, -5.0309125017, -0.8748
Undeploys a deployed pipeline.
Example: Both the empty pipeline and pipeline with models deployed in the step Deploy a Pipeline will be undeployed.
# Undeploy an empty pipeline
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/pipelines/undeploy"
data = {
"pipeline_id": exampleEmptyPipelineId,
"deployment_id":exampleEmptyDeploymentId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
# Undeploy pipeline with models
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/pipelines/undeploy"
data = {
"pipeline_id": exampleModelPipelineId,
"deployment_id":exampleModelDeploymentId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
Copies an existing pipeline into a new one in the same workspace. A new engine configuration can be set for the copied pipeline.
Example: The pipeline with models created in the step Create Pipeline in a Workspace will be copied into a new one.
# Copy a pipeline
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/pipelines/copy"
exampleCopiedPipelineName="copiedmodelpipeline"
data = {
"name": exampleCopiedPipelineName,
"workspace_id": exampleWorkspaceId,
"source_pipeline": exampleModelPipelineId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
{'pipeline_pk_id': 26,
'pipeline_variant_pk_id': 26,
'pipeline_version': None,
'deployment': None}
Lists the enablement features for the Wallaroo instance.
{}
# List enablement features
TOKEN=get_jwt_token(TOKENURL, CLIENT, SECRET, USERNAME, PASSWORD)
apiRequest = "/features/list"
data = {
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
{'features': {'plateau': 'true'},
'name': 'Wallaroo Dev',
'is_auth_enabled': True}
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.
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 more information on retrieving this information, see the Wallaroo Developer Guides.
# Create assay
apiRequest = "/assays/create"
exampleAssayName = "api_assay_test2"
## Now get all of the assays for the pipeline in workspace 4 `housepricedrift`
exampleAssayPipelineId = 4
exampleAssayPipelineName = "housepricepipe"
exampleAssayModelName = "housepricemodel"
exampleAssayWorkspaceId = 4
# iopath can be input 00 or output 0 0
data = {
'name': exampleAssayName,
'pipeline_id': exampleAssayPipelineId,
'pipeline_name': exampleAssayPipelineName,
'active': True,
'status': 'active',
'iopath': "input 0 0",
'baseline': {
'Fixed': {
'pipeline': exampleAssayPipelineName,
'model': 'houseprice-model-yns',
'start_at': '2022-01-01T00:00:00-05:00',
'end_at': '2022-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 = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
example_assay_id = response['assay_id']
response
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.
## First list all of the workspaces and the list of pipelines
# List workspaces
apiRequest = "/workspaces/list"
data = {
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
# Get assays
apiRequest = "/assays/list"
data = {
"pipeline_id": exampleAssayPipelineId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
Activates or deactivates an existing assay.
Example: Assay 8 “House Output Assay” will be deactivated then activated.
# Deactivate assay
apiRequest = "/assays/set_active"
data = {
'id': example_assay_id,
'active': False
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
# Activate assay
apiRequest = "/assays/set_active"
data = {
'id': example_assay_id,
'active': True
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
Creates an interactive assay baseline.
Example: An interactive assay baseline will be set for the assay “Test Assay” on Pipeline 4.
# Run interactive baseline
apiRequest = "/assays/run_interactive_baseline"
exampleAssayPipelineId = 4
exampleAssayPipelineName = "housepricepipe"
exampleAssayModelName = "housepricemodel"
exampleAssayWorkspaceId = 4
exampleAssayId = 3
exampleAssayName = "example assay"
data = {
'id': exampleAssayId,
'name': exampleAssayName,
'pipeline_id': exampleAssayPipelineId,
'pipeline_name': exampleAssayPipelineName,
'active': True,
'status': 'active',
'iopath': "input 0 0",
'baseline': {
'Fixed': {
'pipeline': exampleAssayPipelineName,
'model': exampleAssayModelName,
'start_at': '2022-01-01T00:00:00-05:00',
'end_at': '2022-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 = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
Retrieve an assay baseline.
Example: 3 assay baselines for Workspace 6 and pipeline houseprice-pipe-yns
will be retrieved.
# Get Assay Baseline
apiRequest = "/assays/get_baseline"
data = {
'workspace_id': exampleAssayWorkspaceId,
'pipeline_name': exampleAssayPipelineName,
'limit': 3
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
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
apiRequest = "/assays/run_interactive"
data = {
'id': exampleAssayId,
'name': exampleAssayName,
'pipeline_id': exampleAssayPipelineId,
'pipeline_name': exampleAssayPipelineName,
'active': True,
'status': 'active',
'iopath': "input 0 0",
'baseline': {
'Fixed': {
'pipeline': exampleAssayPipelineName,
'model': exampleAssayModelName,
'start_at': '2022-01-01T00:00:00-05:00',
'end_at': '2022-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 = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response[0]
print(len(response))
Retrieve the results for an assay.
Example: Results for Assay 3 “example assay” will be retrieved for January 2 to January 3. For the sake of time, only the first record will be displayed.
# Get Assay Results
apiRequest = "/assays/get_results"
data = {
'assay_id': exampleAssayId,
'pipeline_id': exampleAssayPipelineId
}
response = get_wallaroo_response(APIURL, apiRequest, TOKEN, data)
response
How to use the Wallaroo API for User Management
How to use the Wallaroo API for Workspace Management
How to use the Wallaroo API for Model Management
How to use the Wallaroo API for Pipeline Management
How to use the Wallaroo API for Enablement Management
How to use the Wallaroo API for Assays Management