flamapy-rest 2.0.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.1
2
+ Name: flamapy-rest
3
+ Version: 2.0.0
4
+ Summary: Flamapy feature model is a distribution of the flama framework containing all plugins required to analyze feature models. It also offers a richier API and a complete command line interface and documentation.
5
+ Home-page: https://github.com/flamapy/flamapy-feature-model
6
+ Author: Flamapy
7
+ Author-email: flamapy@us.es
8
+ License: UNKNOWN
9
+ Platform: UNKNOWN
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+ Provides-Extra: dev
16
+
17
+ <div align="center">
18
+
19
+ <a href="">[![Pytest Testing Suite](https://github.com/flamapy/flamapy-rest/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/flamapy/flamapy-rest/actions/workflows/tests.yml)</a>
20
+ <a href="">[![Commits Syntax Checker](https://github.com/flamapy/flamapy-rest/actions/workflows/commits.yml/badge.svg?branch=main)](https://github.com/flamapy/flamapy-rest/actions/workflows/commits.yml)</a>
21
+ <a href="">![PyPI](https://img.shields.io/pypi/v/flamapy-rest?label=pypi%20package)
22
+ <a href="">![PyPI - Downloads](https://img.shields.io/pypi/dm/flamapy-rest)
23
+ </div>
24
+
25
+ #
26
+
27
+ <div id="top"></div>
28
+ <br />
29
+ <div align="center">
30
+
31
+ <h3 align="center">FLAMAPY rest API</h3>
32
+
33
+ <p align="center">
34
+ A new and easy way to use FLAMA
35
+ <br />
36
+ <a href="https://github.com/flamapy/flamapy-fm-dist/issues">Report Bug</a>
37
+ ·
38
+ <a href="https://github.com/flamapy/flamapy-fm-dist/issues">Request Feature</a>
39
+ </p>
40
+ </div>
41
+ <!-- ABOUT THE PROJECT -->
42
+
43
+ ## About The Project
44
+
45
+ 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.
46
+
47
+ 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.
48
+
49
+ 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!
50
+
51
+ Three main interfaces are provided:
52
+ * 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.
53
+
54
+ Whant it to runint, simply run
55
+ ```bash
56
+ pip install flamapy-rest
57
+ gunicorn --bind 0.0.0.0:8000 app:app
58
+ ```
59
+
60
+ Alternatively, you can use docker in this way:
61
+ ```bash
62
+ chmod +x start-server.sh
63
+ ./start-server.sh
64
+ ```
65
+ Or go to [the render deployed version]() it isn't fast, but its free.
66
+
67
+ <p align="right">(<a href="#top">back to top</a>)</p>
68
+
69
+ ### Built With
70
+
71
+ * [Docker](https://www.docker.com/)
72
+ * [Flask](https://flask.palletsprojects.com/en/2.2.x/)
73
+ * [FLAMAPY](https://github.com/flamapy)
74
+ * [Flasgger](https://github.com/flasgger/flasgger)
75
+
76
+ <p align="right">(<a href="#top">back to top</a>)</p>
77
+
78
+ # Using the distribution REST API
79
+ The easies way is to execute the following command: docker run -p 8000:8000 flamapy/flamapy-fm-dist and open localhost:8000
80
+ <!-- GETTING STARTED -->
81
+ ## Getting Started
82
+
83
+ To get a local copy up and running follow these simple example steps.
84
+
85
+ First, you will need to install [Docker](https://docs.docker.com/desktop/).
86
+
87
+ ### Instalation
88
+
89
+ 1. Clone the repository
90
+
91
+ 2. If you are running Windows, run
92
+ ```sh
93
+ $ cd flamapy-dm-dist
94
+ $ ./start-server.cmd
95
+ ```
96
+
97
+ 3. If you are running Linux or MacOS, run
98
+ ```sh
99
+ $ cd flamapy-dm-dist
100
+ $ ./start-server.sh
101
+ ```
102
+
103
+ 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/)
104
+
105
+ <p align="right">(<a href="#top">back to top</a>)</p>
106
+
107
+ ### API Documentation
108
+
109
+ 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!
110
+
111
+ <p align="right">(<a href="#top">back to top</a>)</p>
112
+
113
+
@@ -0,0 +1,95 @@
1
+ <div align="center">
2
+
3
+ <a href="">[![Pytest Testing Suite](https://github.com/flamapy/flamapy-rest/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/flamapy/flamapy-rest/actions/workflows/tests.yml)</a>
4
+ <a href="">[![Commits Syntax Checker](https://github.com/flamapy/flamapy-rest/actions/workflows/commits.yml/badge.svg?branch=main)](https://github.com/flamapy/flamapy-rest/actions/workflows/commits.yml)</a>
5
+ <a href="">![PyPI](https://img.shields.io/pypi/v/flamapy-rest?label=pypi%20package)
6
+ <a href="">![PyPI - Downloads](https://img.shields.io/pypi/dm/flamapy-rest)
7
+ </div>
8
+
9
+ #
10
+
11
+ <div id="top"></div>
12
+ <br />
13
+ <div align="center">
14
+
15
+ <h3 align="center">FLAMAPY rest API</h3>
16
+
17
+ <p align="center">
18
+ A new and easy way to use FLAMA
19
+ <br />
20
+ <a href="https://github.com/flamapy/flamapy-fm-dist/issues">Report Bug</a>
21
+ ·
22
+ <a href="https://github.com/flamapy/flamapy-fm-dist/issues">Request Feature</a>
23
+ </p>
24
+ </div>
25
+ <!-- ABOUT THE PROJECT -->
26
+
27
+ ## About The Project
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.
30
+
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.
32
+
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!
34
+
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.
37
+
38
+ Whant it to runint, simply run
39
+ ```bash
40
+ pip install flamapy-rest
41
+ gunicorn --bind 0.0.0.0:8000 app:app
42
+ ```
43
+
44
+ Alternatively, you can use docker in this way:
45
+ ```bash
46
+ chmod +x start-server.sh
47
+ ./start-server.sh
48
+ ```
49
+ Or go to [the render deployed version]() it isn't fast, but its free.
50
+
51
+ <p align="right">(<a href="#top">back to top</a>)</p>
52
+
53
+ ### Built With
54
+
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)
59
+
60
+ <p align="right">(<a href="#top">back to top</a>)</p>
61
+
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
66
+
67
+ To get a local copy up and running follow these simple example steps.
68
+
69
+ First, you will need to install [Docker](https://docs.docker.com/desktop/).
70
+
71
+ ### Instalation
72
+
73
+ 1. Clone the repository
74
+
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/)
88
+
89
+ <p align="right">(<a href="#top">back to top</a>)</p>
90
+
91
+ ### API Documentation
92
+
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!
94
+
95
+ <p align="right">(<a href="#top">back to top</a>)</p>
@@ -0,0 +1,116 @@
1
+ import os
2
+ import inspect
3
+ import json
4
+
5
+ from flask import Blueprint, request, jsonify
6
+ from flamapy.interfaces.python.flamapy_feature_model import FLAMAFeatureModel
7
+ from flamapy.metamodels.configuration_metamodel.models import Configuration
8
+
9
+
10
+ operations_bp = Blueprint('operations_bp', __name__, url_prefix='/api/v1/operations')
11
+
12
+ MODEL_FOLDER = './resources/models/'
13
+
14
+ class CustomJSONEncoder(json.JSONEncoder):
15
+ def default(self, obj):
16
+ if isinstance(obj, Configuration):
17
+ return obj.__dict__
18
+ return super().default(obj)
19
+
20
+ def _api_call(operation_name: str):
21
+ # Get files
22
+ uploaded_model = request.files['model']
23
+
24
+ # Check if file is provided
25
+ if uploaded_model.filename != '':
26
+ # Save file
27
+ uploaded_model.save(os.path.join(MODEL_FOLDER, uploaded_model.filename))
28
+
29
+ fm = FLAMAFeatureModel(os.path.join(MODEL_FOLDER, uploaded_model.filename))
30
+ operation = getattr(fm, operation_name)
31
+
32
+ # Extract the method signature
33
+ sig = inspect.signature(operation)
34
+ params = sig.parameters
35
+
36
+ args = []
37
+ for param in params.values():
38
+ if param.name == 'feature_name':
39
+ args.append(request.form['feature'])
40
+ elif param.name == 'configuration_path':
41
+ configuration = request.files['configuration']
42
+ configuration.save(os.path.join(MODEL_FOLDER, configuration.filename))
43
+ args.append(os.path.join(MODEL_FOLDER, configuration.filename))
44
+
45
+ result = operation(*args)
46
+
47
+ # Remove file
48
+ os.remove(os.path.join(MODEL_FOLDER, uploaded_model.filename))
49
+
50
+ if 'configuration' in request.files:
51
+ os.remove(os.path.join(MODEL_FOLDER, request.files['configuration'].filename))
52
+
53
+ # Return result
54
+ if result is None:
55
+ return jsonify(error='Not valid result'), 404
56
+ else:
57
+ return jsonify(json.loads(json.dumps(result, cls=CustomJSONEncoder)))
58
+
59
+
60
+ def extract_docstring_with_swagger_info(method):
61
+ docstring = method.__doc__ or ""
62
+ parameters = """
63
+ parameters:
64
+ - name: model
65
+ in: formData
66
+ type: file
67
+ required: true
68
+ """
69
+
70
+ # Extract the method signature
71
+ sig = inspect.signature(method)
72
+ for param in sig.parameters.values():
73
+ if param.name == 'feature_name':
74
+ parameters += """
75
+ - name: feature
76
+ in: formData
77
+ type: string
78
+ required: true
79
+ """
80
+ elif param.name == 'configuration_path':
81
+ parameters += """
82
+ - name: configuration
83
+ in: formData
84
+ type: file
85
+ required: true
86
+ """
87
+
88
+ swagger_info = """
89
+ ---
90
+ tags:
91
+ - {operation_name}
92
+ {parameters}
93
+ responses:
94
+ 200:
95
+ description: Result of the operation
96
+ examples:
97
+ result: Example result
98
+ """.format(operation_name=method.__name__, parameters=parameters)
99
+ # Replace new lines with HTML line breaks
100
+ docstring = docstring.replace('\n', '')
101
+ return docstring + swagger_info
102
+
103
+ def create_route(operation_name: str, docstring: str):
104
+ def route_function():
105
+ return _api_call(operation_name)
106
+
107
+ route_function.__name__ = operation_name
108
+ route_function.__doc__ = docstring
109
+ return route_function
110
+
111
+ # Introspect FLAMAFeatureModel class to find all callable methods and create routes dynamically
112
+ for name, method in inspect.getmembers(FLAMAFeatureModel, predicate=inspect.isfunction):
113
+ if name.startswith('_'):
114
+ continue
115
+ docstring = extract_docstring_with_swagger_info(method)
116
+ operations_bp.route(f'/{name}', methods=['POST'])(create_route(name, docstring))
@@ -0,0 +1,113 @@
1
+ Metadata-Version: 2.1
2
+ Name: flamapy-rest
3
+ Version: 2.0.0
4
+ Summary: Flamapy feature model is a distribution of the flama framework containing all plugins required to analyze feature models. It also offers a richier API and a complete command line interface and documentation.
5
+ Home-page: https://github.com/flamapy/flamapy-feature-model
6
+ Author: Flamapy
7
+ Author-email: flamapy@us.es
8
+ License: UNKNOWN
9
+ Platform: UNKNOWN
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
12
+ Classifier: Operating System :: OS Independent
13
+ Requires-Python: >=3.9
14
+ Description-Content-Type: text/markdown
15
+ Provides-Extra: dev
16
+
17
+ <div align="center">
18
+
19
+ <a href="">[![Pytest Testing Suite](https://github.com/flamapy/flamapy-rest/actions/workflows/tests.yml/badge.svg?branch=main)](https://github.com/flamapy/flamapy-rest/actions/workflows/tests.yml)</a>
20
+ <a href="">[![Commits Syntax Checker](https://github.com/flamapy/flamapy-rest/actions/workflows/commits.yml/badge.svg?branch=main)](https://github.com/flamapy/flamapy-rest/actions/workflows/commits.yml)</a>
21
+ <a href="">![PyPI](https://img.shields.io/pypi/v/flamapy-rest?label=pypi%20package)
22
+ <a href="">![PyPI - Downloads](https://img.shields.io/pypi/dm/flamapy-rest)
23
+ </div>
24
+
25
+ #
26
+
27
+ <div id="top"></div>
28
+ <br />
29
+ <div align="center">
30
+
31
+ <h3 align="center">FLAMAPY rest API</h3>
32
+
33
+ <p align="center">
34
+ A new and easy way to use FLAMA
35
+ <br />
36
+ <a href="https://github.com/flamapy/flamapy-fm-dist/issues">Report Bug</a>
37
+ ·
38
+ <a href="https://github.com/flamapy/flamapy-fm-dist/issues">Request Feature</a>
39
+ </p>
40
+ </div>
41
+ <!-- ABOUT THE PROJECT -->
42
+
43
+ ## About The Project
44
+
45
+ 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.
46
+
47
+ 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.
48
+
49
+ 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!
50
+
51
+ Three main interfaces are provided:
52
+ * 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.
53
+
54
+ Whant it to runint, simply run
55
+ ```bash
56
+ pip install flamapy-rest
57
+ gunicorn --bind 0.0.0.0:8000 app:app
58
+ ```
59
+
60
+ Alternatively, you can use docker in this way:
61
+ ```bash
62
+ chmod +x start-server.sh
63
+ ./start-server.sh
64
+ ```
65
+ Or go to [the render deployed version]() it isn't fast, but its free.
66
+
67
+ <p align="right">(<a href="#top">back to top</a>)</p>
68
+
69
+ ### Built With
70
+
71
+ * [Docker](https://www.docker.com/)
72
+ * [Flask](https://flask.palletsprojects.com/en/2.2.x/)
73
+ * [FLAMAPY](https://github.com/flamapy)
74
+ * [Flasgger](https://github.com/flasgger/flasgger)
75
+
76
+ <p align="right">(<a href="#top">back to top</a>)</p>
77
+
78
+ # Using the distribution REST API
79
+ The easies way is to execute the following command: docker run -p 8000:8000 flamapy/flamapy-fm-dist and open localhost:8000
80
+ <!-- GETTING STARTED -->
81
+ ## Getting Started
82
+
83
+ To get a local copy up and running follow these simple example steps.
84
+
85
+ First, you will need to install [Docker](https://docs.docker.com/desktop/).
86
+
87
+ ### Instalation
88
+
89
+ 1. Clone the repository
90
+
91
+ 2. If you are running Windows, run
92
+ ```sh
93
+ $ cd flamapy-dm-dist
94
+ $ ./start-server.cmd
95
+ ```
96
+
97
+ 3. If you are running Linux or MacOS, run
98
+ ```sh
99
+ $ cd flamapy-dm-dist
100
+ $ ./start-server.sh
101
+ ```
102
+
103
+ 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/)
104
+
105
+ <p align="right">(<a href="#top">back to top</a>)</p>
106
+
107
+ ### API Documentation
108
+
109
+ 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!
110
+
111
+ <p align="right">(<a href="#top">back to top</a>)</p>
112
+
113
+
@@ -0,0 +1,8 @@
1
+ README.md
2
+ setup.py
3
+ flamapy/interfaces/rest/operations_routes.py
4
+ flamapy_rest.egg-info/PKG-INFO
5
+ flamapy_rest.egg-info/SOURCES.txt
6
+ flamapy_rest.egg-info/dependency_links.txt
7
+ flamapy_rest.egg-info/requires.txt
8
+ flamapy_rest.egg-info/top_level.txt
@@ -0,0 +1,16 @@
1
+ wheel
2
+ Flask
3
+ gunicorn
4
+ flamapy==2.0.0
5
+ flask-swagger-ui
6
+ flask-restplus
7
+ pytest
8
+ flask_cors
9
+ flasgger
10
+
11
+ [dev]
12
+ pytest
13
+ pytest-mock
14
+ prospector
15
+ mypy
16
+ coverage
@@ -0,0 +1 @@
1
+ flamapy
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,37 @@
1
+ import setuptools
2
+
3
+
4
+ with open("README.md", "r") as fh:
5
+ long_description = fh.read()
6
+
7
+ def read_requirements(file):
8
+ with open(file, "r") as fh:
9
+ return fh.read().splitlines()
10
+
11
+ # Read requirements from the requirements.txt file
12
+ requirements = read_requirements("requirements.txt")
13
+
14
+ # Read development requirements from the dev-requirements.txt file
15
+ dev_requirements = read_requirements("requirements-dev.txt")
16
+
17
+ setuptools.setup(
18
+ name="flamapy-rest",
19
+ version="2.0.0",
20
+ author="Flamapy",
21
+ author_email="flamapy@us.es",
22
+ description="Flamapy feature model is a distribution of the flama framework containing all plugins required to analyze feature models. It also offers a richier API and a complete command line interface and documentation.",
23
+ long_description=long_description,
24
+ long_description_content_type="text/markdown",
25
+ url="https://github.com/flamapy/flamapy-feature-model",
26
+ packages=setuptools.find_namespace_packages(include=['flamapy.*']),
27
+ classifiers=[
28
+ "Programming Language :: Python :: 3",
29
+ "License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)",
30
+ "Operating System :: OS Independent",
31
+ ],
32
+ python_requires='>=3.9',
33
+ install_requires=requirements,
34
+ extras_require={
35
+ 'dev': dev_requirements
36
+ }
37
+ )