Metadata-Version: 2.3
Name: londonaicentre-mesa-runtime
Version: 0.6.0
Author: Martin Chapman
Author-email: Martin Chapman <contact@martinchapman.co.uk>
Requires-Dist: boto3>=1.35
Requires-Dist: httpx>=0.28
Requires-Dist: pydantic>=2.0
Requires-Python: >=3.12
Description-Content-Type: text/markdown

# mesa-runtime/lib

A client for dispatching and following MESA training and inference runs through the [automations API](https://github.com/londonaicentre/automations/tree/main/api).

## Usage

```python
from mesa_runtime import MesaRuntime

client = MesaRuntime("https://example.cloudfront.net", "username", "password")

run_id = client.dispatch("batch-2026-01", "foo", "onco")
print(client.get_run(run_id))
```

Batch inference uploads the batch file with the caller's AWS credentials:

```python
run_id = client.run_batch_inference("foo/bar", "qux.jsonl", "quux", "baz")
print(client.get_run(run_id))
```

Listing training data also uses the caller's AWS credentials, which need `s3:ListBucket` on `aicentre-nlpteam-mesa-build`.

A `config` file passed to `dispatch` or `run_batch_inference` replaces the flow's default config in full, so start from a copy of the defaults in automations' [`flows/configs/mesa`](https://github.com/londonaicentre/automations/tree/main/flows/configs/mesa).
The flow's own inference endpoint, storage type and storage paths override any set in it.

## API

| Method | Description |
|--------|-------------|
| `list_training_data()` | List available training data objects from S3 |
| `dispatch(training_batch_name, model_name, schema, ...)` | Trigger a training run, returns its ID |
| `get_run(run_id)` | Fetch a single training or inference run by ID |
| `list_runs()` | List the ten most recent training runs |
| `list_queued_runs()` | List the training runs waiting to start |
| `cancel(run_id)` | Cancel a training or inference run |
| `get_logs(run_id)` | Fetch the logs of a training or inference run |
| `get_runner_status()` | Get the work pool's online/busy status |
| `run_batch_inference(job_id, batch_file, bucket, model_id, ...)` | Upload a Bedrock batch file and trigger an inference run, returns its ID (omit `model_id` to split across every endpoint model; pass `schema_name` and `schema_version` to name the output schema) |
| `list_inference_runs()` | List the ten most recent inference runs |
