Momotor Engine Shared documentation

momotor-engine-shared is a Python library with building blocks that the other Momotor engine packages share. Client packages, worker packages, and the broker all depend on it, so the code here has no dependency on any of them.

You use this package when you write code that works with the Momotor engine and you need one of these building blocks:

  • Resources match a job to a worker. A job states what it needs, such as a programming language. A worker states what it offers. momotor.shared.resources explains the definition syntax and the matching rules.

  • Shared state locks let separate processes take turns with shared data. momotor.shared.state explains the lock interface and the local implementation.

  • Async logging wraps a standard Python logger so async code can log without blocking the event loop. See momotor.shared.log.

  • Self-tests plan and judge the test cases that recipe authors embed in a recipe or configuration bundle. See momotor.shared.selftest.

New terms are defined in the Glossary.

Install the package

pip install momotor-engine-shared

The package needs Python 3.11 through 3.14. Python 3.10 support ended in version 3.0.0.

The self-test module is an optional extra. Install it only when you run recipe self-tests:

pip install 'momotor-engine-shared[selftest]'

A first example

This example parses two resource definitions and matches a job against a worker. The job requires Python 3.12. The worker offers Python and Java.

from momotor.shared.resources import Resources

job = Resources.from_string('language: python; python: 3.12')
worker = Resources.from_string('language: ?python, ?java; python: ?3.11, ?3.12')

print(job.match(worker))

The example prints -1.0. A lower number is a better match, and -1.0 is a strong match. momotor.shared.resources explains every match value.

Contents

Indices and tables