Skip to content

Commit

Permalink
fix: Fix bug in validate FLAMA Feature Model (endpoint)
Browse files Browse the repository at this point in the history
  • Loading branch information
drorganvidez committed Sep 30, 2024
1 parent cbfee90 commit c1349b2
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 14 deletions.
7 changes: 6 additions & 1 deletion app/modules/dataset/templates/dataset/view_dataset.html
Original file line number Diff line number Diff line change
Expand Up @@ -285,8 +285,13 @@ <h4 style="margin-bottom: 0px;"><span class="badge bg-dark">{{ dataset.get_files
<br>
<small class="text-muted">({{ file.get_formatted_size() }})</small>
</div>
<div class="col-2">

</div>

<div class="row" style="word-wrap: break-word;">
<div class="col-12">
<div id="check_{{ file.id }}">

</div>
</div>
</div>
Expand Down
16 changes: 12 additions & 4 deletions app/modules/flamapy/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
from app.modules.flamapy import flamapy_bp
from flamapy.metamodels.fm_metamodel.transformations import UVLReader, GlencoeWriter, SPLOTWriter
from flamapy.metamodels.pysat_metamodel.transformations import FmToPysat, DimacsWriter
from flamapy.interfaces.python.flamapy_feature_model import FLAMAFeatureModel
from flamapy.core.exceptions import FlamaException
import tempfile
import os

Expand Down Expand Up @@ -52,20 +54,26 @@ def syntaxError(self, recognizer, offendingSymbol, line, column, msg, e):
parser.removeErrorListeners()
parser.addErrorListener(error_listener)

# Optional: Commented out for now
# tree = parser.featureModel()

if error_listener.errors:
return jsonify({"errors": error_listener.errors}), 400

# Optional: Print the parse tree
# print(tree.toStringTree(recog=parser))
# After parsing, try transforming the model
try:
# Assuming some logic here like loading and validating the model
# This part should contain your logic for using the Flamapy transformation
model = FLAMAFeatureModel(hubfile.get_path()) # Example usage
# You can optionally print or process the model here
return jsonify({"message": "Valid Model"}), 200

return jsonify({"message": "Valid Model"}), 200
except FlamaException as fe:
return jsonify({"error": f"Model transformation failed: {str(fe)}"}), 400

except Exception as e:
return jsonify({"error": str(e)}), 500


@flamapy_bp.route('/flamapy/valid/<int:file_id>', methods=['GET'])
def valid(file_id):
return jsonify({"success": True, "file_id": file_id})
Expand Down
14 changes: 13 additions & 1 deletion app/static/css/own.css
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,30 @@
color: white;
padding: 5px;
border-radius: 3px;
max-width: 100%;
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
}

.badge-danger {
background-color: red;
color: white;
padding: 5px;
border-radius: 3px;
max-width: 100%;
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
}

.badge-warning {
background-color: orange;
color: white;
padding: 5px;
border-radius: 3px;
}
max-width: 100%;
display: inline-block;
overflow: hidden;
text-overflow: ellipsis;
}
16 changes: 8 additions & 8 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ click==8.1.7
ConfigArgParse==1.7
coverage==7.6.0
cryptography==42.0.8
dd==0.6.0
dd==0.5.7
dnspython==2.6.1
docker==7.1.0
email_validator==2.2.0
Faker==26.0.0
flake8==7.1.0
flamapy==2.0.0.dev1
flamapy-bdd==2.0.0.dev1
flamapy-fm==2.0.0.dev1
flamapy-fw==2.0.0.dev1
flamapy-sat==2.0.0.dev1
flamapy==2.0.1
flamapy-bdd==2.0.1
flamapy-fm==2.0.1
flamapy-fw==2.0.1
flamapy-sat==2.0.1
Flask==3.0.3
Flask-Cors==4.0.1
Flask-Login==0.6.3
Expand Down Expand Up @@ -78,7 +78,7 @@ pytest==8.2.2
pytest-cov==5.0.0
python-dateutil==2.9.0.post0
python-dotenv==1.0.1
python-sat==1.8.dev13
python-sat==0.1.8.dev17
pytz==2024.1
pyzmq==26.0.3
redis==5.0.7
Expand Down Expand Up @@ -106,4 +106,4 @@ wsproto==1.2.0
WTForms==3.1.2
zope.event==5.0
zope.interface==6.4.post2
zstandard==0.22.0
zstandard==0.22.0

0 comments on commit c1349b2

Please sign in to comment.