Skip to content

Commit

Permalink
Fix model wrapping for clingraph input models
Browse files Browse the repository at this point in the history
Resolves: #78
  • Loading branch information
stephanzwicknagl committed May 1, 2024
1 parent 2e8dbcc commit 832620d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion backend/src/viasp/server/blueprints/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ def transform_relax():
def clingraph_generate():
if request.method == "POST":
marked_models = load_models()
marked_models = wrap_marked_models(marked_models)
marked_models = wrap_marked_models(marked_models, clingraph=True)
if request.json is None:
return "Invalid request", 400
viz_encoding = request.json[
Expand Down
8 changes: 6 additions & 2 deletions backend/src/viasp/server/blueprints/dag_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,14 +398,18 @@ def get_is_sortable():

def wrap_marked_models(
marked_models: Iterable[StableModel],
conflict_free_showTerm: str = "showTerm") -> List[List[str]]:
conflict_free_showTerm: str = "showTerm",
clingraph: bool = False) -> List[List[str]]:
result = []
for model in marked_models:
wrapped = []
for part in model.atoms:
wrapped.append(f"{part}.")
for part in model.terms:
wrapped.append(f"{conflict_free_showTerm}({part}).")
if clingraph:
wrapped.append(f"{part}.")
else:
wrapped.append(f"{conflict_free_showTerm}({part}).")
result.append(wrapped)
return result

Expand Down

0 comments on commit 832620d

Please sign in to comment.