Skip to content

Commit

Permalink
Added missing kwonlyargs treatment
Browse files Browse the repository at this point in the history
  • Loading branch information
awicenec committed Jun 10, 2022
1 parent 4093142 commit 3cbe6b4
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion daliuge-engine/dlg/apps/pyfunc.py
Original file line number Diff line number Diff line change
Expand Up @@ -531,6 +531,31 @@ def optionalEval(x):
logger.warning(f"Keyword argument '{ka}' not found!")
logger.debug(f"updating funcargs with {kwargs}")
self.funcargs.update(kwargs)

# deal with kwonlyargs
kwargs = {}
kws = self.arguments.kwonlyargs
for ka in kws:
if ka not in self.funcargs:
if ka in appArgs:
arg = appArgs.pop(ka)
value = arg['value']
ptype = arg['type']
if ptype in ["Complex", "Json"]:
try:
value = ast.literal_eval(value)
except:
pass
kwargs.update({
ka:
value
})
else:
logger.warning(f"Keyword only argument '{ka}' not found!")
logger.debug(f"updating funcargs with kwonlyargs: {kwargs}")
self.funcargs.update(kwargs)

# any remaining application arguments will be used for vargs and vkwargs
vparg = []
vkarg = {}
logger.debug(f"Remaining AppArguments {appArgs}")
Expand All @@ -544,7 +569,6 @@ def optionalEval(x):
else:
vkarg.update({arg:value})

# any remaining application arguments will be used for vargs and vkwargs
if self.arguments.varargs:
self.pargs.extend(vparg)
if self.arguments.varkw:
Expand Down

0 comments on commit 3cbe6b4

Please sign in to comment.