LogoLogo
WebsiteSlack
0.30
0.30
  • Get started
  • Clients
    • Install
    • CLI commands
    • Python API
    • Environments
    • Telemetry
    • Uninstall
  • Workloads
    • Realtime APIs
      • Example
      • Predictor
      • Configuration
      • Models
      • Parallelism
      • Server-side batching
      • Autoscaling
      • Statuses
      • Metrics
      • Multi-model
        • Example
        • Configuration
        • Caching
      • Traffic Splitter
        • Example
        • Configuration
      • Troubleshooting
    • Batch APIs
      • Example
      • Predictor
      • Configuration
      • Jobs
      • Statuses
    • Task APIs
      • Example
      • Definition
      • Configuration
      • Jobs
      • Statuses
    • Dependencies
      • Example
      • Python packages
      • System packages
      • Custom images
    • Observability
      • Logging
      • Metrics
  • Clusters
    • AWS
      • Install
      • Update
      • Auth
      • Security
      • Spot instances
      • Networking
        • Custom domain
        • HTTPS (via API Gateway)
        • VPC peering
      • Setting up kubectl
      • Uninstall
    • GCP
      • Install
      • Credentials
      • Setting up kubectl
      • Uninstall
    • Private Docker registry
Powered by GitBook
On this page
  • Deploy using the Python Client
  • Deploy using the CLI
  1. Workloads
  2. Dependencies

Example

You can deploy an API by providing a project directory. Cortex will save the project directory and make it available during API initialization.

project/
  ├── model.py
  ├── util.py
  ├── predictor.py
  ├── requirements.txt
  └── ...

You can define your Predictor class in a separate python file and import code from your project.

# predictor.py

from model import MyModel

class PythonPredictor:
    def __init__(self, config):
        model = MyModel()

    def predict(payload):
        return model(payload)

Deploy using the Python Client

import cortex

api_spec = {
    "name": "text-generator",
    "kind": "RealtimeAPI",
    "predictor": {
        "type": "python",
        "path": "predictor.py"
    }
}

cx = cortex.client("aws")
cx.create_api(api_spec, project_dir=".")

Deploy using the CLI

# api.yaml

- name: text-generator
  kind: RealtimeAPI
  predictor:
    type: python
    path: predictor.py
cortex deploy api.yaml
PreviousDependenciesNextPython packages

Last updated 4 years ago