2. Usage
Usage
To use flamapy, any user can assume different roles. In this page, we organize the content by them. For the flamapy installation, follow Installation guide
As an end user
As an end user you might be interested on executing your analysis either from the command line or from your python script.
From the command line.
The execution from the command line is very straigt forward. We rely on the Flamapy cli interface.
$flamapy-admin cli use_operation_from_file Valid <Path to file>
There are some analysis operations that require to pass a predefine configuration. More information on how to define such files in TODO. Please note that the extension of files should be csvconf
$flamapy-admin cli use_operation_from_file --configuration_file <path to csv file>.csvconf ValidProduct <path to model file>
For example:
$flamapy-admin cli use_operation_from_file --configuration_file ../test/test.csvconf ValidProduct ../test/output.uvl
From a user python script.
To execute a simple operation in our script we should import the module and simply call the operation. For example
from flamapy.core.discover import DiscoverMetamodels # This loads the tool in the python execution environment
dm = DiscoverMetamodels() # Instantiate the class
result = dm.use_operation_from_file(operation, filename) # This launch the operation and stores the result on the result variable
print(result) # to print the result
Then you can printout the result or perform any other operation on it.
In case of executing an operation that requires optional paramenters:
from flamapy.core.discover import DiscoverMetamodels # This loads the tool in the python execution environment
dm = DiscoverMetamodels() # Instantiate the class
result = dm.use_operation_from_file(operation, filename, configuration_file) # This launch the operation and stores the result on the result variable
print(result) # to print the result
For example:
from flamapy.core.discover import DiscoverMetamodels # This loads the tool in the python execution environment
dm = DiscoverMetamodels() # Instantiate the class
result = dm.use_operation_from_file('Valid', './test.uvl', './test.csvconf') # This launch the operation and stores the result on the result variable
print(result) # to print the result
More information on how to define such files in TODO. Please note that the extension of configuration files should be csvconf
As a developer
As a developer you might be interested on using a rest api to consume or analyze your feature models. For that, make sure that you have installed the plugins using pip and simple start a REST API SERVER as showin in the following instructions.
Command line CLI and HTTP API
We rely on the Hug library to expose an API to consume flamapy
To execute the API you need to:
$git clone https://github.com/flamapy/core.git
Then, cd into the core directory containing all the source files and exec the following commands
hug -f flamapy/endpoint/diverso_lab.py # mount the endpoint in port 8000
# Doc: hug generate doc in json when you access to no exist endpoint
http://localhost:8000/example/
# Example
http://localhost:8000/v1/get-plugins/
http://localhost:8000/v1/get-operations/pysat_metamodel/
http://localhost:8000/v1/use-operation-from-file/Valid/test.xml