|
1 | 1 | <div align="center"> |
2 | 2 |
|
3 | | - <a href="">[](https://github.com/flamapy/flamapy-rest/actions/workflows/tests.yml)</a> |
4 | | - <a href="">[](https://github.com/flamapy/flamapy-rest/actions/workflows/commits.yml)</a> |
5 | | - <a href=""> |
6 | | - <a href=""> |
| 3 | + <a href="https://github.com/flamapy/flamapy-rest/actions/workflows/main.yml"></a> |
| 4 | + <a href="https://github.com/flamapy/flamapy-rest/actions/workflows/conventionalpr.yml"></a> |
| 5 | + <a href="https://github.com/flamapy/flamapy-rest/actions/workflows/docker-image.yml"></a> |
| 6 | + <a href="https://pypi.org/project/flamapy-rest/"></a> |
| 7 | + <a href="https://hub.docker.com/r/flamapy/flamapy-rest"></a> |
| 8 | + <a href="https://pypi.org/project/flamapy-rest/"></a> |
7 | 9 | </div> |
8 | 10 |
|
9 | | -# |
10 | | - |
11 | 11 | <div id="top"></div> |
12 | 12 | <br /> |
13 | 13 | <div align="center"> |
14 | 14 |
|
15 | | - <h3 align="center">FLAMAPY rest API</h3> |
| 15 | + <h3 align="center">FLAMAPY REST API</h3> |
16 | 16 |
|
17 | 17 | <p align="center"> |
18 | 18 | A new and easy way to use FLAMA |
19 | 19 | <br /> |
20 | | - <a href="https://github.com/flamapy/flamapy-fm-dist/issues">Report Bug</a> |
| 20 | + <a href="https://github.com/flamapy/flamapy-rest/issues">Report Bug</a> |
21 | 21 | · |
22 | | - <a href="https://github.com/flamapy/flamapy-fm-dist/issues">Request Feature</a> |
| 22 | + <a href="https://github.com/flamapy/flamapy-rest/issues">Request Feature</a> |
23 | 23 | </p> |
24 | 24 | </div> |
25 | | -<!-- ABOUT THE PROJECT --> |
26 | 25 |
|
| 26 | +<!-- ABOUT THE PROJECT --> |
27 | 27 | ## About The Project |
28 | 28 |
|
29 | | -FLAMAPY Feature model distribution provides an easier way of using FLAMA when analysing feature models. It packs the most used plugins for analyis of feature models adding a layer of convenience to use the framework or integrate it. |
| 29 | +`flamapy-rest` is a [Flask](https://flask.palletsprojects.com/) REST API that wraps the |
| 30 | +[FLAMAPY](https://flamapy.github.io/) framework for **feature model analysis**. It dynamically |
| 31 | +exposes FLAMAPY operations (dead features, false-optional features, configurations, satisfiability, |
| 32 | +diagnosis, …) as HTTP endpoints, with self-generated [Swagger](https://swagger.io/) documentation. |
| 33 | + |
| 34 | +Feature model analysis has a crucial role in software product line engineering, enabling us to |
| 35 | +understand, design, and validate the complex relationships among features in a software product |
| 36 | +line. These models can be complex and challenging to analyze due to their variability, making it |
| 37 | +difficult to identify conflicts, dead features, and potential optimizations. This REST API makes |
| 38 | +that analysis available to any tool or language that can speak HTTP. |
| 39 | + |
| 40 | +Please note: this is a living document and we will continue to update and improve it as we release |
| 41 | +new versions of the plugins and receive feedback from our users. If there's anything you don't |
| 42 | +understand or if you have any suggestions for improvement, don't hesitate to |
| 43 | +[open an issue](https://github.com/flamapy/flamapy-rest/issues). We're here to help! |
| 44 | + |
| 45 | +### Built With |
| 46 | + |
| 47 | +* [Docker](https://www.docker.com/) |
| 48 | +* [Flask](https://flask.palletsprojects.com/) |
| 49 | +* [FLAMAPY](https://github.com/flamapy) |
| 50 | +* [Flasgger](https://github.com/flasgger/flasgger) |
30 | 51 |
|
31 | | -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 feature models can often be complex and challenging to analyze due to their variability, making it difficult to identify conflicts, dead features, and potential optimizations. This is where this distribution comes in. |
| 52 | +<p align="right">(<a href="#top">back to top</a>)</p> |
32 | 53 |
|
33 | | -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 contact us. We're here to help! |
| 54 | +<!-- GETTING STARTED --> |
| 55 | +## Getting Started |
34 | 56 |
|
35 | | -Three main interfaces are provided: |
36 | | -* A REST API: The REST API allows for easy integration with other tools and applications. It is also a more user friendly interface for those who are not familiar with the command line. |
| 57 | +There are three supported ways to run the API. **Using the published Docker image is the easiest** — |
| 58 | +nothing to build, and it already bundles FLAMAPY and all of its analysis plugins. |
| 59 | + |
| 60 | +### Option 1 — Run the published Docker image (recommended) |
| 61 | + |
| 62 | +The CI publishes a multi-arch image (`linux/amd64` and `linux/arm64`) to Docker Hub at |
| 63 | +[`flamapy/flamapy-rest`](https://hub.docker.com/r/flamapy/flamapy-rest) on every version tag. |
37 | 64 |
|
38 | | -Whant it to runint, simply run |
39 | 65 | ```bash |
40 | | -pip install flamapy-rest |
41 | | -gunicorn --bind 0.0.0.0:8000 app:app |
| 66 | +# Pull and run the latest release |
| 67 | +docker run --rm -p 8000:8000 flamapy/flamapy-rest |
| 68 | +``` |
| 69 | + |
| 70 | +Then open: |
| 71 | + |
| 72 | +* API home: <http://localhost:8000/> |
| 73 | +* Swagger UI / API docs: <http://localhost:8000/docs/> |
| 74 | + |
| 75 | +To pin a specific version, use its tag (matching a release, e.g. `v2.6.0`): |
| 76 | + |
| 77 | +```bash |
| 78 | +docker run --rm -p 8000:8000 flamapy/flamapy-rest:v2.6.0 |
| 79 | +``` |
| 80 | + |
| 81 | +Run it detached and give the container a name so it's easy to stop later: |
| 82 | + |
| 83 | +```bash |
| 84 | +docker run -d --name flamapy-rest -p 8000:8000 flamapy/flamapy-rest |
| 85 | +docker logs -f flamapy-rest # follow the logs |
| 86 | +docker stop flamapy-rest # stop it |
| 87 | +docker rm flamapy-rest # remove it |
42 | 88 | ``` |
43 | 89 |
|
44 | | -Alternatively, you can use docker in this way: |
| 90 | +### Option 2 — Build the Docker image from source |
| 91 | + |
| 92 | +If you want to run your local changes, clone the repo and build the image yourself. A helper script |
| 93 | +is provided that builds, runs, and (on exit) cleans up the container and image: |
| 94 | + |
45 | 95 | ```bash |
46 | | -chmod +x start-server.sh |
| 96 | +# Linux / macOS |
47 | 97 | ./start-server.sh |
| 98 | + |
| 99 | +# Windows |
| 100 | +start-server.cmd |
48 | 101 | ``` |
49 | | -Or go to [the render deployed version]() it isn't fast, but its free. |
50 | 102 |
|
51 | | -<p align="right">(<a href="#top">back to top</a>)</p> |
| 103 | +Or do it by hand: |
52 | 104 |
|
53 | | -### Built With |
| 105 | +```bash |
| 106 | +docker build --tag flamapy-rest . |
| 107 | +docker run --rm -p 8000:8000 flamapy-rest |
| 108 | +``` |
54 | 109 |
|
55 | | -* [Docker](https://www.docker.com/) |
56 | | -* [Flask](https://flask.palletsprojects.com/en/2.2.x/) |
57 | | -* [FLAMAPY](https://github.com/flamapy) |
58 | | -* [Flasgger](https://github.com/flasgger/flasgger) |
| 110 | +### Option 3 — Install from PyPI and run locally |
| 111 | + |
| 112 | +The API is also published on PyPI as [`flamapy-rest`](https://pypi.org/project/flamapy-rest/) |
| 113 | +(requires **Python 3.11+**). Because the WSGI entrypoint lives in `app.py`, clone the repo to get it: |
| 114 | + |
| 115 | +```bash |
| 116 | +git clone https://github.com/flamapy/flamapy-rest.git |
| 117 | +cd flamapy-rest |
| 118 | +pip install . |
| 119 | + |
| 120 | +# Production server |
| 121 | +gunicorn --bind 0.0.0.0:8000 app:app |
| 122 | + |
| 123 | +# …or the Flask development server |
| 124 | +python -m flask run --host=0.0.0.0 |
| 125 | +``` |
59 | 126 |
|
60 | 127 | <p align="right">(<a href="#top">back to top</a>)</p> |
61 | 128 |
|
62 | | -# Using the distribution REST API |
63 | | -The easies way is to execute the following command: docker run -p 8000:8000 flamapy/flamapy-fm-dist and open localhost:8000 |
64 | | -<!-- GETTING STARTED --> |
65 | | -## Getting Started |
| 129 | +## Usage |
66 | 130 |
|
67 | | -To get a local copy up and running follow these simple example steps. |
| 131 | +Every public operation of FLAMAPY's `FLAMAFeatureModel` facade is exposed as a `POST` endpoint under |
| 132 | +`/api/v1/operations/<operation_name>`. Each call uploads a feature model file (e.g. UVL) as |
| 133 | +multipart form data; some operations also accept an optional `feature` or `configuration` parameter. |
68 | 134 |
|
69 | | -First, you will need to install [Docker](https://docs.docker.com/desktop/). |
| 135 | +```bash |
| 136 | +# Example: count the number of valid configurations of a model |
| 137 | +curl -X POST http://localhost:8000/api/v1/operations/configurations_number \ |
| 138 | + -F "model=@resources/models/simple/valid_model.uvl" |
| 139 | +``` |
70 | 140 |
|
71 | | -### Instalation |
| 141 | +The full, interactive list of endpoints — with parameters and "try it out" support — is available |
| 142 | +in the Swagger UI at <http://localhost:8000/docs/>. |
72 | 143 |
|
73 | | -1. Clone the repository |
| 144 | +<p align="right">(<a href="#top">back to top</a>)</p> |
| 145 | + |
| 146 | +## API Documentation |
74 | 147 |
|
75 | | -2. If you are running Windows, run |
76 | | - ```sh |
77 | | - $ cd flamapy-dm-dist |
78 | | - $ ./start-server.cmd |
79 | | - ``` |
80 | | - |
81 | | -3. If you are running Linux or MacOS, run |
82 | | - ```sh |
83 | | - $ cd flamapy-dm-dist |
84 | | - $ ./start-server.sh |
85 | | - ``` |
86 | | - |
87 | | -This script will build, install and deploy the API in http://localhost:8000, you can access all the endpoints through an application like [Postman](https://www.postman.com/) |
| 148 | +All documentation is registered with Swagger UI and OAS 3.0, served at |
| 149 | +[`/docs/`](http://localhost:8000/docs/). It is generated dynamically by |
| 150 | +[Flasgger](https://github.com/flasgger/flasgger) from the route docstrings and method signatures, so |
| 151 | +**don't forget to document your code in the route files** — new operations show up automatically. |
88 | 152 |
|
89 | 153 | <p align="right">(<a href="#top">back to top</a>)</p> |
90 | 154 |
|
91 | | -### API Documentation |
| 155 | +## Contributing |
| 156 | + |
| 157 | +Contributions are welcome. This repo enforces |
| 158 | +[Conventional Commits](https://www.conventionalcommits.org/) on pull request titles, and runs Ruff, |
| 159 | +mypy, and pytest in CI. |
92 | 160 |
|
93 | | -All the documentation is registered with Swagger UI and OAS 3.0. It is accesible through /api/v1/docs. This documentation is generated dinamically by relyin gon flasgger. DO not forget to document your code in the route files! |
| 161 | +```bash |
| 162 | +pip install .[dev] # install dev tooling |
| 163 | + |
| 164 | +ruff check . # lint |
| 165 | +mypy -p flamapy # static type checking |
| 166 | +pytest # tests |
| 167 | +``` |
94 | 168 |
|
95 | 169 | <p align="right">(<a href="#top">back to top</a>)</p> |
0 commit comments