Skip to content

Commit

Permalink
fix: better error message for missing plugin args
Browse files Browse the repository at this point in the history
  • Loading branch information
johanneskoester committed Jan 23, 2024
1 parent c7c02a3 commit d233f4f
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions snakemake_interface_common/plugin_registry/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,23 @@ def register_cli_args(self, argparser):
settings.add_argument(*args, **kwargs)

def validate_settings(self, settings):
def get_description(thefield):
envvar = (
f" (or environment variable {self.get_envvar(thefield.name)})"
if thefield.metadata.get("env_var", None)
else ""
)
return f"{self.get_cli_arg(thefield.name)}{envvar}"

# rewrite for settings
missing = [
thefield.name
thefield
for thefield in fields(settings)
if thefield.metadata.get("required")
and getattr(settings, thefield.name) is None
]
if missing:
cli_args = [self.get_cli_arg(name) for name in missing]
cli_args = [get_description(thefield) for thefield in missing]
raise WorkflowError(
f"The following required arguments are missing for "
f"plugin {self.name}: {', '.join(cli_args)}."
Expand Down

0 comments on commit d233f4f

Please sign in to comment.