The following tutorial is available on the Wallaroo Github Repository.
This notebook will walk through building Wallaroo pipeline with a a Classification model deployed to detect the likelihood of credit card fraud, then publishing that pipeline to an Open Container Initiative (OCI) Registry where it can be deployed in other Docker and Kubernetes environments.
This demonstration will focus on deployment to the edge. For further examples of using Wallaroo with this computer vision models, see Wallaroo 101.
This demonstration performs the following:
helm
for Wallaroo Inference server deployments.The first step is to import the libraries used in this notebook.
import wallaroo
from wallaroo.object import EntityNotFoundError
import pyarrow as pa
import pandas as pd
import requests
# used to display dataframe information without truncating
from IPython.display import display
pd.set_option('display.max_colwidth', None)
pd.set_option('display.max_columns', None)
The next step is to connect to Wallaroo through the Wallaroo client. The Python library is included in the Wallaroo install and available through the Jupyter Hub interface provided with your Wallaroo environment.
This is accomplished using the wallaroo.Client()
command, which provides a URL to grant the SDK permission to your specific Wallaroo environment. When displayed, enter the URL into a browser and confirm permissions. Store the connection into a variable that can be referenced later.
If logging into the Wallaroo instance through the internal JupyterHub service, use wl = wallaroo.Client()
. For more information on Wallaroo Client settings, see the Client Connection guide.
wl = wallaroo.Client()
We’ll use the SDK below to create our workspace , assign as our current workspace, then display all of the workspaces we have at the moment. We’ll also set up variables for our models and pipelines down the road, so we have one spot to change names to whatever fits your organization’s standards best.
To allow this tutorial to be run by multiple users in the same Wallaroo instance, a random 4 character prefix will be added to the workspace, pipeline, and model. Feel free to set suffix=''
if this is not required.
workspace_name = f'edge-observability-demo'
pipeline_name = 'edge-observability-pipeline'
xgboost_model_name = 'ccfraud-xgboost'
xgboost_model_file_name = './models/xgboost_ccfraud.onnx'
workspace = wl.get_workspace(name=workspace_name, create_if_not_exist=True)
wl.set_current_workspace(workspace)
{'name': 'edge-observability-demojch', 'id': 14, 'archived': False, 'created_by': 'b3deff28-04d0-41b8-a04f-b5cf610d6ce9', 'created_at': '2023-10-31T20:12:45.456363+00:00', 'models': [], 'pipelines': []}
When a model is uploaded to a Wallaroo cluster, it is optimized and packaged to make it ready to run as part of a pipeline. In many times, the Wallaroo Server can natively run a model without any Python overhead. In other cases, such as a Python script, a custom Python environment will be automatically generated. This is comparable to the process of “containerizing” a model by adding a small HTTP server and other wrapping around it.
Our pretrained model is in ONNX format, which is specified in the framework
parameter.
xgboost_edge_demo_model = wl.upload_model(
xgboost_model_name,
xgboost_model_file_name,
framework=wallaroo.framework.Framework.ONNX,
).configure(tensor_fields=["tensor"])
Before deploying an inference engine we need to tell wallaroo what resources it will need.
To do this we will use the wallaroo DeploymentConfigBuilder() and fill in the options listed below to determine what the properties of our inference engine will be.
We will be testing this deployment for an edge scenario, so the resource specifications are kept small – what’s the minimum needed to meet the expected load on the planned hardware.
deploy_config = (wallaroo
.DeploymentConfigBuilder()
.replica_count(1)
.cpus(1)
.memory("900Mi")
.build()
)
We will now deploy our pipeline into the current Kubernetes environment using the specified resource constraints. This is a “simulated edge” deploy in that we try to mimic the edge hardware as closely as possible.
pipeline = wl.build_pipeline(pipeline_name)
display(pipeline)
# clear the pipeline if previously run
pipeline.clear()
pipeline.add_model_step(xgboost_edge_demo_model)
pipeline.deploy(deployment_config = deploy_config)
name | edge-observability-pipeline |
---|---|
created | 2023-10-31 20:12:45.895294+00:00 |
last_updated | 2023-10-31 20:12:45.895294+00:00 |
deployed | (none) |
arch | None |
tags | |
versions | 5d440e01-f2db-440c-a4f9-cd28bb491b6c |
steps | |
published | False |
Waiting for deployment - this will take up to 45s ....... ok
name | edge-observability-pipeline |
---|---|
created | 2023-10-31 20:12:45.895294+00:00 |
last_updated | 2023-10-31 20:12:46.009712+00:00 |
deployed | True |
arch | None |
tags | |
versions | 2b335efd-5593-422c-9ee9-52542b59601a, 5d440e01-f2db-440c-a4f9-cd28bb491b6c |
steps | ccfraud-xgboost |
published | False |
A single image, encoded using the Apache Arrow format, is sent to the deployed pipeline. Arrow is used here because, as a binary protocol, there is far lower network and compute overhead than using JSON. The Wallaroo Server engine accepts both JSON, pandas DataFrame, and Apache Arrow formats.
The sample DataFrames and arrow tables are in the ./data
directory. We’ll use the Apache Arrow table cc_data_10k.arrow
.
Once complete, we’ll display how long the inference request took.
import datetime
import time
deploy_url = pipeline._deployment._url()
headers = wl.auth.auth_header()
headers['Content-Type']='application/vnd.apache.arrow.file'
# headers['Content-Type']='application/json; format=pandas-records'
headers['Accept']='application/json; format=pandas-records'
dataFile = './data/cc_data_1k.arrow'
local_inference_start = datetime.datetime.now()
!curl -X POST {deploy_url} \
-H "Authorization:{headers['Authorization']}" \
-H "Content-Type:{headers['Content-Type']}" \
-H "Accept:{headers['Accept']}" \
--data-binary @{dataFile} > curl_response_xgboost.df.json
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 799k 100 685k 100 114k 39.3M 6733k --:--:-- --:--:-- --:--:-- 45.9M
We will import the inference output, and isolate the metadata partition
to store where the inference results are stored in the pipeline logs.
# display the first 20 results
df_results = pd.read_json('./curl_response_xgboost.df.json', orient="records")
# get just the partition
df_results['partition'] = df_results['metadata'].map(lambda x: x['partition'])
# display(df_results.head(20))
display(df_results.head(20).loc[:, ['time', 'out', 'partition']])
time | out | partition | |
---|---|---|---|
0 | 1698783174953 | {'variable': [1.0094898]} | engine-5d9b58dbd9-v5rvw |
1 | 1698783174953 | {'variable': [1.0094898]} | engine-5d9b58dbd9-v5rvw |
2 | 1698783174953 | {'variable': [1.0094898]} | engine-5d9b58dbd9-v5rvw |
3 | 1698783174953 | {'variable': [1.0094898]} | engine-5d9b58dbd9-v5rvw |
4 | 1698783174953 | {'variable': [-1.9073485999999998e-06]} | engine-5d9b58dbd9-v5rvw |
5 | 1698783174953 | {'variable': [-4.4882298e-05]} | engine-5d9b58dbd9-v5rvw |
6 | 1698783174953 | {'variable': [-9.36985e-05]} | engine-5d9b58dbd9-v5rvw |
7 | 1698783174953 | {'variable': [-8.3208084e-05]} | engine-5d9b58dbd9-v5rvw |
8 | 1698783174953 | {'variable': [-8.332728999999999e-05]} | engine-5d9b58dbd9-v5rvw |
9 | 1698783174953 | {'variable': [0.0004896521599999999]} | engine-5d9b58dbd9-v5rvw |
10 | 1698783174953 | {'variable': [0.0006609559]} | engine-5d9b58dbd9-v5rvw |
11 | 1698783174953 | {'variable': [7.57277e-05]} | engine-5d9b58dbd9-v5rvw |
12 | 1698783174953 | {'variable': [-0.000100553036]} | engine-5d9b58dbd9-v5rvw |
13 | 1698783174953 | {'variable': [-0.0005198717]} | engine-5d9b58dbd9-v5rvw |
14 | 1698783174953 | {'variable': [-3.695488e-06]} | engine-5d9b58dbd9-v5rvw |
15 | 1698783174953 | {'variable': [-0.00010883808]} | engine-5d9b58dbd9-v5rvw |
16 | 1698783174953 | {'variable': [-0.00017666817]} | engine-5d9b58dbd9-v5rvw |
17 | 1698783174953 | {'variable': [-2.8312206e-05]} | engine-5d9b58dbd9-v5rvw |
18 | 1698783174953 | {'variable': [2.1755695e-05]} | engine-5d9b58dbd9-v5rvw |
19 | 1698783174953 | {'variable': [-8.493661999999999e-05]} | engine-5d9b58dbd9-v5rvw |
With our testing complete, we will undeploy the pipeline and return the resources back to the cluster.
pipeline.undeploy()
Waiting for undeployment - this will take up to 45s .................................... ok
name | edge-observability-pipeline |
---|---|
created | 2023-10-31 20:12:45.895294+00:00 |
last_updated | 2023-10-31 20:12:46.009712+00:00 |
deployed | False |
arch | None |
tags | |
versions | 2b335efd-5593-422c-9ee9-52542b59601a, 5d440e01-f2db-440c-a4f9-cd28bb491b6c |
steps | ccfraud-xgboost |
published | False |
It worked! For a demo, we’ll take working once as “tested”. So now that we’ve tested our pipeline, we are ready to publish it for edge deployment.
Publishing it means assembling all of the configuration files and model assets and pushing them to an Open Container Initiative (OCI) repository set in the Wallaroo instance as the Edge Registry service. DevOps engineers then retrieve that image and deploy it through Docker, Kubernetes, or similar deployments.
See Edge Deployment Registry Guide for details on adding an OCI Registry Service to Wallaroo as the Edge Deployment Registry.
This is done through the SDK command wallaroo.pipeline.publish(deployment_config)
which has the following parameters and returns.
The publish
method takes the following parameters. The containerized pipeline will be pushed to the Edge registry service with the model, pipeline configurations, and other artifacts needed to deploy the pipeline.
Parameter | Type | Description |
---|---|---|
deployment_config | wallaroo.deployment_config.DeploymentConfig (Optional) | Sets the pipeline deployment configuration. For example: For more information on pipeline deployment configuration, see the Wallaroo SDK Essentials Guide: Pipeline Deployment Configuration. |
Field | Type | Description |
---|---|---|
id | integer | Numerical Wallaroo id of the published pipeline. |
pipeline version id | integer | Numerical Wallaroo id of the pipeline version published. |
status | string | The status of the pipeline publication. Values include:
|
Engine URL | string | The URL of the published pipeline engine in the edge registry. |
Pipeline URL | string | The URL of the published pipeline in the edge registry. |
Helm Chart URL | string | The URL of the helm chart for the published pipeline in the edge registry. |
Helm Chart Reference | string | The help chart reference. |
Helm Chart Version | string | The version of the Helm Chart of the published pipeline. This is also used as the Docker tag. |
Engine Config | wallaroo.deployment_config.DeploymentConfig | The pipeline configuration included with the published pipeline. |
Created At | DateTime | When the published pipeline was created. |
Updated At | DateTime | When the published pipeline was updated. |
We will now publish the pipeline to our Edge Deployment Registry with the pipeline.publish(deployment_config)
command. deployment_config
is an optional field that specifies the pipeline deployment. This can be overridden by the DevOps engineer during deployment.
pub=pipeline.publish(deploy_config)
display(pub)
Waiting for pipeline publish... It may take up to 600 sec.
Pipeline is Publishing....Published.
ID | 2 |
Pipeline Version | 1a5a21e2-f0e8-4148-9ee2-23c877c0ac90 |
Status | Published |
Engine URL | sample.registry.example.com/uat/engines/proxy/wallaroo/ghcr.io/wallaroolabs/standalone-mini:v2023.4.0-4092 |
Pipeline URL | sample.registry.example.com/uat/pipelines/edge-observability-pipeline:1a5a21e2-f0e8-4148-9ee2-23c877c0ac90 |
Helm Chart URL | oci://sample.registry.example.com/uat/charts/edge-observability-pipeline |
Helm Chart Reference | sample.registry.example.com/uat/charts@sha256:8bf628174b5ff87d913590d34a4c3d5eaa846b8b2a52bcf6a76295cd588cb6e8 |
Helm Chart Version | 0.0.1-1a5a21e2-f0e8-4148-9ee2-23c877c0ac90 |
Engine Config | {'engine': {'resources': {'limits': {'cpu': 1.0, 'memory': '512Mi'}, 'requests': {'cpu': 1.0, 'memory': '512Mi'}}}, 'engineAux': {'images': {}}, 'enginelb': {'resources': {'limits': {'cpu': 1.0, 'memory': '512Mi'}, 'requests': {'cpu': 1.0, 'memory': '512Mi'}}}} |
User Images | [] |
Created By | john.hummel@wallaroo.ai |
Created At | 2023-10-31 20:13:32.751657+00:00 |
Updated At | 2023-10-31 20:13:32.751657+00:00 |
Docker Run Variables | {} |
The method wallaroo.client.list_pipelines()
shows a list of all pipelines in the Wallaroo instance, and includes the published
field that indicates whether the pipeline was published to the registry (True
), or has not yet been published (False
).
wl.list_pipelines()
name | created | last_updated | deployed | arch | tags | versions | steps | published |
---|---|---|---|---|---|---|---|---|
edge-observability-pipeline | 2023-31-Oct 20:12:45 | 2023-31-Oct 20:13:32 | False | None | 1a5a21e2-f0e8-4148-9ee2-23c877c0ac90, 2b335efd-5593-422c-9ee9-52542b59601a, 5d440e01-f2db-440c-a4f9-cd28bb491b6c | ccfraud-xgboost | True | |
housepricesagapipeline | 2023-31-Oct 20:04:58 | 2023-31-Oct 20:13:02 | True | None | 0056edf3-730f-452d-a6ed-2dfa47ff5567, 8bc714ea-8257-4512-a102-402baf3143b3, 76006480-b145-4d6a-9e95-9b2e7a4f8d8e | housepricesagacontrol | True |
All publishes created from a pipeline are displayed with the wallaroo.pipeline.publishes
method. The pipeline_version_id
is used to know what version of the pipeline was used in that specific publish. This allows for pipelines to be updated over time, and newer versions to be sent and tracked to the Edge Deployment Registry service.
N/A
A List of the following fields:
Field | Type | Description |
---|---|---|
id | integer | Numerical Wallaroo id of the published pipeline. |
pipeline_version_id | integer | Numerical Wallaroo id of the pipeline version published. |
engine_url | string | The URL of the published pipeline engine in the edge registry. |
pipeline_url | string | The URL of the published pipeline in the edge registry. |
created_by | string | The email address of the user that published the pipeline. |
Created At | DateTime | When the published pipeline was created. |
Updated At | DateTime | When the published pipeline was updated. |
pipeline.publishes()
id | pipeline_version_name | engine_url | pipeline_url | created_by | created_at | updated_at |
---|---|---|---|---|---|---|
2 | 1a5a21e2-f0e8-4148-9ee2-23c877c0ac90 | sample.registry.example.com/uat/engines/proxy/wallaroo/ghcr.io/wallaroolabs/standalone-mini:v2023.4.0-4092 | sample.registry.example.com/uat/pipelines/edge-observability-pipeline:1a5a21e2-f0e8-4148-9ee2-23c877c0ac90 | john.hummel@wallaroo.ai | 2023-31-Oct 20:13:32 | 2023-31-Oct 20:13:32 |
Once a pipeline is deployed to the Edge Registry service, it can be deployed in environments such as Docker, Kubernetes, or similar container running services by a DevOps engineer as a Wallaroo Server.
The following guides will demonstrate publishing a Wallaroo Pipeline as a Wallaroo Server.
Wallaroo Servers can optionally connect to the Wallaroo Ops instance and transmit their inference results. These are added to the pipeline logs for the published pipeline the Wallaroo Server is associated with.
Wallaroo Servers are added with the wallaroo.pipeline_publish.add_edge(name: string)
method. The name
is the unique primary key for each edge added to the pipeline publish and must be unique.
This returns a Publish Edge with the following fields:
Field | Type | Description |
---|---|---|
id | Integer | The integer ID of the pipeline publish. |
created_at | DateTime | The DateTime of the pipeline publish. |
docker_run_variables | String | The Docker variables in UUID format that include the following: The BUNDLE_VERSION , EDGE_NAME , JOIN_TOKEN_ , OPSCENTER_HOST , PIPELINE_URL , and WORKSPACE_ID . |
engine_config | String | The Wallaroo wallaroo.deployment_config.DeploymentConfig for the pipeline. |
pipeline_version_id | Integer | The integer identifier of the pipeline version published. |
status | String | The status of the publish. Published is a successful publish. |
updated_at | DateTime | The DateTime when the pipeline publish was updated. |
user_images | List(String) | User images used in the pipeline publish. |
created_by | String | The UUID of the Wallaroo user that created the pipeline publish. |
engine_url | String | The URL for the published pipeline’s Wallaroo engine in the OCI registry. |
error | String | Any errors logged. |
helm | String | The helm chart, helm reference and helm version. |
pipeline_url | String | The URL for the published pipeline’s container in the OCI registry. |
pipeline_version_name | String | The UUID identifier of the pipeline version published. |
additional_properties | String | Any other identities. |
Two edge publishes will be created so we can demonstrate removing an edge shortly.
edge_01_name = f'edge-ccfraud-observability{random_suffix}'
edge01 = pub.add_edge(edge_01_name)
display(edge01)
edge_02_name = f'edge-ccfraud-observability-02{random_suffix}'
edge02 = pub.add_edge(edge_02_name)
display(edge02)
ID | 2 |
Pipeline Version | 1a5a21e2-f0e8-4148-9ee2-23c877c0ac90 |
Status | Published |
Engine URL | sample.registry.example.com/uat/engines/proxy/wallaroo/ghcr.io/wallaroolabs/standalone-mini:v2023.4.0-4092 |
Pipeline URL | sample.registry.example.com/uat/pipelines/edge-observability-pipeline:1a5a21e2-f0e8-4148-9ee2-23c877c0ac90 |
Helm Chart URL | oci://sample.registry.example.com/uat/charts/edge-observability-pipeline |
Helm Chart Reference | sample.registry.example.com/uat/charts@sha256:8bf628174b5ff87d913590d34a4c3d5eaa846b8b2a52bcf6a76295cd588cb6e8 |
Helm Chart Version | 0.0.1-1a5a21e2-f0e8-4148-9ee2-23c877c0ac90 |
Engine Config | {'engine': {'resources': {'limits': {'cpu': 1.0, 'memory': '512Mi'}, 'requests': {'cpu': 1.0, 'memory': '512Mi'}}}, 'engineAux': {'images': {}}, 'enginelb': {'resources': {'limits': {'cpu': 1.0, 'memory': '512Mi'}, 'requests': {'cpu': 1.0, 'memory': '512Mi'}}}} |
User Images | [] |
Created By | john.hummel@wallaroo.ai |
Created At | 2023-10-31 20:13:32.751657+00:00 |
Updated At | 2023-10-31 20:13:32.751657+00:00 |
Docker Run Variables | {'EDGE_BUNDLE': 'abcde'} |
ID | 2 |
Pipeline Version | 1a5a21e2-f0e8-4148-9ee2-23c877c0ac90 |
Status | Published |
Engine URL | sample.registry.example.com/uat/engines/proxy/wallaroo/ghcr.io/wallaroolabs/standalone-mini:v2023.4.0-4092 |
Pipeline URL | sample.registry.example.com/uat/pipelines/edge-observability-pipeline:1a5a21e2-f0e8-4148-9ee2-23c877c0ac90 |
Helm Chart URL | oci://sample.registry.example.com/uat/charts/edge-observability-pipeline |
Helm Chart Reference | sample.registry.example.com/uat/charts@sha256:8bf628174b5ff87d913590d34a4c3d5eaa846b8b2a52bcf6a76295cd588cb6e8 |
Helm Chart Version | 0.0.1-1a5a21e2-f0e8-4148-9ee2-23c877c0ac90 |
Engine Config | {'engine': {'resources': {'limits': {'cpu': 1.0, 'memory': '512Mi'}, 'requests': {'cpu': 1.0, 'memory': '512Mi'}}}, 'engineAux': {'images': {}}, 'enginelb': {'resources': {'limits': {'cpu': 1.0, 'memory': '512Mi'}, 'requests': {'cpu': 1.0, 'memory': '512Mi'}}}} |
User Images | [] |
Created By | john.hummel@wallaroo.ai |
Created At | 2023-10-31 20:13:32.751657+00:00 |
Updated At | 2023-10-31 20:13:32.751657+00:00 |
Docker Run Variables | {'EDGE_BUNDLE': 'abcde'} |
pipeline.list_edges()
ID | Name | Tags | Pipeline Version | SPIFFE ID |
---|---|---|---|---|
898bb58c-77c2-4164-b6cc-f004dc39e125 | edge-ccfraud-observabilityymgy | [] | 6 | wallaroo.ai/ns/deployments/edge/898bb58c-77c2-4164-b6cc-f004dc39e125 |
1f35731a-f4f6-4cd0-a23a-c4a326b73277 | edge-ccfraud-observability-02ymgy | [] | 6 | wallaroo.ai/ns/deployments/edge/1f35731a-f4f6-4cd0-a23a-c4a326b73277 |
Wallaroo Servers are removed with the wallaroo.pipeline_publish.remove_edge(name: string)
method.
This returns a Publish Edge with the following fields:
Field | Type | Description |
---|---|---|
id | Integer | The integer ID of the pipeline publish. |
created_at | DateTime | The DateTime of the pipeline publish. |
docker_run_variables | String | The Docker variables in UUID format that include the following: The BUNDLE_VERSION , EDGE_NAME , JOIN_TOKEN_ , OPSCENTER_HOST , PIPELINE_URL , and WORKSPACE_ID . |
engine_config | String | The Wallaroo wallaroo.deployment_config.DeploymentConfig for the pipeline. |
pipeline_version_id | Integer | The integer identifier of the pipeline version published. |
status | String | The status of the publish. Published is a successful publish. |
updated_at | DateTime | The DateTime when the pipeline publish was updated. |
user_images | List(String) | User images used in the pipeline publish. |
created_by | String | The UUID of the Wallaroo user that created the pipeline publish. |
engine_url | String | The URL for the published pipeline’s Wallaroo engine in the OCI registry. |
error | String | Any errors logged. |
helm | String | The helm chart, helm reference and helm version. |
pipeline_url | String | The URL for the published pipeline’s container in the OCI registry. |
pipeline_version_name | String | The UUID identifier of the pipeline version published. |
additional_properties | String | Any other identities. |
Two edge publishes will be created so we can demonstrate removing an edge shortly.
sample = pub.remove_edge(edge_02_name)
display(sample)
None
pipeline.list_edges()
ID | Name | Tags | Pipeline Version | SPIFFE ID |
---|---|---|---|---|
898bb58c-77c2-4164-b6cc-f004dc39e125 | edge-ccfraud-observabilityymgy | [] | 6 | wallaroo.ai/ns/deployments/edge/898bb58c-77c2-4164-b6cc-f004dc39e125 |
First, the DevOps engineer must authenticate to the same OCI Registry service used for the Wallaroo Edge Deployment registry.
For more details, check with the documentation on your artifact service. The following are provided for the three major cloud services:
For the deployment, the engine URL is specified with the following environmental variables:
DEBUG
(true|false): Whether to include debug output.OCI_REGISTRY
: The URL of the registry service.CONFIG_CPUS
: The number of CPUs to use.OCI_USERNAME
: The edge registry username.OCI_PASSWORD
: The edge registry password or token.PIPELINE_URL
: The published pipeline URL.Using our sample environment, here’s sample deployment using Docker with a computer vision ML model, the same used in the Wallaroo Use Case Tutorials Computer Vision: Retail tutorials.
docker run -p 8080:8080 \
-e DEBUG=true \
-e OCI_REGISTRY={your registry server} \
-e EDGE_BUNDLE={Your edge bundle['EDGE_BUNDLE']}
-e CONFIG_CPUS=1 \
-e OCI_USERNAME=oauth2accesstoken \
-e OCI_PASSWORD={registry token here} \
-e PIPELINE_URL={your registry server}{Your Wallaroo Server pipeline} \
{your registry server}/{Your Wallaroo Server engine}
For users who prefer to use docker compose
, the following sample compose.yaml
file is used to launch the Wallaroo Edge pipeline. This is the same used in the Wallaroo Use Case Tutorials Computer Vision: Retail tutorials.
services:
engine:
image: {Your Engine URL}
ports:
- 8080:8080
environment:
EDGE_BUNDLE: {Your Edge Bundle['EDGE_BUNDLE']}
PIPELINE_URL: {Your Pipeline URL}
OCI_REGISTRY: {Your Edge Registry URL}
OCI_USERNAME: {Your Registry Username}
OCI_PASSWORD: {Your Token or Password}
CONFIG_CPUS: 1
For example:
services:
engine:
image: sample-registry.com/engine:v2023.3.0-main-3707
ports:
- 8080:8080
environment:
PIPELINE_URL: sample-registry.com/pipelines/edge-cv-retail:bf70eaf7-8c11-4b46-b751-916a43b1a555
OCI_REGISTRY: sample-registry.com
OCI_USERNAME: _json_key_base64
OCI_PASSWORD: abc123
CONFIG_CPUS: 1
The deployment and undeployment is then just a simple docker compose up
and docker compose down
. The following shows an example of deploying the Wallaroo edge pipeline using docker compose
.
docker compose up
[+] Running 1/1
✔ Container cv_data-engine-1 Recreated 0.5s
Attaching to cv_data-engine-1
cv_data-engine-1 | Wallaroo Engine - Standalone mode
cv_data-engine-1 | Login Succeeded
cv_data-engine-1 | Fetching manifest and config for pipeline: sample-registry.com/pipelines/edge-cv-retail:bf70eaf7-8c11-4b46-b751-916a43b1a555
cv_data-engine-1 | Fetching model layers
cv_data-engine-1 | digest: sha256:c6c8869645962e7711132a7e17aced2ac0f60dcdc2c7faa79b2de73847a87984
cv_data-engine-1 | filename: c6c8869645962e7711132a7e17aced2ac0f60dcdc2c7faa79b2de73847a87984
cv_data-engine-1 | name: resnet-50
cv_data-engine-1 | type: model
cv_data-engine-1 | runtime: onnx
cv_data-engine-1 | version: 693e19b5-0dc7-4afb-9922-e3f7feefe66d
cv_data-engine-1 |
cv_data-engine-1 | Fetched
cv_data-engine-1 | Starting engine
cv_data-engine-1 | Looking for preexisting `yaml` files in //modelconfigs
cv_data-engine-1 | Looking for preexisting `yaml` files in //pipelines
Published pipelines can be deployed through the use of helm charts.
Helm deployments take up to two steps - the first step is in retrieving the required values.yaml
and making updates to override.
helm pull oci://{published.helm_chart_url} --version {published.helm_chart_version}
tgz
file and copy the values.yaml
and copy the values used to edit engine allocations, etc. The following are required for the deployment to run:ociRegistry:
registry: {your registry service}
username: {registry username here}
password: {registry token here}
Store this into another file, suc as local-values.yaml
.
wallaroo-edge-pipeline
would be:kubectl create -n wallaroo-edge-pipeline
Deploy the helm
installation with helm install
through one of the following options:
Specify the tgz
file that was downloaded and the local values file. For example:
helm install --namespace {namespace} --values {local values file} {helm install name} {tgz path}
Specify the expended directory from the downloaded tgz
file.
helm install --namespace {namespace} --values {local values file} {helm install name} {helm directory path}
Specify the Helm Pipeline Helm Chart and the Pipeline Helm Version.
helm install --namespace {namespace} --values {local values file} {helm install name} oci://{published.helm_chart_url} --version {published.helm_chart_version}
Once deployed, the DevOps engineer will have to forward the appropriate ports to the svc/engine-svc
service in the specific pipeline. For example, using kubectl port-forward
to the namespace ccfraud
that would be:
kubectl port-forward svc/engine-svc -n ccfraud01 8080 --address 0.0.0.0`
The following code segment generates a docker run
template based on the previously published pipeline. Replace the $REGISTRYURL
, $REGISTRYUSERNAME
and $REGISTRYPASSWORD
with your OCI registry values.
docker_command = f'''
docker run -p 8080:8080 \\
-e DEBUG=true \\
-e OCI_REGISTRY=$REGISTRYURL \\
-e EDGE_BUNDLE={edge01.docker_run_variables['EDGE_BUNDLE']} \\
-e CONFIG_CPUS=1 \\
-e OCI_USERNAME=$REGISTRYUSERNAME \\
-e OCI_PASSWORD=$REGISTRYPASSWORD \\
-e PIPELINE_URL={edge01.pipeline_url} \\
{edge01.engine_url}
'''
print(docker_command)
Once deployed, we can check the pipelines and models available. We’ll use a curl
command, but any HTTP based request will work the same way.
The endpoint /pipelines
returns:
Running
, or Error
if there are any issues.For this example, the deployment is made on a machine called localhost
. Replace this URL with the URL of you edge deployment.
!curl testboy.local:8080/pipelines
The endpoint /models
returns a List of models with the following fields:
!curl testboy.local:8080/models
The inference endpoint takes the following pattern:
/pipelines/{pipeline-name}
: The pipeline-name
is the same as returned from the /pipelines
endpoint as id
.Wallaroo inference endpoint URLs accept the following data inputs through the Content-Type
header:
Content-Type: application/vnd.apache.arrow.file
: For Apache Arrow tables.Content-Type: application/json; format=pandas-records
: For pandas DataFrame in record format.Once deployed, we can perform an inference through the deployment URL.
The endpoint returns Content-Type: application/json; format=pandas-records
by default with the following fields:
null
if the input may be too long for a proper return.!curl -X POST testboy.local:8080/pipelines/edge-observability-pipeline \
-H "Content-Type: application/vnd.apache.arrow.file" \
--data-binary @./data/cc_data_1k.arrow > curl_response_edge.df.json
# display the first 20 results
df_results = pd.read_json('./curl_response_edge.df.json', orient="records")
# display(df_results.head(20))
display(df_results.head(20).loc[:, ['time', 'out', 'metadata']])
pipeline.export_logs(
limit=30000,
directory='partition-edge-observability',
file_prefix='edge-logs',
dataset=['time', 'out', 'metadata']
)
# display the head 20 results
df_logs = pd.read_json('./partition-edge-observability/edge-logs-1.json', orient="records", lines=True)
# get just the partition
# df_results['partition'] = df_results['metadata'].map(lambda x: x['partition'])
# display(df_results.head(20))
display(df_logs.head(20).loc[:, ['time', 'out.variable', 'metadata.partition']])
display(pd.unique(df_logs['metadata.partition']))