Skip to content

Commit

Permalink
✨ ignore addtional values in snk config
Browse files Browse the repository at this point in the history
  • Loading branch information
Wytamma committed Nov 17, 2024
1 parent e6430f3 commit fcedc71
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/snk_cli/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions tests/data/workflow/snk.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
art: null
invalid: false
cli:
hidden:
hidden: true
Expand Down

0 comments on commit fcedc71

Please sign in to comment.