Metadata-Version: 2.4
Name: amesa-inference
Version: 0.50.0
Summary: Agent inference package using ONNX models without Ray or PyTorch dependencies
Author-email: Hunter Park <hunter@amesa.com>
Requires-Python: >=3.10, <3.12
Description-Content-Type: text/markdown
Requires-Dist: amesa-api==0.50.0
Requires-Dist: amesa-core==0.50.0
Requires-Dist: numpy<2.0.0
Requires-Dist: onnxruntime
Requires-Dist: onnx
Requires-Dist: ruff
Dynamic: requires-python

# Amesa Inference

A lightweight inference package for running Amesa agents using ONNX models without Ray or PyTorch dependencies.

## Overview

`amesa_inference` provides a standalone inference engine for running trained Amesa agents. It uses ONNX Runtime for model inference, making it suitable for deployment scenarios where you want to avoid heavy dependencies like Ray and PyTorch.

## Features

- **ONNX-based inference**: Uses ONNX Runtime for efficient model inference
- **No Ray or PyTorch dependencies**: Lightweight package suitable for production deployment
- **Network management**: Supports both local and remote objects (agents, perceptors, controllers)
- **Compatible API**: Similar interface to `Trainer.package()` for easy migration

## Installation

```bash
pip install amesa-inference
```

## Usage

`InferenceEngine` is internal: the runtime server and the benchmark run agents with it, and
users run them through those rather than directly.

### Authorization

The engine is authorized by `amesa_core.utils.license_util.authorize_inference`, with the first
of these credentials (`InferenceEngine(license=..., license_file=...)` in place of the
environment):

- `AMESA_LICENSE_FILE`: a license file, validated offline (a runtime server's `license.lic`)
- `AMESA_LICENSE`: a license key, validated by the license server
- `AMESA_PLATFORM_TOKEN`: a compute job's platform token, as long as the platform accepts it
- a USB license key, on a drive mounted on the machine

Without one, or with one that is rejected or not valid, `InferenceEngine()` raises
`LicenseError`; when the server deciding it (the license server, or the platform) doesn't
answer, `LicenseServerError`, a `LicenseError` that trying again may get past.

### Running an agent

```python
from amesa_inference import InferenceEngine

engine = InferenceEngine()
await engine.load_orchestration("path/to/orchestration.json")

# The top agent, or the one named by agent=
await engine.package()

# Each execute() is the episode's next step. The action comes back as the sim gets it in
# training: coerced to its action space and clipped to its bounds
action = await engine.execute(observation, sim_action_mask=action_mask)

# Start a new episode (fresh teachers, controllers and perceptors, no previous action)
await engine.reset()

await engine.close()
```

Remote agents, perceptors and controllers are handled as in training. Pass `config` (a
`NetworkMgr` target, `localhost:1337` by default) to reach them elsewhere.

## Architecture

### Components

1. **InferenceEngine**: Main entry point for inference operations
2. **NetworkMgr**: Manages network connections (non-Ray version)
3. **ONNXInferenceEngine**: Handles ONNX model loading and inference
4. **ONNXAgentProcessor**: Processes agents using ONNX models instead of PyTorch

### Differences from Trainer

- Uses ONNX Runtime instead of PyTorch for model inference
- NetworkMgr is not a Ray actor (runs in the same process)
- No Ray initialization required
- Lighter weight, suitable for production deployment

## Requirements

- Python >= 3.10
- amesa-core
- amesa-api
- onnxruntime
- numpy

## License

Proprietary and confidential - Copyright (C) Amesa, Inc
