diff --git a/src/snk_cli/config/config.py b/src/snk_cli/config/config.py index 5750b72..e515f4e 100644 --- a/src/snk_cli/config/config.py +++ b/src/snk_cli/config/config.py @@ -112,6 +112,14 @@ def from_path(cls, snk_config_path: Path): # TODO: remove conda_required in the future snk_config_dict["conda"] = snk_config_dict["conda_required"] del snk_config_dict["conda_required"] + # print warning about any invalid keys + fields = set(cls.__dict__["__dataclass_fields__"]) + invalid_config_keys = set(snk_config_dict.keys()) - fields + if invalid_config_keys: + import warnings + warnings.warn(f"invalid keys in `snk.yaml` file: {invalid_config_keys}.") + # filer out any invalid keys + snk_config_dict = {k: v for k, v in snk_config_dict.items() if k in fields} snk_config = cls(**snk_config_dict) snk_config.resources = [ snk_config_path.parent / resource for resource in snk_config.resources diff --git a/tests/data/workflow/snk.yaml b/tests/data/workflow/snk.yaml index 59648a3..304af70 100644 --- a/tests/data/workflow/snk.yaml +++ b/tests/data/workflow/snk.yaml @@ -1,4 +1,5 @@ art: null +invalid: false cli: hidden: hidden: true