Skip to main content

MCAI SDK to develop Python worker

Project description

Python SDK for Media Cloud AI workers

Based on mcai_worker_sdk, this SDK uses the PyO3 crate to export a compiled module compatible with CPython ABI.

Documentation

Please, check the docs here and here for the SDK with the media feature enabled.

Build

Before using the Python module you should build it as a CPython library. This will require a virtualenv (where the module will be installed) and maturin to compile the module.

virtualenv venv # Create your environment
source venv/bin/activate # Launch it

You can then either build the module in development mode (this will build and install the module in your virtualenv):

maturin develop --features extension-module # Build and install the module

Or build the wheel file and install it manually via pip:

maturin build --features extension-module # Build the wheel file to install the module
pip install path/to/generated/wheel/file

You will now be able to import the module in your Python's scripts by doing:

import mcai_worker_sdk as mcai

Check out maturin's docs for more information on building the module!

Supported version

We intempt to support as many distribution and architecture as we can, however if pip doesn't find any compatible version for your installation it will download the source and try to compile them directly.

This operation supposes that you have at least Rust 1.62.

We currently support the following version of Python implementations:

  • CPython 3.8 : manylinux
  • CPython 3.9 : manylinux, macosx x86_64
  • CPython 3.10 : manylinux, macosx x86_64, macosx arm64
  • CPython 3.11 : manylinux, macosx arm54
  • Pypy 3.8 : manylinux
  • Pypy 3.9 : manylinux

And the following core architectures:

  • x86_64

Test

To run tests you must have json-strong-typing installed:

pip install json-strong-typing

Then launch tests basically:

cargo test
cargo test --features media

Running examples

Build the Python module

In your virtual environment:

maturin develop

Simple worker

RUST_LOG=debug \
SOURCE_ORDERS="examples/message.json" \
PYTHON_WORKER_FILENAME="worker.py" \
SOURCE_PATH="README.md" \
DESTINATION_PATH="README.md.out" \
python worker.py

Media worker

First set the media filename:

export SOURCE_PATH="/folder/filename.ext"

Then run the SDK with these parameters:

RUST_LOG=debug \
SOURCE_ORDERS="examples/message.json" \
PYTHON_WORKER_FILENAME="media_worker.py" \
DESTINATION_PATH="results.json" \
cargo run --features media

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

mcai_worker_sdk_media-2.0.0.tar.gz (53.0 kB view hashes)

Uploaded Source

Built Distributions

mcai_worker_sdk_media-2.0.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl (38.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.28+ x86-64

mcai_worker_sdk_media-2.0.0-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl (38.9 MB view hashes)

Uploaded PyPy manylinux: glibc 2.28+ x86-64

mcai_worker_sdk_media-2.0.0-cp311-cp311-manylinux_2_28_x86_64.whl (38.9 MB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.28+ x86-64

mcai_worker_sdk_media-2.0.0-cp311-cp311-macosx_11_0_arm64.whl (6.8 MB view hashes)

Uploaded CPython 3.11 macOS 11.0+ ARM64

mcai_worker_sdk_media-2.0.0-cp310-cp310-manylinux_2_28_x86_64.whl (38.9 MB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.28+ x86-64

mcai_worker_sdk_media-2.0.0-cp310-cp310-macosx_11_0_arm64.whl (6.8 MB view hashes)

Uploaded CPython 3.10 macOS 11.0+ ARM64

mcai_worker_sdk_media-2.0.0-cp39-cp39-manylinux_2_28_x86_64.whl (38.9 MB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.28+ x86-64

mcai_worker_sdk_media-2.0.0-cp39-cp39-macosx_11_0_arm64.whl (6.8 MB view hashes)

Uploaded CPython 3.9 macOS 11.0+ ARM64

mcai_worker_sdk_media-2.0.0-cp38-cp38-manylinux_2_28_x86_64.whl (38.9 MB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.28+ x86-64

Supported by

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