This module scaffolds the creation of a standard inference worker to run on the Moises/Maestro infrastructure.
To install the main branch:
pip install git+https://github.com/moises-ai/maestro-worker-python.git
To install a version (recommended):
pip install git+https://github.com/moises-ai/maestro-worker-python.git@5.0.0
Run the init script to scaffold a maestro worker in the current directory.
To create a different one, use the flag --folder
maestro-initThis will create a starter Maestro worker project, including:
- A
modelsfolder to include your models - A
.gitignoreand.dockerignore - A
docker-compose.yamlfile - A
Dockerfile - A
pyproject.tomlpinned to the installed Maestro worker version - A
README.mdcovering local, Docker, and PyTorch development - A
worker.pywith a worker example
Install the worker dependencies and create its uv.lock:
cd <worker-folder>
uv syncCommit the generated uv.lock with the worker project.
The generated README explains how to declare a specific PyTorch version for local development and select a matching PyTorch base image for container tests.
Run the CLI passing your worker file as the first param, then, any parameters exposed by your class. In this example, input_1 will be sent to the worker, with the value Hello.
uv run maestro-cli ./worker.py --input_1=HelloRun the maestro server with the path to your worker. To see all options, use maestro-server --help
uv run maestro-server --worker=./worker.pyInstalled worker adapters can also be loaded by module name:
uv run maestro-server --worker=my_package.workerSend a request to the server inference endpoint:
curl --request POST --url http://localhost:8000/inference --header 'Content-Type: application/json' \
--data '{"input_1": "Hello"}'Workers return a WorkerResponse with three fields:
billable_seconds: the billable duration as a number of seconds, including fractional seconds when available, ornullwhen it cannot be determined.stats: numeric worker measurements. Usedurationfor total worker processing time; additional keys may report individual phases.result: the worker-specific JSON object.
The /health endpoint reports the worker artifact version supplied through
WORKER_VERSION and available GPU metadata in addition to ok. Deployments
should set it to the exact worker image tag; it is null when unset.
nvidia_driver_version is the host driver,
driver_supported_version is the newest CUDA version it supports, and
torch_build_version is the toolkit version used to build an already-imported
PyTorch. NVIDIA host probing uses NVML and is best-effort, so CPU workers return
an empty hardware.gpus list. Visible MIG partitions report their GPU-instance
slice count, compute-instance slice count, and memory size. MPS reports its
configured active-thread percentage and pinned-device-memory limit. These
client settings can be further constrained by the MPS daemon, so they are not
presented as effective limits and cannot reliably reveal the total number of
clients. Once an already-imported PyTorch has initialized CUDA,
observed_sm_count reports the SMs available to its current CUDA device without
making the health check initialize CUDA itself.
In order to avoid using signedurls for uploading/downloading files, you can use the maestro-upload-server command. This will start a server in the default 9090 port that will upload/download files in the local ./uploads folder.
Examples:
maestro-upload-server --port=9090After server is running, you can upload files to it:
curl http://localhost:9090/upload-file/your_file_nameThen retrieve it:
curl http://localhost:9090/get-file/your_file_nameYou can clean the files using:
curl http://localhost:9090/cleanYou can also list files using:
curl http://localhost:9090/list-filesfrom maestro_worker_python.download_file import download_file
file_name = download_file("https://url_to_download_file")from maestro_worker_python.upload_files import upload_files, UploadFile
files_to_upload = []
files_to_upload.append(UploadFile(file_path="test_upload1.txt", file_type="text/plain", signed_url="https://httpbin.org/put"))
files_to_upload.append(UploadFile(file_path="test_upload2.txt", file_type="text/plain", signed_url="https://httpbin.org/put"))
upload_files(files_to_upload)from maestro_worker_python.convert_files import convert_files, FileToConvert
files_to_convert = []
files_to_convert.append(FileToConvert(input_file_path="input.mp3", output_file_path="output.wav", file_format="wav", max_duration=1200))
files_to_convert.append(FileToConvert(input_file_path="input.mp3", output_file_path="output.m4a", file_format="m4a", max_duration=1200))
convert_files(files_to_convert)from maestro_worker_python.get_duration import get_duration
get_duration('./myfile.mp3')The returned float preserves fractional seconds reported by ffprobe.
docker compose builddocker compose run --service-ports workerInstall uv.
You can run it in development mode:
uv sync
uv run maestro-initTo bump the package version:
uv version --bump patchRun the quality checks:
uv run pytest
uv run ruff check .
uv run ruff format --check .
uv run ty check