A FastAPI decorator to track method calls and manage state.
Project description
OptiAttack Client
The OptiAttack Client (optiattack_client) is a FastAPI-based server package designed to facilitate remote integration between the OptiAttack core engine and external models or systems under test (NUT). It provides a simple decorator and API endpoints for seamless communication and adversarial test execution.
Table of Contents
Features
- FastAPI server for remote model or NUT integration
- Decorator-based interface for easy wrapping of prediction functions
- Automatic endpoint creation for running, stopping, and querying the NUT
- Supports image-based adversarial attacks
- Easy integration with OptiAttack core
Installation
You can install the OptiAttack Client package using pip:
pip install optiattack-client
Alternatively, if you want to install from the local directory (for development or custom modifications), run:
cd client
pip install -e .
Quick Start
- Wrap your prediction function with the provided decorator:
from optiattack_client import collect_info
@collect_info(host="localhost", port=38000)
def predict(image_array):
# Your prediction logic here
return {"predictions": ...}
- Start your script. The FastAPI server will automatically run and expose endpoints for OptiAttack to communicate with.
API Endpoints
The client exposes the following endpoints (default base path: /api/v1):
GET /api/v1/infoNUT— Get the current state of the NUTPOST /api/v1/runNUT— Run a prediction on the NUT (expects base64-encoded image)POST /api/v1/stopNUT— Stop the NUTPOST /api/v1/newAction— Apply a new action (mutation) and get prediction
See client/constants.py for all endpoint paths and defaults.
Example Usage
from optiattack_client import collect_info
@collect_info(host="localhost", port=38000)
def predict(image_array):
# Example: Use your ML model to predict
# result = model.predict(image_array)
return {"predictions": [0.1, 0.9]} # Example output
# The FastAPI server is now running at http://localhost:38000
Configuration
- Host and Port: Set via the
collect_infodecorator arguments. - Endpoints: Configurable in
client/constants.py. - Python Version: Requires Python 3.9 or higher.
Contributing
Contributions are welcome! Please open issues or pull requests for bug fixes, new features, or documentation improvements.
License
This package is part of the OptiAttack project and is licensed under the GNU Lesser General Public License v3 (LGPLv3).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file optiattack_client-0.1.6.tar.gz.
File metadata
- Download URL: optiattack_client-0.1.6.tar.gz
- Upload date:
- Size: 4.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a356dec6786ec8b7e545c3550eb73bbba7eaed473242c572698701a2a537f40f
|
|
| MD5 |
4a77b39e83b3894be43ec7d89d6e801e
|
|
| BLAKE2b-256 |
d1cc4d27be3723bcf5f0b581a91d58b5e108c91c3fd30c0324aa8b57a3beb27f
|
File details
Details for the file optiattack_client-0.1.6-py3-none-any.whl.
File metadata
- Download URL: optiattack_client-0.1.6-py3-none-any.whl
- Upload date:
- Size: 4.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dddcbe1708f36aa6df5b6f4d8e7336692495bc336f601dfeffd4b89f48b180ed
|
|
| MD5 |
322cc33939c3455f266c035afc9ec89d
|
|
| BLAKE2b-256 |
46c8527bc7ab2c18b0e3706cc9094d8353777b72261b32a5ba15decd79bf50a5
|