Skip to content

Commit

Permalink
Merge pull request #10 from Open-EO/static_node_ids
Browse files Browse the repository at this point in the history
Static node ids
  • Loading branch information
claxn authored Mar 30, 2020
2 parents d5db442 + 4973316 commit ea9d84a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ MANIFEST

# Per-project virtualenvs
.venv*/

# folder including testing scripts
.scripts
8 changes: 4 additions & 4 deletions src/openeo_pg_parser_python/translate_process_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
from openeo_pg_parser_python.graph import Node, Edge, Graph


def walk_pg_graph(nodes, data, node_ids=None, level=0, prev_level=0):
def walk_pg_graph(nodes, data, node_ids=None, level=0, prev_level=0, node_counter=0):
for key, value in data.items():
if isinstance(value, dict):
if "process_id" in value.keys():
token = secrets.token_hex(nbytes=8)
node_id = "_".join([key, token])
node_id = "_".join([key, str(node_counter)])
node = Node(id=node_id, name=key, graph=value, edges=[])
if node_ids:
filtered_node_ids = [prev_node_id for prev_node_id in node_ids if prev_node_id]
Expand All @@ -34,8 +33,9 @@ def walk_pg_graph(nodes, data, node_ids=None, level=0, prev_level=0):
node_ids.append(node_id)
prev_level = level
level += 1
node_counter += 1
nodes, node_ids, level, prev_level = walk_pg_graph(nodes, value, node_ids=node_ids, level=level,
prev_level=prev_level)
prev_level=prev_level, node_counter=node_counter)

level += -1
if node_ids:
Expand Down

0 comments on commit ea9d84a

Please sign in to comment.