Skip to content

Commit

Permalink
Adapt ast_types to clingo version used
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanzwicknagl committed May 2, 2024
1 parent 832620d commit 2e92aad
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
9 changes: 8 additions & 1 deletion backend/src/viasp/asp/ast_types.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import clingo
from clingo.ast import ASTType
from pkg_resources import parse_version

SUPPORTED_TYPES = {
ASTType.Comparison, ASTType.Aggregate, ASTType.Rule, ASTType.Program,
Expand All @@ -11,9 +13,14 @@
ASTType.Interval, ASTType.UnaryOperation, ASTType.BinaryOperation,
ASTType.Defined, ASTType.External, ASTType.ProjectAtom,
ASTType.ProjectSignature, ASTType.ShowTerm, ASTType.Minimize,
ASTType.Script, ASTType.Comment
ASTType.Script
}

if parse_version(clingo.__version__) >= parse_version("5.7.0"):
SUPPORTED_TYPES.update({
ASTType.Comment
})

UNSUPPORTED_TYPES = {
ASTType.Disjunction,
}
Expand Down
4 changes: 0 additions & 4 deletions backend/src/viasp/asp/justify.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,10 +258,6 @@ def get_recursion_subgraph(
pad=False,
supernode_symbols=supernode_symbols)
h_syms.sort(key=lambda node: node.rule_nr)
# h_syms.insert(0, Node(frozenset(facts), -1))
insert_atoms_into_nodes(h_syms)

# reasoning_subgraph = nx.DiGraph()
# for a, b in pairwise(h_syms[1:]):
# reasoning_subgraph.add_edge(a, b)
return h_syms
2 changes: 2 additions & 0 deletions backend/src/viasp/asp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ def remove_loops(g: nx.DiGraph) -> Tuple[nx.DiGraph, FrozenSet[RuleContainer]]:


def insert_atoms_into_nodes(path: List[Node]) -> None:
if not path:
return
facts = path[0]
state = set(facts.diff)
facts.atoms = frozenset(state)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
clingo==5.6.1
clingo>=5.6.0
flask>=2.2.0
networkx>=2.6
pytest>=6.2.4
Expand Down

0 comments on commit 2e92aad

Please sign in to comment.