The following tutorial is available on the Wallaroo Github Repository.
This notebook will walk through building a summarization text pipeline in Wallaroo, deploying it to the local cluster for testing, and then publishing it for edge deployment.
This demonstration will focus on deployment to the edge. The sample model is available at the following URL. This model should be downloaded and placed into the ./models
folder before beginning this demonstration.
model-auto-conversion_hugging-face_complex-pipelines_hf-summarisation-bart-large-samsun.zip (1.4 GB)
This demonstration performs the following:
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
# used to display dataframe information without truncating
from IPython.display import display
pd.set_option('display.max_colwidth', 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-hf-summarization'
pipeline_name = 'edge-hf-summarization'
model_name = 'hf-summarization'
model_file_name = './models/model-auto-conversion_hugging-face_complex-pipelines_hf-summarisation-bart-large-samsun.zip'
workspace = wl.get_workspace(name=workspace_name, create_if_not_exist=True)
wl.set_current_workspace(workspace)
{'name': 'edge-hf-summarization', 'id': 6, 'archived': False, 'created_by': 'cd8fd063-62fb-48dc-9589-1de1b29d96a7', 'created_at': '2023-12-21T17:25:52.172386+00:00', 'models': [{'name': 'hf-summarization', 'versions': 6, 'owner_id': '""', 'last_update_time': datetime.datetime(2023, 12, 21, 18, 23, 12, 532900, tzinfo=tzutc()), 'created_at': datetime.datetime(2023, 12, 21, 17, 26, 52, 956758, tzinfo=tzutc())}], 'pipelines': [{'name': 'edge-hf-summarization', 'create_time': datetime.datetime(2023, 12, 21, 17, 51, 27, 284532, tzinfo=tzutc()), 'definition': '[]'}]}
This is required for non-native runtimes for models deployed to Wallaroo.
You can find more info on the available inputs under TextSummarizationInputs or under the official source code from 🤗 Hugging Face
.
input_schema = pa.schema([
pa.field('inputs', pa.string()),
pa.field('return_text', pa.bool_()),
pa.field('return_tensors', pa.bool_()),
pa.field('clean_up_tokenization_spaces', pa.bool_()),
# pa.field('generate_kwargs', pa.map_(pa.string(), pa.null())), # dictionaries are not currently supported by the engine
])
output_schema = pa.schema([
pa.field('summary_text', pa.string()),
])
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 HuggingFace format, which is specified in the framework
parameter. The input and output schemas are included as part of the model upload. For more information, see Wallaroo SDK Essentials Guide: Model Uploads and Registrations: Hugging Face.
model = wl.upload_model(model_name,
model_file_name,
framework=wallaroo.framework.Framework.HUGGING_FACE_SUMMARIZATION,
input_schema=input_schema,
output_schema=output_schema
)
model
Waiting for model loading - this will take up to 10.0min.
Model is pending loading to a container runtime.
Model is attempting loading to a container runtime..............................................successful
Ready
Name | hf-summarization |
Version | add06bd2-054e-4562-b25e-ee692c6e472c |
File Name | model-auto-conversion_hugging-face_complex-pipelines_hf-summarisation-bart-large-samsun.zip |
SHA | ee71d066a83708e7ca4a3c07caf33fdc528bb000039b6ca2ef77fa2428dc6268 |
Status | ready |
Image Path | proxy.replicated.com/proxy/wallaroo/ghcr.io/wallaroolabs/mac-deploy:v2024.1.0-main-4317 |
Architecture | None |
Updated At | 2023-21-Dec 17:50:41 |
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.
deployment_config = wallaroo.DeploymentConfigBuilder() \
.cpus(0.25).memory('1Gi') \
.sidekick_cpus(model, 4) \
.sidekick_memory(model, "8Gi") \
.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)
pipeline.clear()
pipeline.add_model_step(model)
pipeline.deploy(deployment_config=deployment_config)
name | edge-hf-summarization |
---|---|
created | 2023-12-21 17:51:27.284532+00:00 |
last_updated | 2023-12-21 17:51:27.938345+00:00 |
deployed | True |
arch | None |
tags | |
versions | d86600fa-a49b-4a4c-9278-ccbed1ce0f06, ce2c843f-f0f8-4633-bb18-021d404acbae |
steps | hf-summarization |
published | False |
pipeline = wl.build_pipeline(pipeline_name)
pipeline.status()
{'status': 'Error',
'details': [],
'engines': [{'ip': '10.244.3.237',
'name': 'engine-85bbd44c87-b4czr',
'status': 'Running',
'reason': None,
'details': [],
'pipeline_statuses': {'pipelines': [{'id': 'edge-hf-summarization',
'status': 'Running'}]},
'model_statuses': {'models': [{'name': 'hf-summarization',
'version': 'add06bd2-054e-4562-b25e-ee692c6e472c',
'sha': 'ee71d066a83708e7ca4a3c07caf33fdc528bb000039b6ca2ef77fa2428dc6268',
'status': 'Running'}]}}],
'engine_lbs': [{'ip': '10.244.4.232',
'name': 'engine-lb-584f54c899-4rbh2',
'status': 'Running',
'reason': None,
'details': []}],
'sidekicks': [{'ip': '10.244.3.236',
'name': 'engine-sidekick-hf-summarization-3-ffb4c795f-xpr86',
'status': 'Failed',
'reason': 'CrashLoopBackOff',
'details': ['containers with unready status: [engine-sidekick-hf-summarization-3]',
'containers with unready status: [engine-sidekick-hf-summarization-3]'],
'statuses': None}]}
pipeline.undeploy()
pipeline.status()
{'status': 'Running',
'details': [],
'engines': [{'ip': '10.244.3.234',
'name': 'engine-797648499d-wmgxh',
'status': 'Running',
'reason': None,
'details': [],
'pipeline_statuses': {'pipelines': [{'id': 'edge-hf-summarization',
'status': 'Running'}]},
'model_statuses': {'models': [{'name': 'hf-summarization',
'version': 'add06bd2-054e-4562-b25e-ee692c6e472c',
'sha': 'ee71d066a83708e7ca4a3c07caf33fdc528bb000039b6ca2ef77fa2428dc6268',
'status': 'Running'}]}}],
'engine_lbs': [{'ip': '10.244.4.230',
'name': 'engine-lb-584f54c899-4bv9b',
'status': 'Running',
'reason': None,
'details': []}],
'sidekicks': [{'ip': '10.244.3.233',
'name': 'engine-sidekick-hf-summarization-3-654776889f-9bsvg',
'status': 'Running',
'reason': None,
'details': [],
'statuses': '\n'}]}
A single inference using sample input data is prepared below. We’ll run through it to verify the pipeline inference is working.
input_data = {
"inputs": ["LinkedIn (/lɪŋktˈɪn/) is a business and employment-focused social media platform that works through websites and mobile apps. It launched on May 5, 2003. It is now owned by Microsoft. The platform is primarily used for professional networking and career development, and allows jobseekers to post their CVs and employers to post jobs. From 2015 most of the company's revenue came from selling access to information about its members to recruiters and sales professionals. Since December 2016, it has been a wholly owned subsidiary of Microsoft. As of March 2023, LinkedIn has more than 900 million registered members from over 200 countries and territories. LinkedIn allows members (both workers and employers) to create profiles and connect with each other in an online social network which may represent real-world professional relationships. Members can invite anyone (whether an existing member or not) to become a connection. LinkedIn can also be used to organize offline events, join groups, write articles, publish job postings, post photos and videos, and more"], # required
"return_text": [True], # optional: using the defaults, similar to not passing this parameter
"return_tensors": [False], # optional: using the defaults, similar to not passing this parameter
"clean_up_tokenization_spaces": [False], # optional: using the defaults, similar to not passing this parameter
}
dataframe = pd.DataFrame(input_data)
dataframe
inputs | return_text | return_tensors | clean_up_tokenization_spaces | |
---|---|---|---|---|
0 | LinkedIn (/lɪŋktˈɪn/) is a business and employment-focused social media platform that works through websites and mobile apps. It launched on May 5, 2003. It is now owned by Microsoft. The platform is primarily used for professional networking and career development, and allows jobseekers to post their CVs and employers to post jobs. From 2015 most of the company's revenue came from selling access to information about its members to recruiters and sales professionals. Since December 2016, it has been a wholly owned subsidiary of Microsoft. As of March 2023, LinkedIn has more than 900 million registered members from over 200 countries and territories. LinkedIn allows members (both workers and employers) to create profiles and connect with each other in an online social network which may represent real-world professional relationships. Members can invite anyone (whether an existing member or not) to become a connection. LinkedIn can also be used to organize offline events, join groups, write articles, publish job postings, post photos and videos, and more | True | False | False |
deploy_url = pipeline._deployment._url()
headers = wl.auth.auth_header()
headers['Content-Type']='application/json; format=pandas-records'
# headers['Content-Type']='application/json; format=pandas-records'
headers['Accept']='application/json; format=pandas-records'
dataFile = './data/test_summarization.df.json'
!curl -X POST {deploy_url} \
-H "Authorization:{headers['Authorization']}" \
-H "Content-Type:{headers['Content-Type']}" \
-H "Accept:{headers['Accept']}" \
--data-binary @{dataFile}
[{"time":1703181165212,"in":{"clean_up_tokenization_spaces":false,"inputs":"LinkedIn (/lɪŋktˈɪn/) is a business and employment-focused social media platform that works through websites and mobile apps. It launched on May 5, 2003. It is now owned by Microsoft. The platform is primarily used for professional networking and career development, and allows jobseekers to post their CVs and employers to post jobs. From 2015 most of the company's revenue came from selling access to information about its members to recruiters and sales professionals. Since December 2016, it has been a wholly owned subsidiary of Microsoft. As of March 2023, LinkedIn has more than 900 million registered members from over 200 countries and territories. LinkedIn allows members (both workers and employers) to create profiles and connect with each other in an online social network which may represent real-world professional relationships. Members can invite anyone (whether an existing member or not) to become a connection. LinkedIn can also be used to organize offline events, join groups, write articles, publish job postings, post photos and videos, and more","return_tensors":false,"return_text":true},"out":{"summary_text":"LinkedIn is a business and employment-focused social media platform that works through websites and mobile apps. It launched on May 5, 2003. LinkedIn allows members (both workers and employers) to create profiles and connect with each other in an online social network which may represent real-world professional relationships."},"check_failures":[],"metadata":{"last_model":"{\"model_name\":\"hf-summarization\",\"model_sha\":\"ee71d066a83708e7ca4a3c07caf33fdc528bb000039b6ca2ef77fa2428dc6268\"}","pipeline_version":"d86600fa-a49b-4a4c-9278-ccbed1ce0f06","elapsed":[123702,5889708564],"dropped":[],"partition":"engine-797648499d-wmgxh"}}]
Just to clear up resources, we’ll undeploy the pipeline.
pipeline.undeploy()
name | edge-hf-summarization |
---|---|
created | 2023-12-21 17:51:27.284532+00:00 |
last_updated | 2023-12-21 17:51:27.938345+00:00 |
deployed | False |
arch | None |
tags | |
versions | d86600fa-a49b-4a4c-9278-ccbed1ce0f06, ce2c843f-f0f8-4633-bb18-021d404acbae |
steps | hf-summarization |
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.
## This may still show an error status despite but if both containers show running it should be good to go
pipeline.publish(deployment_config)
Waiting for pipeline publish... It may take up to 600 sec.
Pipeline is Publishing......................Published.
ID | 1 |
Pipeline Version | a440e392-73eb-4f5f-a049-1b081cad68b0 |
Status | Published |
Engine URL | ghcr.io/wallaroolabs/doc-samples/engines/proxy/wallaroo/ghcr.io/wallaroolabs/standalone-mini:v2024.1.0-main-4317 |
Pipeline URL | ghcr.io/wallaroolabs/doc-samples/pipelines/edge-hf-summarization:a440e392-73eb-4f5f-a049-1b081cad68b0 |
Helm Chart URL | oci://ghcr.io/wallaroolabs/doc-samples/charts/edge-hf-summarization |
Helm Chart Reference | ghcr.io/wallaroolabs/doc-samples/charts@sha256:0709821c25fc0d9cf22bda3aa98b3e9969bce3e138886dafeb887e19517af773 |
Helm Chart Version | 0.0.1-a440e392-73eb-4f5f-a049-1b081cad68b0 |
Engine Config | {'engine': {'resources': {'arch': 'x86', 'gpu': False, 'limits': {'cpu': 1.0, 'memory': '512Mi'}, 'requests': {'cpu': 1.0, 'memory': '512Mi'}}}, 'engineAux': {'images': {}}, 'enginelb': {'resources': {'arch': 'x86', 'gpu': False, 'limits': {'cpu': 1.0, 'memory': '512Mi'}, 'requests': {'cpu': 1.0, 'memory': '512Mi'}}}} |
User Images | [] |
Created By | john.hummel@wallaroo.ai |
Created At | 2023-12-21 17:53:32.882705+00:00 |
Updated At | 2023-12-21 17:53:32.882705+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 |
---|---|---|---|---|---|---|---|---|
yolo8demonstration | 2023-21-Dec 17:51:41 | 2023-21-Dec 17:51:41 | False | None | b404b106-6387-43f4-b0ef-ebeb1acdcec0, ed9c763f-bbd0-4d93-b359-cafd0f03639f | yolov8n | False | |
edge-hf-summarization | 2023-21-Dec 17:51:27 | 2023-21-Dec 17:53:31 | False | None | a440e392-73eb-4f5f-a049-1b081cad68b0, d86600fa-a49b-4a4c-9278-ccbed1ce0f06, ce2c843f-f0f8-4633-bb18-021d404acbae | hf-summarization | 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 |
---|---|---|---|---|---|---|
1 | a440e392-73eb-4f5f-a049-1b081cad68b0 | ghcr.io/wallaroolabs/doc-samples/engines/proxy/wallaroo/ghcr.io/wallaroolabs/standalone-mini:v2024.1.0-main-4317 | ghcr.io/wallaroolabs/doc-samples/pipelines/edge-hf-summarization:a440e392-73eb-4f5f-a049-1b081cad68b0 | john.hummel@wallaroo.ai | 2023-21-Dec 17:53:32 | 2023-21-Dec 17:53:32 |
pub = pipeline.publishes()[0]
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.
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.
For docker run
commands, the persistent volume for storing session data is stored with -v ./data:/persist
. Updated as required for your deployments.
docker run -p 8080:8080 \
-v ./data:/persist \
-e DEBUG=true -e OCI_REGISTRY={your registry server} \
-e CONFIG_CPUS=4 \
-e OCI_USERNAME=oauth2accesstoken \
-e OCI_PASSWORD={registry token here} \
-e PIPELINE_URL={your registry server}/pipelines/edge-cv-retail:bf70eaf7-8c11-4b46-b751-916a43b1a555 \
{your registry server}/engine:v2023.3.0-main-3707
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. The session and other data is stored with the volumes
entry to add a persistent volume.
services:
engine:
image: {Your Engine URL}
ports:
- 8080:8080
volumes:
- ./data:/persist
environment:
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 compose
template based on the previously published pipeline.
docker_compose = f'''
services:
engine:
image: {pub.engine_url}
ports:
- 8080:8080
volumes:
- ./data:/persist
environment:
PIPELINE_URL: {pub.pipeline_url}
OCI_USERNAME: YOUR USERNAME
OCI_PASSWORD: YOUR PASSWORD OR TOKEN
OCI_REGISTRY: YOUR REGISTRY
CONFIG_CPUS: 4
'''
print(docker_compose)
services:
engine:
image: ghcr.io/wallaroolabs/doc-samples/engines/proxy/wallaroo/ghcr.io/wallaroolabs/standalone-mini:v2024.1.0-main-4317
ports:
- 8080:8080
volumes:
- ./data:/persist
environment:
PIPELINE_URL: ghcr.io/wallaroolabs/doc-samples/pipelines/edge-hf-summarization:a440e392-73eb-4f5f-a049-1b081cad68b0
OCI_USERNAME: YOUR USERNAME
OCI_PASSWORD: YOUR PASSWORD OR TOKEN
OCI_REGISTRY: YOUR REGISTRY
CONFIG_CPUS: 4
docker_deploy = f'''
docker run -p 8080:8080 \\
-v ./data:/persist \
-e DEBUG=true -e OCI_REGISTRY=$REGISTRYURL \\
-e CONFIG_CPUS=4 \\
-e OCI_USERNAME=$REGISTRYUSERNAME \\
-e OCI_PASSWORD=$REGISTRYPASSWORD \\
-e PIPELINE_URL={pub.pipeline_url} \\
{pub.engine_url}
'''
print(docker_deploy)
docker run -p 8080:8080 \
-v ./data:/persist -e DEBUG=true -e OCI_REGISTRY=$REGISTRYURL \
-e CONFIG_CPUS=4 \
-e OCI_USERNAME=$REGISTRYUSERNAME \
-e OCI_PASSWORD=$REGISTRYPASSWORD \
-e PIPELINE_URL=ghcr.io/wallaroolabs/doc-samples/pipelines/edge-hf-summarization:a440e392-73eb-4f5f-a049-1b081cad68b0 \
ghcr.io/wallaroolabs/doc-samples/engines/proxy/wallaroo/ghcr.io/wallaroolabs/standalone-mini:v2024.1.0-main-4317
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.curl localhost:8080/pipelines
{"pipelines":[{"id":"edge-cv-retail","status":"Running"}]}
!curl testboy.local:8080/pipelines
{"pipelines":[{"id":"edge-hf-summarization","status":"Running"}]}
The endpoint /models
returns a List of models with the following fields:
curl localhost:8080/models
{"models":[{"name":"resnet-50","sha":"c6c8869645962e7711132a7e17aced2ac0f60dcdc2c7faa79b2de73847a87984","status":"Running","version":"693e19b5-0dc7-4afb-9922-e3f7feefe66d"}]}
!curl testboy.local:8080/models
{"models":[{"name":"hf-summarization","version":"add06bd2-054e-4562-b25e-ee692c6e472c","sha":"ee71d066a83708e7ca4a3c07caf33fdc528bb000039b6ca2ef77fa2428dc6268","status":"Running"}]}
!curl testboy.local:8080/pipelines/edge-hf-summarization \
-H "Content-Type: application/json; format=pandas-records" \
-d @./data/test_summarization.df.json
[{"time":1703263367472,"in":{"clean_up_tokenization_spaces":false,"inputs":"LinkedIn (/lɪŋktˈɪn/) is a business and employment-focused social media platform that works through websites and mobile apps. It launched on May 5, 2003. It is now owned by Microsoft. The platform is primarily used for professional networking and career development, and allows jobseekers to post their CVs and employers to post jobs. From 2015 most of the company's revenue came from selling access to information about its members to recruiters and sales professionals. Since December 2016, it has been a wholly owned subsidiary of Microsoft. As of March 2023, LinkedIn has more than 900 million registered members from over 200 countries and territories. LinkedIn allows members (both workers and employers) to create profiles and connect with each other in an online social network which may represent real-world professional relationships. Members can invite anyone (whether an existing member or not) to become a connection. LinkedIn can also be used to organize offline events, join groups, write articles, publish job postings, post photos and videos, and more","return_tensors":false,"return_text":true},"out":{"summary_text":"LinkedIn is a business and employment-focused social media platform that works through websites and mobile apps. It launched on May 5, 2003. LinkedIn allows members (both workers and employers) to create profiles and connect with each other in an online social network which may represent real-world professional relationships."},"check_failures":[],"metadata":{"last_model":"{\"model_name\":\"hf-summarization\",\"model_sha\":\"ee71d066a83708e7ca4a3c07caf33fdc528bb000039b6ca2ef77fa2428dc6268\"}","pipeline_version":"","elapsed":[33162,6756169365],"dropped":[],"partition":"00ce08246cd9"}}]
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.import json
import requests
import pandas as pd
# set the content type and accept headers
headers = {
'Content-Type': 'application/json; format=pandas-records'
}
# Submit arrow file
dataFile="./data/test_summarization.df.json"
data = json.load(open(dataFile))
host = 'http://testboy.local:8080'
deployurl = f'{host}/pipelines/edge-hf-summarization'
response = requests.post(
deployurl,
headers=headers,
json=data,
verify=True
)
# display(response)
display(pd.DataFrame(response.json()).loc[0, ['outputs']][0][0]['String']['data'][0])
'LinkedIn is a business and employment-focused social media platform that works through websites and mobile apps. It launched on May 5, 2003. LinkedIn allows members (both workers and employers) to create profiles and connect with each other in an online social network which may represent real-world professional relationships.'