Skip to content

Commit

Permalink
Merge pull request #300 from ICRAR/LIU-392
Browse files Browse the repository at this point in the history
LIU-392: Enable per-port serailisation
  • Loading branch information
myxie authored Jan 29, 2025
2 parents 24cd5d5 + 4a08d80 commit 83d76e8
Show file tree
Hide file tree
Showing 22 changed files with 595 additions and 239 deletions.
28 changes: 28 additions & 0 deletions daliuge-common/dlg/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,14 @@ def __init__(self, init_dict=None):
def _addSomething(self, other, key, name=None):
if key not in self:
self[key] = []
# TODO: self[key] = {}; we want to move to dictionaries, not lists
if other["oid"] not in self[key]:
# TODO: Returning just the other drop OID instead of the named
# port list is not a good solution. Required for the dask
# tests.
append = {other["oid"]: name} if name else other["oid"]
# if name is None:
# TODO: self[key][other['oid']: name]
# raise ValueError
self[key].append(append)

Expand All @@ -114,6 +116,32 @@ def addOutput(self, other, name=None):
def addProducer(self, other, name=None):
self._addSomething(other, "producers", name=name)

def _hasSomething(self, key, name):
"""
self[key] => [{oidA: nameA}, {oidB:nameB}]
Need to translate to ["nameA", "nameB"] to determine if we have that element
"""
if key not in self:
return False
ports = []
[ports.extend(pair.values()) for pair in self[key]]
return name in ports

def hasOutput(self, output):
"""
self["outputs"] => [{"oidA": "portnameA"}, {"oidB":"portnameB"}]
Translate to ["portnameA", "portnameB"]
"""
return self._hasSomething("outputs", output)

def hasProducer(self, producer):
"""
See hasOutput.
"""
return self._hasSomething("producers", producer)

def __ge__(self, other):
return self.get("oid") >= other.get("oid")

Expand Down
Loading

0 comments on commit 83d76e8

Please sign in to comment.