Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workflow constructor raises TypeError when input_spec is an instance of SpecInfo #572

Closed
NicolasGensollen opened this issue Sep 1, 2022 · 2 comments · Fixed by #573
Closed
Labels
bug Something isn't working

Comments

@NicolasGensollen
Copy link
Contributor

The documentation of the Workflow constructor says that input_spec can be a list of strings, a SpecInfo, or a BaseSpec instance:

input_spec: ty.Optional[ty.Union[ty.List[ty.Text], SpecInfo, BaseSpec]] = None,

However, when providing a SpecInfo I get a TypeError: unhashable type: 'SpecInfo'.

Looking at the code, it seems like this case isn't handled properly such that we end up iterating over the SpecInfo instance (line 860), triggering the error described above:

pydra/pydra/engine/core.py

Lines 843 to 863 in 219c721

if input_spec:
if isinstance(input_spec, BaseSpec):
self.input_spec = input_spec
else:
self.input_spec = SpecInfo(
name="Inputs",
fields=[("_graph_checksums", ty.Any)]
+ [
(
nm,
attr.ib(
type=ty.Any,
metadata={
"help_string": f"{nm} input from {name} workflow"
},
),
)
for nm in input_spec
],
bases=(BaseSpec,),
)

It could be that SpecInfo was supposed to inherit from BaseSpec, but it doesn't seem to be the case atm:

class SpecInfo:

@NicolasGensollen NicolasGensollen added the bug Something isn't working label Sep 1, 2022
@satra
Copy link
Contributor

satra commented Sep 1, 2022

@NicolasGensollen - this seems like an oversight and is a bug.

would you like to send a PR to resolve this ? i think the only specific check that would be needed is that the SpecInfo object has BaseSpec as it's bases, similar to the constructor here:

bases=(BaseSpec,),

@NicolasGensollen
Copy link
Contributor Author

@satra Sure I'll send a PR! Thanks for the quick reply ! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
2 participants