Skip to content

Commit

Permalink
LIU-385: Add support for SubGraphs in translator
Browse files Browse the repository at this point in the history
This supports SubGraphs with no InputApps, which functionally ignores the entire SubGraph construct.
  • Loading branch information
myxie committed May 31, 2024
1 parent 7e2b744 commit caa24e3
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions daliuge-translator/dlg/dropmake/definition_classes.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ class Categories:
GROUP_BY = "GroupBy"
LOOP = "Loop"
VARIABLES = "Variables"
SUBGRAPH = "SubGraph"

BRANCH = "Branch"
DATA = "Data"
Expand Down Expand Up @@ -106,6 +107,7 @@ class Categories:
Categories.LOOP,
Categories.MKN,
Categories.SERVICE,
Categories.SUBGRAPH
]


Expand All @@ -117,3 +119,4 @@ class ConstructTypes:
LOOP = Categories.LOOP
MKN = Categories.MKN
SERVICE = Categories.SERVICE
SUBGRAPH = Categories.SUBGRAPH
6 changes: 6 additions & 0 deletions daliuge-translator/dlg/dropmake/dm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -467,6 +467,7 @@ def convert_construct(lgo):
ConstructTypes.SCATTER,
ConstructTypes.GATHER,
ConstructTypes.SERVICE,
ConstructTypes.SUBGRAPH
]:
continue
has_app = None
Expand All @@ -482,6 +483,8 @@ def convert_construct(lgo):
has_app = ak
break
if has_app is None:
if node["category"] == ConstructTypes.SUBGRAPH:
node["hasInputApp"] = False
continue
# step 1
app_node = dict()
Expand Down Expand Up @@ -514,6 +517,9 @@ def convert_construct(lgo):
if node["category"] == ConstructTypes.SERVICE:
app_node["isService"] = True

if node["category"] == ConstructTypes.SUBGRAPH:
app_node["hasInputApp"] = True

new_nodes.append(app_node)

# step 2
Expand Down
9 changes: 9 additions & 0 deletions daliuge-translator/dlg/dropmake/lg.py
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,8 @@ def lgn_to_pgn(self, lgn, iid="0", lpcxt=None):
elif lgn.is_service:
# no action required, inputapp node aleady created and marked with "isService"
pass
elif lgn.is_subgraph:
pass
else:
src_drop = lgn.make_single_drop(iid, loop_ctx=lpcxt)
self._drop_dict[lgn.id].append(src_drop)
Expand Down Expand Up @@ -772,6 +774,9 @@ def unroll_to_tpl(self):
# per compute instance
tlgn["categoryType"] = "Application"
tlgn["category"] = "PythonApp"
elif tlgn.is_subgraph:
# TODO LIU-385: Add behaviour for when we have an SubGraphInputApp
pass
else:
raise GraphException(
"Unsupported target group {0}".format(tlgn.jd.category)
Expand Down Expand Up @@ -827,6 +832,10 @@ def unroll_to_tpl(self):
# for sl_drop in self._drop_dict[lid]:
# if 'gather-data_drop' in sl_drop:
# del sl_drop['gather-data_drop']
elif lgn.is_subgraph:
if not lgn.jd['hasInputApp']:
del self._drop_dict[lid]
# TODO LIU-385: Add support for SubGraphs with InputApps

logger.info(
"Unroll progress - extra drops done for session %s",
Expand Down
6 changes: 6 additions & 0 deletions daliuge-translator/dlg/dropmake/lg_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,10 @@ def is_branch(self):
def is_mpi(self):
return self._jd["category"] == Categories.MPI

@property
def is_subgraph(self):
return self._jd["category"] == Categories.SUBGRAPH

@property
def group_keys(self):
"""
Expand Down Expand Up @@ -702,6 +706,8 @@ def dop(self):
break
elif self.is_service:
self._dop = 1 # TODO: number of compute nodes
elif self.is_subgraph:
self._dop = 1
else:
raise GInvalidNode(
"Unrecognised (Group) Logical Graph Node: '{0}'".format(
Expand Down

0 comments on commit caa24e3

Please sign in to comment.