Skip to main content

Python analysis Conventional Commits Docker Image CI PyPI Docker Pulls PyPI - Downloads


FLAMAPY REST API

A new and easy way to use FLAMA
Report Bug · Request Feature

About The Project

flamapy-rest is a Flask REST API that wraps the FLAMAPY framework for feature model analysis. It dynamically exposes FLAMAPY operations (dead features, false-optional features, configurations, satisfiability, diagnosis, …) as HTTP endpoints, with self-generated Swagger documentation.

Feature model analysis has a crucial role in software product line engineering, enabling us to understand, design, and validate the complex relationships among features in a software product line. These models can be complex and challenging to analyze due to their variability, making it difficult to identify conflicts, dead features, and potential optimizations. This REST API makes that analysis available to any tool or language that can speak HTTP.

Please note: this is a living document and we will continue to update and improve it as we release new versions of the plugins and receive feedback from our users. If there's anything you don't understand or if you have any suggestions for improvement, don't hesitate to open an issue. We're here to help!

Built With

(back to top)

Getting Started

There are three supported ways to run the API. Using the published Docker image is the easiest — nothing to build, and it already bundles FLAMAPY and all of its analysis plugins.

The CI publishes a multi-arch image (linux/amd64 and linux/arm64) to Docker Hub at flamapy/flamapy-rest on every version tag.

# Pull and run the latest release
docker run --rm -p 8000:8000 flamapy/flamapy-rest

Then open:

To pin a specific version, use its tag (matching a release, e.g. v2.6.0):

docker run --rm -p 8000:8000 flamapy/flamapy-rest:v2.6.0

Run it detached and give the container a name so it's easy to stop later:

docker run -d --name flamapy-rest -p 8000:8000 flamapy/flamapy-rest
docker logs -f flamapy-rest   # follow the logs
docker stop flamapy-rest      # stop it
docker rm flamapy-rest        # remove it

Option 2 — Build the Docker image from source

If you want to run your local changes, clone the repo and build the image yourself. A helper script is provided that builds, runs, and (on exit) cleans up the container and image:

# Linux / macOS
./start-server.sh

# Windows
start-server.cmd

Or do it by hand:

docker build --tag flamapy-rest .
docker run --rm -p 8000:8000 flamapy-rest

Option 3 — Install from PyPI and run locally

The API is also published on PyPI as flamapy-rest (requires Python 3.11+). Because the WSGI entrypoint lives in app.py, clone the repo to get it:

git clone https://github.com/flamapy/flamapy-rest.git
cd flamapy-rest
pip install .

# Production server
gunicorn --bind 0.0.0.0:8000 app:app

# …or the Flask development server
python -m flask run --host=0.0.0.0

(back to top)

Usage

Every public operation of FLAMAPY's FLAMAFeatureModel facade is exposed as a POST endpoint under /api/v1/operations/<operation_name>. Each call uploads a feature model file (e.g. UVL) as multipart form data; some operations also accept an optional feature or configuration parameter.

# Example: count the number of valid configurations of a model
curl -X POST http://localhost:8000/api/v1/operations/configurations_number \
  -F "model=@resources/models/simple/valid_model.uvl"

The full, interactive list of endpoints — with parameters and "try it out" support — is available in the Swagger UI at http://localhost:8000/docs/.

(back to top)

Abuse controls & configuration

The API ships with per-IP rate limiting, a per-operation time budget, upload size limits and a result cache, all configurable through environment variables (e.g. docker run -e FLAMAPY_...):

Env var Default Meaning
FLAMAPY_MAX_CONTENT_LENGTH 16777216 Max upload size in bytes; larger requests get 413
FLAMAPY_RATELIMIT_ENABLED true Turn rate limiting on/off
FLAMAPY_RATELIMIT_DEFAULT 60 per minute Per-IP limit for cheap operations
FLAMAPY_RATELIMIT_EXPENSIVE 10 per minute Per-IP limit for enumeration/solver-heavy operations (configurations, configurations_number, sampling, …); exceeding a limit returns 429
FLAMAPY_RATELIMIT_STORAGE_URI memory:// Limiter storage; use redis://host:6379 when running several gunicorn workers so they share counters
FLAMAPY_OPERATION_TIMEOUT 60 Seconds an operation may run before it is killed and 504 is returned; 0 disables
FLAMAPY_CACHE_TTL 3600 Seconds a result stays cached (same model + operation + arguments); 0 disables. Responses carry an `X-Cache: HIT
FLAMAPY_CACHE_MAXSIZE 128 Max cached results per worker
FLAMAPY_TRUST_PROXY false Set to true behind a reverse proxy so rate limits see the real client IP (X-Forwarded-For)
WEB_CONCURRENCY 2 gunicorn worker count (Docker image)
GUNICORN_TIMEOUT 120 gunicorn hard worker timeout; keep it above FLAMAPY_OPERATION_TIMEOUT

Every request is logged to stdout (client IP, path, status, duration, upload size, cache result), so docker logs is enough to spot heavy users.

(back to top)

API Documentation

All documentation is registered with Swagger UI and OAS 3.0, served at /docs/. It is generated dynamically by Flasgger from the route docstrings and method signatures, so don't forget to document your code in the route files — new operations show up automatically.

(back to top)

Contributing

Contributions are welcome. This repo enforces Conventional Commits on pull request titles, and runs Ruff, mypy, and pytest in CI.

pip install .[dev]   # install dev tooling

ruff check .         # lint
mypy -p flamapy      # static type checking
pytest               # tests

(back to top)

Metadata

Release files for flamapy-rest 2.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for flamapy-rest 2.6.0
File Size Uploaded Provenance
flamapy_rest-2.6.0.tar.gz 15.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for flamapy-rest 2.6.0
File Interpreter ABI Platform
flamapy_rest-2.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 26.8 kB

Release files / flamapy_rest-2.6.0.tar.gz

Download URL flamapy_rest-2.6.0.tar.gz
Size 15.8 kB
Tags Source
SHA-256 checksum
How to use checksums
4354a5d81511f80377c0b169509cd209af4b2059d647e403b5493d0f588e9738
BLAKE2b-256 checksum
How to use checksums
4bda95f6d10a866b5d7a71765a513fa4b0b2c5d07d22f51723f901b96699585a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Release files / flamapy_rest-2.6.0-py3-none-any.whl

Download URL flamapy_rest-2.6.0-py3-none-any.whl
Size 11.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
19ce15f0053df80ade21ae11428f638c90102d1ad17d342515d9c865b726c8d5
BLAKE2b-256 checksum
How to use checksums
a859daaad6e2b1824a39af7356d3513c1948dbdf117496cc90679a43050cd5f0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.15

Security for flamapy-rest 2.6.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page