Deployment
Runtime environment setup
You can reproduce this deployment guide on localhost. Nevertheless this guide is a blueprint for production. All environment variables, package sources, dependencies and other settings are declared with configuration YAML files. This is the preferred approach to production settings with Ray. See Ray Production Guide.
As a consequence, this guide is a lot about managing YAML files. Kodosumi simplifies the management of these configuration files by splitting the configuration into a base and multiple app configurations.
This deployment is based on the company_news
service built in development workflow.
Let’s start with creating a root directory to host our runtime environment, i.e.
mkdir ~/kodosumi cd kodosumi
Create a Python Virtual Environment with
python -m venv .venv # depends on OS setup source .venv/bin/activate
[!NOTE] The location of your system’s Python executable
python
might vary.
Next, install Kodosumi from the Python package index
pip install kodosumi
if instead you prefer to install the latest development trunk run
pip install “kodosumi @ git+https://github.com/masumi-network/kodosumi.git@dev”
Start your Ray cluster with
ray start —head
In the previous examples you did run koco start
which launches the Kodosumi spooler daemon PLUS the Kodosumi admin panel web app and API. In the current example we start the spooler and the panel seperately. We start with the spooler
koco spool
This starts the spooler in the background and as a daemon. You can review daemon status with
koco spool —status
Stop the spooler later with koco spool --stop
.
The spooler automatically creates directory ./data/config
to host Ray serve configuration files as specified with configuration parameter YAML_BASE
. The yaml base defaults to ./data/config/config.yaml
and locates the base relative to the directory where you start koco spool
and koco serve
.
Create file ./data/config/config.yaml
with Ray serve base configuration. The following yaml configuration is a good starting point. For further details read Ray’s documentation about Serve Config Files.
We will deploy the agentic-workflow-example service as a package company_news
.
Create the first app configuration named company_news.yaml
with the following content:
Test and deploy your configuration set with
koco deploy —dry-run —file ./data/config/config.yaml koco deploy —run —file ./data/config/config.yaml
This will apply your base configuration from ./data/config/config.yaml
and adds a key application
with records from ./data/config/company_news.yaml
.
With running Ray, spooler and app we now start the Kodosumi panel and register Ray deployments
koco serve —register http://localhost:8001/-/routes
See Configure Ray Serve Deployments for additional options on your deployment. Be advised to gather some experience with Ray core components before you rollout your services. Understand remote resource requirements and how to limit concurrency to avoid OOM issues
Deployment API
[!NOTE] The deployment API at
/deploy
and/serve
is experimental.
Use kodosumi panel API to change your Ray serve deployments at runtime. The panel API ships with a simple CRUD interfacce to create, read, update and delete deployment configurations including the base configuration with config.yaml
.
The following Python snippets demonstrates API usage with example service kodosumi_examples.prime
.
Let us first stop Ray serve and remove all existing deployments except the base configuration config.yaml
before we deploy the prime
service.
Verify no deployments with GET /deploy
and an existing base configuration with GET /deploy/config
.
This yields the content of the base configuration ./data/config/config.yaml
, for example
If the base configuration does not exist and GET /deploy/config
throws a 404 Not found
exception, then create it with for example
Deploy the prime service with the corresponding Ray serve configuration.
Verify the to-be deployment state of the prime service.
To request Ray serve to enter this state POST /serve
with
Watch the timeout because the response of Ray serve might take a while.