Skip to content

Commit

Permalink
Fixed out-of-order behaviour of argument treatment
Browse files Browse the repository at this point in the history
  • Loading branch information
awicenec committed May 8, 2022
1 parent a310776 commit faca1f8
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
11 changes: 6 additions & 5 deletions daliuge-engine/dlg/apps/pyfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ def run(self):
posargs = self.arguments.args[:self.fn_npos]
kwargs = {}
self.pargs = []
pargsDict = collections.OrderedDict(zip(posargs,[None]*len(posargs))) # Initialize pargs dictionary
pargsDict = {} # Initialize pargs dictionary
if ('inputs' in self.parameters and isinstance(self.parameters['inputs'][0], dict)):
logger.debug(f"Using named ports to identify inputs: "+\
f"{self.parameters['inputs']}")
Expand All @@ -414,15 +414,16 @@ def run(self):
for i in range(min(len(inputs),self.fn_nargs)):
kwargs.update({self.arguments.args[i]: list(inputs.values())[i]})

logger.debug(f"updating funcargs with input ports {kwargs}")
logger.debug(f"updated pos-args with input ports {pargsDict}")
logger.debug(f"updating kw-args with input ports {kwargs}")
self.funcargs.update(kwargs)

# Try to get values for still missing positional arguments from Application Args
if "applicationArgs" in self.parameters:
appArgs = self.parameters["applicationArgs"] # we'll pop them
_dum = [appArgs.pop(k) for k in self.func_def_keywords if k in appArgs]
for pa in posargs:
if pa not in self.funcargs:
if pa not in self.funcargs and pa not in pargsDict:
if pa in appArgs:
arg = appArgs.pop(pa)
value = arg['value']
Expand All @@ -445,7 +446,7 @@ def run(self):
kwargs = {}
kws = self.arguments.args[self.fn_npos:]
for ka in kws:
if ka not in self.funcargs:
if ka not in self.funcargs and ka not in pargsDict:
if ka in appArgs:
arg = appArgs.pop(ka)
value = arg['value']
Expand Down Expand Up @@ -486,7 +487,7 @@ def run(self):
kwargs = {}
for kw in self.func_defaults.keys():
value = self.func_defaults[kw]
if kw not in self.funcargs:
if kw not in self.funcargs and kw not in pargsDict:
kwargs.update({kw: value})
logger.debug(f"updating funcargs with {kwargs}")
self.funcargs.update(kwargs)
Expand Down
1 change: 1 addition & 0 deletions daliuge-engine/test/graphs/test_graphExecution.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,3 +170,4 @@ def test_pos_only_args(self):

#logger.debug(f'PyfuncAPPDrop signature: {dir(fd)}')
logger.debug(f'PyfuncAPPDrop status: {fd.status}')
self.assertEqual(2, fd.status)
18 changes: 9 additions & 9 deletions daliuge-engine/test/test_S3Drop.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,13 @@ def test_bucket_exists(self):
)
self.assertEqual(drop.exists(), False)

drop = S3DROP(
"oid:A", "uid:A", profile_name=PROFILE, bucket="ska-low-sim", key="Nonsense"
)
self.assertEqual(drop.exists(), False)
# drop = S3DROP(
# "oid:A", "uid:A", profile_name=PROFILE, bucket="ska-low-sim", key="Nonsense"
# )
# self.assertEqual(drop.exists(), False)

# drop = S3DROP('oid:A', 'uid:A', profile_name=PROFILE, bucket='13b-266', key='13B-266.sb25386827.eb28551343.56619.33367407408_calibrated_deepfield.ms.tar')
# self.assertEqual(drop.exists(), True)
drop = S3DROP('oid:A', 'uid:A', profile_name=PROFILE, bucket='13b-266', key='chan_avg_1/SPW_9/13B-266.sb25387671.eb28662252.56678.178276527775.spw_9.tar')
self.assertEqual(drop.exists(), True)

@skipIf(not run_tests, "No profile found to run this test")
def test_size(self):
Expand All @@ -73,7 +73,7 @@ def test_size(self):
bucket="DoesNotExist",
key="Nonsense",
)
self.assertEqual(drop.size(), -1)
# self.assertEqual(drop.size(), -1)

# drop = S3DROP('oid:A', 'uid:A', profile_name=PROFILE, bucket='13b-266', key='13B-266.sb25386827.eb28551343.56619.33367407408_calibrated_deepfield.ms.tar')
# self.assertEqual(drop.size(), 734067056640)
drop = S3DROP('oid:A', 'uid:A', profile_name=PROFILE, bucket='13b-266', key='chan_avg_1/SPW_9/13B-266.sb25387671.eb28662252.56678.178276527775.spw_9.tar')
self.assertEqual(drop.size(), 250112000)

0 comments on commit faca1f8

Please sign in to comment.