Skip to main content

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

  1. 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": ...}
  1. 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 NUT
  • POST /api/v1/runNUT — Run a prediction on the NUT (expects base64-encoded image)
  • POST /api/v1/stopNUT — Stop the NUT
  • POST /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_info decorator 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

optiattack_client-0.1.1.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

optiattack_client-0.1.1-py3-none-any.whl (5.1 kB view details)

Uploaded Python 3

File details

Details for the file optiattack_client-0.1.1.tar.gz.

File metadata

  • Download URL: optiattack_client-0.1.1.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for optiattack_client-0.1.1.tar.gz
Algorithm Hash digest
SHA256 9fdeab95c4c7734e7fa17312b5e1a5cfb43755eef6bcdb708446b88713ea42fd
MD5 9487b89c4b0ff1214b2d567c3400060a
BLAKE2b-256 37fd1f1131ba91c3319dbb8b9a8bfe5b0b6ef30bf0d20ea9edec77204db0982a

See more details on using hashes here.

File details

Details for the file optiattack_client-0.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for optiattack_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 0c24b70a150f256fb9ce2ca48ee27245181cda22438ddea1fe7799c0fa570c98
MD5 9d834519d96c495158ae74e3a23b8bf6
BLAKE2b-256 b26476b1a4e2679845829785d55f62f3c964b55d26e6ff6644d319b222c1fabe

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page