# Python SDK for Media Cloud AI workers
Based on [mcai_worker_sdk](https://gitlab.com/media-cloud-ai/sdks/rs_mcai_worker_sdk), this SDK uses the [PyO3 crate](https://github.com/PyO3/pyo3) to export a compiled module compatible with CPython ABI.
## Documentation
Please, check the docs [here](https://media-cloud-ai.gitlab.io/sdks/py_mcai_worker_sdk/mcai_worker_sdk/) and [here](https://media-cloud-ai.gitlab.io/sdks/py_mcai_worker_sdk/mcai_worker_sdk_media/) 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](https://github.com/PyO3/maturin) to compile the module.
```bash
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):
```bash
maturin develop --features extension-module # Build and install the module
```
Or build the wheel file and install it manually via `pip`:
```bash
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:
```python
import mcai_worker_sdk as mcai
```
Check out [maturin's docs](https://www.maturin.rs/distribution.html#build-wheels) 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:
- [x] CPython 3.8 : manylinux
- [x] CPython 3.9 : manylinux, macosx x86_64
- [x] CPython 3.10 : manylinux, macosx x86_64, macosx arm64
- [x] CPython 3.11 : manylinux, macosx arm54
- [x] Pypy 3.8 : manylinux
- [x] Pypy 3.9 : manylinux
And the following core architectures:
- [x] x86_64
## Test
To run tests you must have `json-strong-typing` installed:
```bash
pip install json-strong-typing
```
Then launch tests basically:
```bash
cargo test
cargo test --features media
```
### Running examples
#### Build the Python module
In your virtual environment:
```bash
maturin develop
```
#### Simple worker
```bash
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:
```bash
export SOURCE_PATH="/folder/filename.ext"
```
Then run the SDK with these parameters:
```bash
RUST_LOG=debug \
SOURCE_ORDERS="examples/message.json" \
PYTHON_WORKER_FILENAME="media_worker.py" \
DESTINATION_PATH="results.json" \
cargo run --features media
```
Raw data
{
"_id": null,
"home_page": "https://gitlab.com/media-cloud-ai/sdks/py_mcai_worker_sdk",
"name": "mcai-worker-sdk",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": "",
"keywords": "AMQP,micro-service,python",
"author": "Valentin NOEL <valentin.noel@media-io.com>, Marc-Antoine Arnaud <maarnaud@media-io.com>, Thibaud Le Graverend <thibaud.legraverend@luminvent.com>",
"author_email": "Valentin NOEL <valentin.noel@media-io.com>, Marc-Antoine Arnaud <maarnaud@media-io.com>, Thibaud Le Graverend <thibaud.legraverend@luminvent.com>",
"download_url": "https://files.pythonhosted.org/packages/26/6a/236126ce580c984b5e41c2c5fdf17d57166cd480ddacdd33386bcad48825/mcai_worker_sdk-2.0.0.tar.gz",
"platform": null,
"description": "# Python SDK for Media Cloud AI workers\n\nBased on [mcai_worker_sdk](https://gitlab.com/media-cloud-ai/sdks/rs_mcai_worker_sdk), this SDK uses the [PyO3 crate](https://github.com/PyO3/pyo3) to export a compiled module compatible with CPython ABI.\n\n## Documentation\n\nPlease, check the docs [here](https://media-cloud-ai.gitlab.io/sdks/py_mcai_worker_sdk/mcai_worker_sdk/) and [here](https://media-cloud-ai.gitlab.io/sdks/py_mcai_worker_sdk/mcai_worker_sdk_media/) for the SDK with the media feature enabled.\n\n## Build\n\nBefore 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](https://github.com/PyO3/maturin) to compile the module.\n\n```bash\nvirtualenv venv # Create your environment\nsource venv/bin/activate # Launch it\n```\n\nYou can then either build the module in development mode (this will build and install the module in your virtualenv):\n\n```bash\nmaturin develop --features extension-module # Build and install the module\n```\n\nOr build the wheel file and install it manually via `pip`:\n\n```bash\nmaturin build --features extension-module # Build the wheel file to install the module\npip install path/to/generated/wheel/file\n```\n\nYou will now be able to import the module in your Python's scripts by doing:\n\n```python\nimport mcai_worker_sdk as mcai\n```\n\nCheck out [maturin's docs](https://www.maturin.rs/distribution.html#build-wheels) for more information on building the module!\n\n### Supported version\n\nWe 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.\n\nThis operation supposes that you have at least __Rust 1.62__.\n\nWe currently support the following version of Python implementations:\n- [x] CPython 3.8 : manylinux\n- [x] CPython 3.9 : manylinux, macosx x86_64\n- [x] CPython 3.10 : manylinux, macosx x86_64, macosx arm64\n- [x] CPython 3.11 : manylinux, macosx arm54\n- [x] Pypy 3.8 : manylinux\n- [x] Pypy 3.9 : manylinux\n\nAnd the following core architectures:\n- [x] x86_64\n\n\n## Test\n\nTo run tests you must have `json-strong-typing` installed:\n\n```bash\npip install json-strong-typing\n```\n\nThen launch tests basically:\n\n```bash\ncargo test\ncargo test --features media\n```\n\n### Running examples\n\n#### Build the Python module\n\nIn your virtual environment:\n\n```bash\nmaturin develop\n```\n\n#### Simple worker\n\n```bash\nRUST_LOG=debug \\\nSOURCE_ORDERS=\"examples/message.json\" \\\nPYTHON_WORKER_FILENAME=\"worker.py\" \\\nSOURCE_PATH=\"README.md\" \\\nDESTINATION_PATH=\"README.md.out\" \\\npython worker.py\n```\n\n#### Media worker\n\nFirst set the media filename:\n\n```bash\nexport SOURCE_PATH=\"/folder/filename.ext\"\n```\n\nThen run the SDK with these parameters:\n\n```bash\nRUST_LOG=debug \\\nSOURCE_ORDERS=\"examples/message.json\" \\\nPYTHON_WORKER_FILENAME=\"media_worker.py\" \\\nDESTINATION_PATH=\"results.json\" \\\ncargo run --features media\n```\n\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "MCAI SDK to develop Python worker",
"version": "2.0.0",
"project_urls": {
"Documentation": "https://mcai-python-sdk.readthedocs.io/",
"Homepage": "https://gitlab.com/media-cloud-ai/sdks/py_mcai_worker_sdk"
},
"split_keywords": [
"amqp",
"micro-service",
"python"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "660de6a56db3a15ee75b5e4811a09b3849c19952c0dcaf999b1c13fb22660ae1",
"md5": "2806adeb648de9e9e805f7f4280efac5",
"sha256": "14966b0b3edb8941823816ee428d368cc066d30bed231298924279d0965b7f65"
},
"downloads": -1,
"filename": "mcai_worker_sdk-2.0.0-cp310-cp310-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "2806adeb648de9e9e805f7f4280efac5",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.8",
"size": 9719538,
"upload_time": "2023-08-17T10:22:52",
"upload_time_iso_8601": "2023-08-17T10:22:52.889404Z",
"url": "https://files.pythonhosted.org/packages/66/0d/e6a56db3a15ee75b5e4811a09b3849c19952c0dcaf999b1c13fb22660ae1/mcai_worker_sdk-2.0.0-cp310-cp310-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "3292019157f1ce9a1f359c2974953606d52d9bf873515d8d86a3eb17daf0d682",
"md5": "9c2640023eae554d10641530050501df",
"sha256": "18473f5f5b0b4b2ee942c0bf26c8f4bf77ccf41621e74e1da2326c3431566c93"
},
"downloads": -1,
"filename": "mcai_worker_sdk-2.0.0-cp311-cp311-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "9c2640023eae554d10641530050501df",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.8",
"size": 9719538,
"upload_time": "2023-08-17T10:22:56",
"upload_time_iso_8601": "2023-08-17T10:22:56.918376Z",
"url": "https://files.pythonhosted.org/packages/32/92/019157f1ce9a1f359c2974953606d52d9bf873515d8d86a3eb17daf0d682/mcai_worker_sdk-2.0.0-cp311-cp311-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "951f6bfeeb801b051c854e204fd8ff001bd122c01fb64212e153e36a3b521a34",
"md5": "30c22443e58b3004738107ff6260053a",
"sha256": "79a93e38bef2ba9403d57666e603125e873c54d6b732778f8917942fdcbf6c69"
},
"downloads": -1,
"filename": "mcai_worker_sdk-2.0.0-cp38-cp38-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "30c22443e58b3004738107ff6260053a",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 9719191,
"upload_time": "2023-08-17T10:23:01",
"upload_time_iso_8601": "2023-08-17T10:23:01.263471Z",
"url": "https://files.pythonhosted.org/packages/95/1f/6bfeeb801b051c854e204fd8ff001bd122c01fb64212e153e36a3b521a34/mcai_worker_sdk-2.0.0-cp38-cp38-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "0d28d2594dc57667c755b2a08302f4b51d181323ed8a71c94a9c9f3e4ccdb9fb",
"md5": "18b54a79a997eaeaaaff5764cb242de5",
"sha256": "a79384d0e5bf06f5f93ebcd64a6c56ee78b00b8c361d15edecc3b43f05d8004e"
},
"downloads": -1,
"filename": "mcai_worker_sdk-2.0.0-cp39-cp39-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "18b54a79a997eaeaaaff5764cb242de5",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.8",
"size": 9719283,
"upload_time": "2023-08-17T10:23:05",
"upload_time_iso_8601": "2023-08-17T10:23:05.112396Z",
"url": "https://files.pythonhosted.org/packages/0d/28/d2594dc57667c755b2a08302f4b51d181323ed8a71c94a9c9f3e4ccdb9fb/mcai_worker_sdk-2.0.0-cp39-cp39-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "7c42a5e42db34aece70acd978b392264acc943fa6861c6d52366b37e7dd0864c",
"md5": "512d94a4fb4c4a0235be51ddc11e84f9",
"sha256": "2dea52e1b03e7c70f30eaf47e5d48629d7d3a87b8a6fb804bfae86021fb92dbf"
},
"downloads": -1,
"filename": "mcai_worker_sdk-2.0.0-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "512d94a4fb4c4a0235be51ddc11e84f9",
"packagetype": "bdist_wheel",
"python_version": "pp38",
"requires_python": ">=3.8",
"size": 9719628,
"upload_time": "2023-08-17T10:23:08",
"upload_time_iso_8601": "2023-08-17T10:23:08.592081Z",
"url": "https://files.pythonhosted.org/packages/7c/42/a5e42db34aece70acd978b392264acc943fa6861c6d52366b37e7dd0864c/mcai_worker_sdk-2.0.0-pp38-pypy38_pp73-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "f6e876b944d049a64aeef265ee61a31dcac7a32db1b76e0588a6ea94c68c792a",
"md5": "d6f4c6d2a90f040d0facf37b06c497c9",
"sha256": "4527491f689cac1db619cfca4192e0851548b06aa377c024ba49a5a647cfbfd0"
},
"downloads": -1,
"filename": "mcai_worker_sdk-2.0.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "d6f4c6d2a90f040d0facf37b06c497c9",
"packagetype": "bdist_wheel",
"python_version": "pp39",
"requires_python": ">=3.8",
"size": 9719970,
"upload_time": "2023-08-17T10:23:11",
"upload_time_iso_8601": "2023-08-17T10:23:11.632276Z",
"url": "https://files.pythonhosted.org/packages/f6/e8/76b944d049a64aeef265ee61a31dcac7a32db1b76e0588a6ea94c68c792a/mcai_worker_sdk-2.0.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "266a236126ce580c984b5e41c2c5fdf17d57166cd480ddacdd33386bcad48825",
"md5": "b66cfceeca756f8659138cc75294f18f",
"sha256": "03a4321b17b08cc0aa419c63ebcca5e6a1a26ec542388529c4d1c4f7e4c75159"
},
"downloads": -1,
"filename": "mcai_worker_sdk-2.0.0.tar.gz",
"has_sig": false,
"md5_digest": "b66cfceeca756f8659138cc75294f18f",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 52949,
"upload_time": "2023-08-17T10:23:14",
"upload_time_iso_8601": "2023-08-17T10:23:14.544254Z",
"url": "https://files.pythonhosted.org/packages/26/6a/236126ce580c984b5e41c2c5fdf17d57166cd480ddacdd33386bcad48825/mcai_worker_sdk-2.0.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-08-17 10:23:14",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "media-cloud-ai",
"gitlab_project": "sdks",
"lcname": "mcai-worker-sdk"
}