Deploy via CLI
What you'll learn
- How to Deploy your Async Service using the Python SDK
Upon completing this guide, you will have successfully deployed an Async Service. Your Async Service deployment dashboard will resemble the following:
![](https://files.readme.io/63b1263-Screenshot_2023-09-07_at_11.26.52_AM.png)
Step 1: Clone the code
To get started, clone the following repository by entering the following command in your terminal:
git clone https://github.com/truefoundry/getting-started-examples
After cloning the repository, navigate to the code directory using the following command:
cd deploy-ml-model
The servicefoundry.yaml
script that we'll create in the upcoming steps will be located in this directory.
Step 2: Deploying the Async Service
In this step, we will create a servicefoundry.yaml
file to configure and deploy our Async Service. The servicefoundry.yaml
file will contain the configuration for your Async Service.
Please create the servicefoundry.yaml
file in the same directory where your Async Service code (app.py) is located. After creating the servicefoundry.yaml
file, your directory structure will look like the following:
File Structure
.
├── app.py
├── servicefoundry.yaml
└── requirements.txt
servicefoundry.yaml
servicefoundry.yaml
name: async-service
type: async_service
image:
type: build
build_spec:
type: tfy-python-buildpack
command: gunicorn app:app --workers 1 --worker-class uvicorn.workers.UvicornWorker --bind 127.0.0.1:8000
python_version: '3.9'
requirements_path: requirements.txt
build_context_path: ./
build_source:
type: local
ports:
- host: <YOUR HOST HERE>
port: 8000
worker_config:
input_config:
type: sqs
queue_url: <YOUR_INPUT_QUEUE_URL>
region_name: <YOUR_REGION_NAME>
visibility_timeout: 1
wait_time_seconds: 1
auth:
aws_access_key_id: <YOUR_AWS_ACCESS_KEY_ID>
aws_secret_access_key: <YOUR_AWS_SECRET_ACCESS_KEY>
output_config:
type: sqs
queue_url: <YOUR_OUTPUT_QUEUE_URL>
region_name: <YOUR_REGION_NAME>
auth:
aws_access_key_id: <YOUR_AWS_ACCESS_KEY_ID>
aws_secret_access_key: <YOUR_AWS_SECRET_ACCESS_KEY>
sidecar:
destination_url: <your destination url>
request_timeout: 10
resources:
cpu_limit: 1
cpu_request: 0.5
memory_limit: 200
memory_request: 500
ephemeral_storage_limit: 1000
ephemeral_storage_request: 2000
Picking a value for
host
Providing a host value depends on the base domain urls configured in the cluster settings, you can learn how to find the base domain urls available to you here
For e.g. If your base domain url is
*.truefoundry.your-org.com
then a valid value can befastapi-your-workspace-8000.truefoundry.your-org.com
.Alternatively if you have a non wildcard based domain url e.g.
truefoundry.your-org.com
, then a valid value can betruefoundry.your-org.com/fastapi-your-workspace-8000
To deploy your Async Service using the servicefoundry CLI, execute the following command in your terminal:
servicefoundry deploy --workspace-fqn=YOUR_WORKSPACE_FQN
Run the above command from the same directory containing the
app.py
andrequirements.txt
files.
After executing the command mentioned above, the deployment process will begin.
Please be patient and wait for the deployment process to finish. You can monitor the deployment status, and once it displays "SUCCESS"
, your Async Service will be successfully deployed.
Once the deployment process is complete, you will receive a link to access the dashboard. Look for a message like You can find the application on the dashboard:
in the output.
Click on the provided link to access the deployment dashboard.
Interact with your Async Service
Follow the following guide to learn how to Interact with the Async Service you just deployed:
Interacting with your Async Service
Updated 9 months ago