Model Version Management

Here you will find what you need to upload, deploy, fetch, and list out model versions for your organization (org_name), app (app_name), and model (model_name) from Skafos.

skafos.models.upload_version(files, description=None, verbose=True, **kwargs) → dict

Upload a model version, belonging to a specific app and model, to Skafos. All files are automatically zipped together and uploaded to storage. Once successfully uploaded, a dictionary of meta data is returned.

Note

If your model file(s) are not in your working directory, Skafos will zip up and preserve the entire path pointing to the file(s). We recommend placing your file(s) in your current working directory before upload.

Parameters:
  • files (str or list) – Single model file path or list of file paths to zip up and upload to Skafos.
  • description (str) – Optional. Short description for your model version. Must be less than or equal to 255 characters.
  • verbose (boolean) – Control the amount of console print statements you see when working with the SDK. True by default.
  • **kwargs – Keyword arguments identifying the organization, app, and model for upload. See below.
Returns:

A meta data dictionary for the uploaded model version.

Keyword Args:
  • skafos_api_token (str) –
    If not provided, it will be read from the environment as SKAFOS_API_TOKEN.
  • org_name (str) –
    If not provided, it will be read from the environment as SKAFOS_ORG_NAME.
  • app_name (str) –
    If not provided, it will be read from the environment as SKAFOS_APP_NAME.
  • model_name (str) –
    If not provided, it will be read from the environment as SKAFOS_MODEL_NAME.
Usage:
from skafos import models

# Upload a model version to Skafos
models.upload_version(
    skafos_api_token="<your-api-token>",
    org_name="<your-organization>",
    app_name="<your-app>",
    model_name="<your-model>",
    files="my_text_classifier.mlmodel",
    description="My model version upload to Skafos"
)
Raises:
  • InvalidTokenError - if improper API token is used or is missing entirely.
  • InvalidParamError - if improper connection params are passed or missing entirely.
  • UploadFailedError - if there’s a local network or API related issue.
skafos.models.deploy_version(version='latest', environment='dev', **kwargs)

Deploy a model version for a specific app and model to a given application environment (dev or prod).

Note

You can only deploy a model version that has been uploaded to Skafos already.

Parameters:
  • version (str or list) – Version of the model to download or “latest”. If unspecified, defaults to the latest version.
  • environment (str) – Application environment (dev or prod) to deliver the model version. If unspecified, defaults to the dev environment.
  • **kwargs – Keyword arguments identifying the organization, app, and model for deployment. See below.
Returns:

None

Keyword Args:
  • skafos_api_token (str) –
    If not provided, it will be read from the environment as SKAFOS_API_TOKEN.
  • org_name (str) –
    If not provided, it will be read from the environment as SKAFOS_ORG_NAME.
  • app_name (str) –
    If not provided, it will be read from the environment as SKAFOS_APP_NAME.
  • model_name (str) –
    If not provided, it will be read from the environment as SKAFOS_MODEL_NAME.
Usage:
from skafos import models

# Deploy a model version to Skafos
models.deploy_version(
    skafos_api_token="<your-api-token>",
    org_name="<your-organization>",
    app_name="<your-app>",
    model_name="<your-model>",
    version=2,
    environment="prod"
 )
Raises:
  • InvalidTokenError - if improper API token is used or is missing entirely.
  • InvalidParamError - if improper connection params are passed or missing entirely.
  • DeployFailedError - if there’s a local network or API related issue, or if the model version or environment does not exist.
skafos.models.fetch_version(version=None, **kwargs)

Download a model version, belonging to a specific app and model, as a zipped archive to your current working directory as <model_name>.zip.

Parameters:
  • version (int) – Version of the model to download. If unspecified, defaults to the latest version.
  • **kwargs – Keyword arguments identifying the organization, app, and model for download. See below.
Returns:

None

Keyword Args:
  • skafos_api_token (str) –
    If not provided, it will be read from the environment as SKAFOS_API_TOKEN.
  • org_name (str) –
    If not provided, it will be read from the environment as SKAFOS_ORG_NAME.
  • app_name (str) –
    If not provided, it will be read from the environment as SKAFOS_APP_NAME.
  • model_name (str) –
    If not provided, it will be read from the environment as SKAFOS_MODEL_NAME.
Usage:
from skafos import models

# Fetch the latest version of your model
models.fetch_version(
    skafos_api_token="<your-api-token>",
    org_name="<your-organization>",
    app_name="<your-app>",
    model_name="<your-model>"
)

# Fetch a specific version of your model
models.fetch_version(
    skafos_api_token="<your-api-token>",
    org_name="<your-organization>",
    app_name="<your-app>",
    model_name="<your-model>",
    version=2
)
Raises:
  • InvalidTokenError - if improper API token is used or is missing entirely.
  • InvalidParamError - if improper connection parameters are passed or a zip file in your working directory exists with the same name that Skafos is trying to download.
  • DownloadFailedError - if there’s a local network or API related issue, or if no model version exists.
skafos.models.list_versions(**kwargs) → list

Return a list of all saved model versions belonging to an organization, app, and model.

Parameters:

**kwargs – Keyword arguments identifying the organization, app, and model for version retrieval. See below.

Returns:

List of dictionaries containing model versions that have been successfully uploaded to Skafos.

Keyword Args:
  • skafos_api_token (str) –
    If not provided, it will be read from the environment as SKAFOS_API_TOKEN.
  • org_name (str) –
    If not provided, it will be read from the environment as SKAFOS_ORG_NAME.
  • app_name (str) –
    If not provided, it will be read from the environment as SKAFOS_APP_NAME.
  • model_name (str) –
    If not provided, it will be read from the environment as SKAFOS_MODEL_NAME.
Usage:
from skafos import models

# List previously saved model versions
models.list_versions(
    skafos_api_token="<your-api-token>",
    org_name="<your-organization>",
    app_name="<your-app>",
    model_name="<your-model>"
)
Raises:
  • InvalidTokenError - if improper API token is used or is missing entirely.
  • InvalidParamError - if improper connection parameters are passed.
skafos.models.list_environments(**kwargs) → list

Return a list of all available environments belonging to an organization, app, and model. :param **kwargs:

Keyword arguments identifying the organization, app, and model for version retrieval. See below.
Returns:

List of dictionaries containing model environments available for deployment.

Keyword Args:
  • skafos_api_token (str) –
    If not provided, it will be read from the environment as SKAFOS_API_TOKEN.
  • org_name (str) –
    If not provided, it will be read from the environment as SKAFOS_ORG_NAME.
  • app_name (str) –
    If not provided, it will be read from the environment as SKAFOS_APP_NAME.
  • model_name (str) –
    If not provided, it will be read from the environment as SKAFOS_MODEL_NAME.
Usage:
from skafos import models

# List avilable environments for a model
models.list_environments(
    skafos_api_token="<your-api-token>",
    org_name="<your-organization>",
    app_name="<your-app>",
    model_name="<your-model>"
)
Raises:
  • InvalidTokenError - if improper API token is used or is missing entirely.
  • InvalidParamError - if improper connection parameters are passed.