Deployments

Sermos provides Managed Deployments as a service through Sermos Cloud. This allows your organization to focus on the core functionality that matters to your business, we handle all of the cloud infrastructure, scaling, availability, etc.

Prerequisites

To deploy your application to Sermos, there are a few prerequisites:

  1. You have created your Deployment environment in your Sermos Cloud console.

  2. An access key has been issued for that Deployment

  3. Your app is a valid Python package with a standard structure (see below)

  4. You have a valid Sermos Yaml (sermos.yaml).

Deployment

You can initiate a Sermos deployment in two ways: programmatically or using the CLI tool.

It is recommended to keep your secret access key in the environment and to set the client package directory in the environment as well. An example .env file would contain:

SERMOS_ACCESS_KEY=YBPiRczbyatDNVCz.zxMe8XsZTb2TxVLWTeQQ7Sa1
SERMOS_DEPLOYMENT_ID=ec43g32d-128a-4de6-b51e-8c6a1303ec85

Programmatic Deployment

Invoking a pipeline programmatically (e.g. as part of a build pipeline) can be done similar to below (assumes access key/client package directory are available in the environment per note above).

from sermos.deploy import SermosDeploy

sd = SermosDeploy()
status = sd.invoke_deployment()
print(status)

CLI Deployment

For a cli-based deployment, there is a sermos deploy command installed as part of the sermos package. The example below uses a utility [Honcho](https://pypi.org/project/honcho/) to inject the contents of the provided environment file into the environment of the command at runtime. You can accomplish this any other way that works for your setup.

honcho run -e .env sermos deploy

Deployment Status

Assuming your environment is set up per notes in the Deployment section above:

Programmatic Status Checks

from sermos.deploy import SermosDeploy

sd = SermosDeploy()
status = sd.get_deployment_status()
print(status)

CLI Status Checks

honcho run -e .env sermos status

Proper Python Package Structure

Assuming your package is called “my_sermos_client”:

/path/to/codebase/
    my-sermos-client/
        setup.py
        my_sermos_client/
            __init__.py
            sermos.yaml

my_sermos_client/__init__.py has only one requirement, to contain your application’s version assigned as a variable __version__, e.g.:

__version__ = '0.1.0'

Common practice is to use that value in your setup.py file, e.g.

_version_re = re.compile(r'__version__\s+=\s+(.*)')
with open('my_sermos_client/__init__.py', 'rb') as f:
    __version__ = str(ast.literal_eval(_version_re.search(
        f.read().decode('utf-8')).group(1)))

Sermos Deploy

Utilities for deploying applications to Sermos.

Example CLI Usage:

$ honcho run -e .env sermos deploy
$ honcho run -e .env sermos status

Example Programmatic Usage:

from sermos.deploy import SermosDeploy

sd = SermosDeploy(
    os.environ.get("SERMOS_DEPLOYMENT_ID")
    os.environ.get("SERMOS_ACCESS_KEY")
)

# To Invoke
status = sd.invoke_deployment()
print(status)

# To Check Status:
status = sd.get_deployment_status()
print(status)
class sermos.deploy.SermosDeploy(access_key: str | None = None, deployment_id: str | None = None, sermos_yaml_filename: str | None = None, base_url: str | None = None)

Primary Sermos Deployment class for invocation and status updates.

get_deployment_status()

Info on a specific deployment

invoke_deployment()

Invoke a Sermos AI Deployment

validate_deployment(output_file: str | None = None, output_format: str = 'yaml', print_output: bool = False)

Test rendering sermos.yaml and validate.