# 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": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"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>, Nicolas Pierre <nico.pierre@icloud.com>",
"author_email": "Valentin NOEL <valentin.noel@media-io.com>, Marc-Antoine Arnaud <maarnaud@media-io.com>, Thibaud Le Graverend <thibaud.legraverend@luminvent.com>, Nicolas Pierre <nico.pierre@icloud.com>",
"download_url": "https://files.pythonhosted.org/packages/30/b4/627fc77d076420ca0dce973c0682b4f323e7e4a313476bf6624170854ee1/mcai_worker_sdk-2.1.1.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.1.1",
"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": "e44f15c0763f77f0f7dbeaf9898591168244596e49f16229942ace3a8b389a14",
"md5": "7078332b56d2c8893b0f329b01f5c1bc",
"sha256": "06f1837012d22bf3ddb465c9b97b5633c6ad2af0f3687cc5cc23840000d0ac10"
},
"downloads": -1,
"filename": "mcai_worker_sdk-2.1.1-cp310-cp310-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "7078332b56d2c8893b0f329b01f5c1bc",
"packagetype": "bdist_wheel",
"python_version": "cp310",
"requires_python": ">=3.8",
"size": 8972663,
"upload_time": "2024-12-03T11:56:15",
"upload_time_iso_8601": "2024-12-03T11:56:15.649148Z",
"url": "https://files.pythonhosted.org/packages/e4/4f/15c0763f77f0f7dbeaf9898591168244596e49f16229942ace3a8b389a14/mcai_worker_sdk-2.1.1-cp310-cp310-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fc64ef6ffd07afad2f8887b4aa8f2a310b9642f9498237c2904be978eed32472",
"md5": "26cbb1020bbea076d69b3162715489b0",
"sha256": "cb0fa8cd24118f9533ed2bfc335802051228802556ba34dd63f51cc0a4ddc044"
},
"downloads": -1,
"filename": "mcai_worker_sdk-2.1.1-cp311-cp311-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "26cbb1020bbea076d69b3162715489b0",
"packagetype": "bdist_wheel",
"python_version": "cp311",
"requires_python": ">=3.8",
"size": 8971678,
"upload_time": "2024-12-03T11:56:18",
"upload_time_iso_8601": "2024-12-03T11:56:18.342267Z",
"url": "https://files.pythonhosted.org/packages/fc/64/ef6ffd07afad2f8887b4aa8f2a310b9642f9498237c2904be978eed32472/mcai_worker_sdk-2.1.1-cp311-cp311-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "b4296cda4e6a9159d2c7b5acc7d3608b4faffdfeb7cfb5e14771b5c589c8e78c",
"md5": "74009277cdcfcb2baf0709ee45d5fe4d",
"sha256": "e7d178acf6f38307e85135e9044e08a1d42f70617a17b0cc18d79c6a28660f6d"
},
"downloads": -1,
"filename": "mcai_worker_sdk-2.1.1-cp312-cp312-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "74009277cdcfcb2baf0709ee45d5fe4d",
"packagetype": "bdist_wheel",
"python_version": "cp312",
"requires_python": ">=3.8",
"size": 8974171,
"upload_time": "2024-12-03T11:56:20",
"upload_time_iso_8601": "2024-12-03T11:56:20.560218Z",
"url": "https://files.pythonhosted.org/packages/b4/29/6cda4e6a9159d2c7b5acc7d3608b4faffdfeb7cfb5e14771b5c589c8e78c/mcai_worker_sdk-2.1.1-cp312-cp312-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "fa24a82b284cffd5608b81311d4d1182e959bd5d5b09de49c42ac478335fc46d",
"md5": "1b4b9186c099940d03b95262f455de63",
"sha256": "843cb612efd9387382273040e1100891684e6826aa715540b5a0fedc1ea5baab"
},
"downloads": -1,
"filename": "mcai_worker_sdk-2.1.1-cp38-cp38-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "1b4b9186c099940d03b95262f455de63",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.8",
"size": 8973123,
"upload_time": "2024-12-03T11:56:23",
"upload_time_iso_8601": "2024-12-03T11:56:23.794517Z",
"url": "https://files.pythonhosted.org/packages/fa/24/a82b284cffd5608b81311d4d1182e959bd5d5b09de49c42ac478335fc46d/mcai_worker_sdk-2.1.1-cp38-cp38-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "4147db87b9bddb9236208357421b2e22b43e3db2e7ac9590d0bdbbfb3ad3afbb",
"md5": "8d64201fc4ba6b84a97988b7b7c2ee33",
"sha256": "2cd50c8072e5f57764dc93a602cc27266e071a92e042024961f1adf0563d4690"
},
"downloads": -1,
"filename": "mcai_worker_sdk-2.1.1-cp39-cp39-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "8d64201fc4ba6b84a97988b7b7c2ee33",
"packagetype": "bdist_wheel",
"python_version": "cp39",
"requires_python": ">=3.8",
"size": 8973570,
"upload_time": "2024-12-03T11:56:26",
"upload_time_iso_8601": "2024-12-03T11:56:26.233689Z",
"url": "https://files.pythonhosted.org/packages/41/47/db87b9bddb9236208357421b2e22b43e3db2e7ac9590d0bdbbfb3ad3afbb/mcai_worker_sdk-2.1.1-cp39-cp39-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "9716b81d4b56189fcba34903b40a65d4c2faf8a17e917466903b29502ff43f67",
"md5": "f2f2dfcb590122feb16165bef2f1f024",
"sha256": "468c4d87100a58f01fee0bd373a4890dd9870ed7c4ce5fb2390935165db52ff1"
},
"downloads": -1,
"filename": "mcai_worker_sdk-2.1.1-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "f2f2dfcb590122feb16165bef2f1f024",
"packagetype": "bdist_wheel",
"python_version": "pp310",
"requires_python": ">=3.8",
"size": 8974717,
"upload_time": "2024-12-03T11:56:28",
"upload_time_iso_8601": "2024-12-03T11:56:28.670961Z",
"url": "https://files.pythonhosted.org/packages/97/16/b81d4b56189fcba34903b40a65d4c2faf8a17e917466903b29502ff43f67/mcai_worker_sdk-2.1.1-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "ce495a059a14fd882c41c3a74592b3c1af36bba2cee923c31923bc254b32bd88",
"md5": "5a538afcc96bbba40086980764d038fb",
"sha256": "fa9c480fe9361be4f95caf882b3e6cb65e3e0975d33960d59fb072188f6ed4fb"
},
"downloads": -1,
"filename": "mcai_worker_sdk-2.1.1-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl",
"has_sig": false,
"md5_digest": "5a538afcc96bbba40086980764d038fb",
"packagetype": "bdist_wheel",
"python_version": "pp39",
"requires_python": ">=3.8",
"size": 8974232,
"upload_time": "2024-12-03T11:56:30",
"upload_time_iso_8601": "2024-12-03T11:56:30.903997Z",
"url": "https://files.pythonhosted.org/packages/ce/49/5a059a14fd882c41c3a74592b3c1af36bba2cee923c31923bc254b32bd88/mcai_worker_sdk-2.1.1-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "30b4627fc77d076420ca0dce973c0682b4f323e7e4a313476bf6624170854ee1",
"md5": "3adcae963eeb27cc2b55c5d90d65d138",
"sha256": "5892f825e9e96c1c5834b6aad992b99d28228d7b210b707e097ed81676db7707"
},
"downloads": -1,
"filename": "mcai_worker_sdk-2.1.1.tar.gz",
"has_sig": false,
"md5_digest": "3adcae963eeb27cc2b55c5d90d65d138",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 54606,
"upload_time": "2024-12-03T11:56:33",
"upload_time_iso_8601": "2024-12-03T11:56:33.422264Z",
"url": "https://files.pythonhosted.org/packages/30/b4/627fc77d076420ca0dce973c0682b4f323e7e4a313476bf6624170854ee1/mcai_worker_sdk-2.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-12-03 11:56:33",
"github": false,
"gitlab": true,
"bitbucket": false,
"codeberg": false,
"gitlab_user": "media-cloud-ai",
"gitlab_project": "sdks",
"lcname": "mcai-worker-sdk"
}