Skip to content

Allow spawner properties to be set by __setitem__ rather than setattr #115

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

Open
phil-brad opened this issue May 17, 2020 · 0 comments
Open

Comments

@phil-brad
Copy link
Member

Properties are set using setattr in the generate_tasks_from_spec function. There are a couple of downsides to this:

  • Cannot set non-alphanumeric properties. For example, one might want to pass alpha.beta to the spawner in order to set properties in multi-level input files.
  • There is no check on hasattr which means that if the property does not exist it just adds a Python property (see issue Task creation should fail if spawner doesn't have property #109). If we put a requirement on the property existing then this does not allow spawners to be dynamic in the sense that they must declare all the properties upfront.

Solution:
generate_tasks_from_spec takes two additional default argument getter and setter, which default to getattr and setattr respectively but could also be __getitem__ and __setitem__.

It might make sense to redesign this function into a callable TaskGenerator class.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant