Metadata-Version: 2.3
Name: poliwrap
Version: 0.0.7
Summary: A lightweight, framework-agnostic abstraction for reinforcement learning policy inference.
Keywords: reinforcement-learning,inference,policy
Author: Miguel Villa Floran, Jing Cao
Author-email: Miguel Villa Floran <miguel.villafloran@gmail.com>, Jing Cao <jcao0715@gmail.com>
License: MIT License
         
         Copyright (c) 2026 Miguel Villa Floran, Jing Cao
         
         Permission is hereby granted, free of charge, to any person obtaining a copy
         of this software and associated documentation files (the "Software"), to deal
         in the Software without restriction, including without limitation the rights
         to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
         copies of the Software, and to permit persons to whom the Software is
         furnished to do so, subject to the following conditions:
         
         The above copyright notice and this permission notice shall be included in all
         copies or substantial portions of the Software.
         
         THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
         IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
         FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
         AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
         LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
         OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
         SOFTWARE.
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Dist: numpy
Requires-Dist: poliwrap[onnx] ; extra == 'all'
Requires-Dist: poliwrap[torch] ; extra == 'all'
Requires-Dist: onnxruntime ; extra == 'onnx'
Requires-Dist: onnxruntime-gpu ; extra == 'onnx-gpu'
Requires-Dist: torch ; extra == 'torch'
Requires-Python: >=3.10, <3.14
Provides-Extra: all
Provides-Extra: onnx
Provides-Extra: onnx-gpu
Provides-Extra: torch
Description-Content-Type: text/markdown

# PoliWrap

A lightweight, framework-agnostic wrapper for reinforcement learning policy inference.

## Installation

```bash
pip install poliwrap            # core only (numpy)
pip install poliwrap[onnx]      # + ONNX Runtime backend (CPU)
pip install poliwrap[onnx-gpu]  # + ONNX Runtime backend (CUDA)
pip install poliwrap[torch]     # + PyTorch backend
pip install poliwrap[all]       # all backends (CPU ONNX)
```

Each wrapper is importable only when its backend is installed.

## Usage

### ONNX

```python
from poliwrap import ONNXPolicyWrapper

policy = ONNXPolicyWrapper("policy.onnx")
actions = policy({"actor_obs": obs})  # obs: dict[str, np.ndarray]
```

### PyTorch

```python
from poliwrap import PytorchPolicyWrapper

policy = PytorchPolicyWrapper("policy.pt")
actions = policy({"actor_obs": obs})  # obs: dict[str, torch.Tensor]
```

## Extending

All wrappers subclass `PolicyWrapper`. To support a new backend, implement
`_load_model` and `__call__`:

```python
from poliwrap import PolicyWrapper


class MyPolicyWrapper(PolicyWrapper):
    def _load_model(self) -> None:
        self.model = ...  # load from self.model_path

    def __call__(self, observations):
        return self.model(observations)
```

`PolicyWrapper` also has overridable `preprocess_observations`, `postprocess_actions`,
and `reset` hooks for input/output transforms and stateful (e.g. RNN) policies.

## License

MIT
