diff --git a/snappy_pipeline/models/__init__.py b/snappy_pipeline/models/__init__.py index 6522e046b..79f91a925 100644 --- a/snappy_pipeline/models/__init__.py +++ b/snappy_pipeline/models/__init__.py @@ -67,6 +67,12 @@ def get(self, key: str, default: typing.Any = None) -> typing.Any: """ return getattr(self, key, default) + def __getitem__(self, item: str) -> typing.Any: + """ + Return the value of the field with the given key. + Raise an AttributeError if the field doesn't exist. + """ + return getattr(self, item) # This exists to distinguish workflow step_config models from other snappy specific models # It also provides a default_config_yaml_string method that includes the step_config section