Commits

Rui Xue authored 3af6e63dbde
PIPE-1514: remove 'self' as the first optional argument name for casa tasks.
No tags

pipeline/infrastructure/jobrequest.py

Modified
185 185 # the next piece of code does some introspection on the given function
186 186 # so that we can find out the complete invocation, adding any implicit
187 187 # or defaulted argument values to those arguments explicitly given. We
188 188 # use this information if execute(verbose=True) is specified.
189 189
190 190 # get the argument names and default argument values for the given
191 191 # function
192 192 code = fn.__code__
193 193 argcount = code.co_argcount
194 194 argnames = code.co_varnames[:argcount]
195 +
196 + if is_casa_task and argnames[0] == 'self':
197 + # PIPE-1514: remove 'self' if it's the first arg name obtained from the 'co_varnames' attribute of
198 + # Python code object, which is the case for CASA (ver6) tasks.
199 + argnames = argnames[1:]
200 +
195 201 fn_defaults = fn.__defaults__ or list()
196 202 argdefs = dict(zip(argnames[-len(fn_defaults):], fn_defaults))
197 203
198 204 # remove arguments that are not expected by the function, such as
199 205 # pipeline variables that the CASA task is not expecting.
200 206 unexpected_kw = [k for k, v in kw.items() if k not in argnames]
201 207 if unexpected_kw:
202 208 LOG.warning('Removing unexpected keywords from JobRequest: {!s}'.format(unexpected_kw))
203 209 for key in unexpected_kw:
204 210 kw.pop(key)

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut