Skip to content

Commit

Permalink
Fixed named ports for app drops
Browse files Browse the repository at this point in the history
  • Loading branch information
awicenec committed Jun 3, 2022
1 parent d5665b4 commit 95a934d
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions daliuge-translator/dlg/dropmake/lg.py
Original file line number Diff line number Diff line change
Expand Up @@ -556,17 +556,24 @@ def _update_key_value_attributes(self, kwargs):
else:
kwargs[k_v[0]] = k_v[1]

def _getIdText(self, port="inputPorts", index=0):
def _getIdText(self, port="inputPorts", index=0, portId=None):
"""
Return IdText of port if it exists
"""
idText = None
if (
port in self.jd
and len(self.jd[port]) > index
and "IdText" in self.jd[port][index]
):
idText = self.jd[port][index]["IdText"]
if not portId:
if (
port in self.jd
and len(self.jd[port]) > index
and "IdText" in self.jd[port][index]
):
idText = self.jd[port][index]["IdText"]
else:
if (
port in self.jd
):
idText = [p["IdText"] for p in self.jd["inputPorts"]
if p["Id"] == portId][0]
return idText

def _create_test_drop_spec(self, oid, rank, kwargs) -> dropdict:
Expand Down Expand Up @@ -1314,9 +1321,10 @@ def _link_drops(self, slgn, tlgn, src_drop, tgt_drop, llink):
tdrop.addStreamingInput(dropSpec_null, IdText="stream")
self._drop_dict["new_added"].append(dropSpec_null)
elif s_type in APP_DROP_TYPES:
# target is data drop; get name of input port
# use name from source and ID from target
sIdText = tlgn._getIdText("outputPorts")
tIdText = tlgn._getIdText("inputPorts")
sdrop.addOutput(tdrop, IdText=tIdText)
sdrop.addOutput(tdrop, IdText=sIdText)
tdrop.addProducer(sdrop, IdText=tIdText)
if Categories.BASH_SHELL_APP == s_type:
bc = src_drop["command"]
Expand All @@ -1332,6 +1340,10 @@ def _link_drops(self, slgn, tlgn, src_drop, tgt_drop, llink):
else: # sdrop is a data drop
# there should be only one port, get the name
sIdText = slgn._getIdText("outputPorts")
# could be multiple ports, need to identify
portId = llink["toPort"] if "toPort" in llink else None
tIdText = tlgn._getIdText("inputPorts",
portId=portId)
if llink.get("is_stream", False):
logger.debug(
"link stream connection %s to %s", sdrop["oid"], tdrop["oid"]
Expand All @@ -1341,7 +1353,7 @@ def _link_drops(self, slgn, tlgn, src_drop, tgt_drop, llink):
else:
# print("not a stream from %s to %s" % (llink['from'], llink['to']))
sdrop.addConsumer(tdrop, IdText=sIdText)
tdrop.addInput(sdrop, IdText=sIdText)
tdrop.addInput(sdrop, IdText=tIdText)
if Categories.BASH_SHELL_APP == t_type:
bc = tgt_drop["command"]
bc.add_input_param(slgn.id, src_drop["oid"])
Expand Down

0 comments on commit 95a934d

Please sign in to comment.