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

Make to_aiida_type the default serializer for WorkChains and Calcjobs #5890

Closed
danielhollas opened this issue Feb 13, 2023 · 0 comments · Fixed by #6439
Closed

Make to_aiida_type the default serializer for WorkChains and Calcjobs #5890

danielhollas opened this issue Feb 13, 2023 · 0 comments · Fixed by #6439
Labels
type/feature request status undecided

Comments

@danielhollas
Copy link
Collaborator

Is your feature request related to a problem? Please describe

In #5688, rekeased in AiiDA 2.1, to_aiida_type was added as the default serializer for calcfunctions and workfunctions.
It would be very useful to add the same functionality for WorkChains and CalcJobs to reduce the boilerplate.
Especially useful for beginner plugin developers.

Describe the solution you'd like

Input ports that have the corresponding Python base types (Bool, Int, Dict, Float...) would be automatically serialized for all CalcJobs and WorkChains, even even the serializer is not explictly defined.

Describe alternatives you've considered

Status quo, where to_aiida_type serialized must be explicitly set for all input ports where it applies.

Additional context

Here are initial thoughts about implementation details from @sphuber

Not sure if this would be possible. The spec is defined by the subclass, which calls the super before it defines its own ports. So the base class won't get to intervene and automatically add the serializer to those ports. Not sure where to hook in to correct the port declarations.

Or we should override the __setitem__ method of the PortNamespace class to set the serializer by default depending on the valid type. Could open an issue on aiida-core to flesh the idea out a bit more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type/feature request status undecided
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant