Skip to content

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

@phil-brad

Description

@phil-brad

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions