nipype / pydra

Pydra Dataflow Engine
https://nipype.github.io/pydra/
Other
120 stars 59 forks source link

Allow workflows with no arguments #280

Open nicolocin opened 4 years ago

nicolocin commented 4 years ago

Ran into this when trying to debug #262. Not specifying input_spec returns a RecursionError and makes it hard to check for undefined variables in a workflow. Should input_spec be required at initialization?

Code

import pydra
wf=pydra.Workflow(name='wf')

Output

---------------------------------------------------------------------------
RecursionError                            Traceback (most recent call last)
<ipython-input-2-37069e33e098> in <module>
      1 import pydra
----> 2 wf=pydra.Workflow(name='wf')
      3 #wf.input_spec

~/Desktop/nlo/pydra/pydra/engine/core.py in __init__(self, name, audit_flags, cache_dir, cache_locations, input_spec, messenger_args, messengers, output_spec, rerun, propagate_rerun, **kwargs)
    709             messengers=messengers,
    710             messenger_args=messenger_args,
--> 711             rerun=rerun,
    712         )
    713 

~/Desktop/nlo/pydra/pydra/engine/core.py in __init__(self, name, audit_flags, cache_dir, cache_locations, inputs, messenger_args, messengers, rerun)
    128 
    129         self.name = name
--> 130         if not self.input_spec:
    131             raise ValueError("No input_spec in class: %s" % self.__class__.__name__)
    132         klass = make_klass(self.input_spec)

~/Desktop/nlo/pydra/pydra/engine/core.py in __getattr__(self, name)
    725         if name == "lzout":
    726             return super().__getattr__(name)
--> 727         if name in self.name2obj:
    728             return self.name2obj[name]
    729         return self.__getattribute__(name)

... last 1 frames repeated, from the frame below ...

~/Desktop/nlo/pydra/pydra/engine/core.py in __getattr__(self, name)
    725         if name == "lzout":
    726             return super().__getattr__(name)
--> 727         if name in self.name2obj:
    728             return self.name2obj[name]
    729         return self.__getattribute__(name)

RecursionError: maximum recursion depth exceeded in comparison
satra commented 4 years ago

@nicolocin - a workflow is a subclass of task, so an input spec is required for a workflow when created, but it can be a simple input spec of just names.

satra commented 4 years ago

more importantly though the error should be more direct and caught a lot earlier in the init process.

nicolocin commented 4 years ago

Ok gotcha. Currently None is a valid type for input_spec in the workflow class, once I change that this shouldn't be an issue

satra commented 4 years ago

so i can see how a workflow could have no input spec, let's say it generates, synthesizes data. so indeed, we should allow for this at some level. perhaps check examples of task with no input spec.