Skip to main content

Author, build & deploy Python models for the Motion inference platform

Project description

motion-cli (Python)

Build and deploy Docker images for models on the Motion inference platform.

pip install -e /path/to/cli-py    # gives the `motion` command
export MOTION_API_KEY=motion_live_<your_key>

Quick start

A model is a folder with motion.yml + predict.py:

# predict.py
from motion import BasePredictor, Input, Path

class MyPredictor(BasePredictor):
    def setup(self):
        self.model = load_model(...)

    def predict(self, video: Path = Input(description="Input clip")) -> Path:
        out = "/tmp/out.mp4"
        self.model.run(video, out)
        return Path(out)
# motion.yml
name: lingbot-map
predict: predict.py:MyPredictor
description: Streaming 3D reconstruction

# Where the model appears in GET /api/v1/motion/models
category: reconstruction          # required for catalog listing
inference_model: lingbot-map      # optional; defaults to `name`
input_type: video                 # video | image | text
output_type: mp4

# Used by `motion deploy` to measure CPU/RAM via docker stats
sample: demo_files/input.mp4

build:
  gpu: true
  cuda: "11.8"
  python_version: "3.11"
  system_packages: [ffmpeg]
  python_packages: ["torch>=2.4.0"]

# Optional — overrides auto-profiling
compute:
  cpu: 4
  memory_mib: 16384
  gpu: true

weights:
  - path: weights/model.pt
    url: https://example.com/model.pt
    dest: weights/model.pt

Commands

motion build

Uploads local weights to S3 (via MOTION_API_KEY, no AWS creds on your machine), generates .motion/Dockerfile, and builds motion-<name>:latest.

motion build .                  # build image
motion build . --dry-run        # print Dockerfile only
motion build . --tag myimg:dev  # custom tag

Requires: MOTION_API_KEY when weights: has local files to upload.

Large weights (≥64 MiB) use multipart S3 upload automatically.

motion deploy

Profiles the local image, pushes to ECR, and registers the model in the platform.

motion deploy .
motion deploy . --no-profile              # skip docker stats measurement
motion deploy . --sample tests/clip.mp4   # override profiling input
motion deploy . --profile-timeout 300     # longer profiling window

Flow:

  1. Parse motion.yml (including category, sample, compute)
  2. Profile — run the container locally, poll docker stats, derive cpu_vcpus + memory_mib
    • Skipped if compute: is set in motion.yml (compute_source=declared)
    • Skipped with --no-profile
    • Skipped if no sample file is found
  3. Push image to ECR (backend issues a short-lived docker login token)
  4. RegisterPOST /api/v1/motion/models/register with:
    • model_code = <namespace>/<name> (e.g. saurav/lingbot-map)
    • category_code, inference_model_slug, compute profile, predict params

Requires: MOTION_API_KEY, local image from motion build.

Category codes: list with GET /api/v1/motion/models — e.g. reconstruction, hand-tracking, mesh, 3d-object.

After deploy, submit jobs with:

POST /api/v1/motion/submit   model_name=<namespace>/<name>

Environment

Variable Purpose
MOTION_API_KEY Auth for build (weight upload) and deploy (ECR + register)
MOTION_API_URL Backend base URL (default: Motion App Runner prod)

Image contract

Every built image exposes: GET /health, GET /schema, POST /predict.

Weights declared in motion.yml are fetched from S3 at container startup — not baked into the image.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

motion_intelligence-0.2.0.tar.gz (23.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

motion_intelligence-0.2.0-py3-none-any.whl (25.8 kB view details)

Uploaded Python 3

File details

Details for the file motion_intelligence-0.2.0.tar.gz.

File metadata

  • Download URL: motion_intelligence-0.2.0.tar.gz
  • Upload date:
  • Size: 23.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.8

File hashes

Hashes for motion_intelligence-0.2.0.tar.gz
Algorithm Hash digest
SHA256 1f266844cca6a8fb478146169607bc7a81673553290695a1674c72431ba95f60
MD5 9b2bc252af1a1d43b580f87752c084c8
BLAKE2b-256 de89dd4b0b24c3769b87ea8651e7a903ca4661d5ed0f318d376d3296931483e1

See more details on using hashes here.

File details

Details for the file motion_intelligence-0.2.0-py3-none-any.whl.

File metadata

File hashes

Hashes for motion_intelligence-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 0edda6166d19e90293132f0cbba13e596ab49b645ff7aadf92ca239a3385056c
MD5 bc84918fcbf803a54ecc04a5b9ab38e4
BLAKE2b-256 33368ac639f0794297d1287f74a28dcc3b482904a5f808921920736ab35de01d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page