From a1b3984ffef7d6897b5a1786b5b86a2d7ea2ad90 Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Tue, 30 Apr 2024 11:30:30 +0200 Subject: [PATCH 1/3] fixes #284 --- stimela/kitchen/recipe.py | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/stimela/kitchen/recipe.py b/stimela/kitchen/recipe.py index 1fe4906..9deaf1f 100644 --- a/stimela/kitchen/recipe.py +++ b/stimela/kitchen/recipe.py @@ -563,13 +563,27 @@ def _add_alias(self, alias_name: str, alias_target: Union[str, Tuple], # define schema based on copy of the target, but preserve default io[alias_name] = copy.copy(schema) alias_schema = io[alias_name] - # check that - # default set from own schema, ignoring parameter setting + # if default set in recipe schema, ignore any parameter setting in the step if orig_schema is not None and orig_schema.default is not UNSET: - # also clear parameter setting to propagate our default if step_param_name in step.params: del step.params[step_param_name] alias_schema.default = orig_schema.default + # else check if explicit value or a default is specified in the step -- make it the recipe default + else: + if step_param_name in step.params: + defval = step.params[step_param_name] + elif step_param_name in step.cargo.defaults: + defval = step.cargo.defaults[step_param_name] + else: + defval = schema.default + if defval is not UNSET: + alias_schema.required = False + alias_schema.default = defval + ## see https://github.com/caracal-pipeline/stimela/issues/284. No longer convinced + ## these parameters should be marked as Hidden. After all, the recipe explicitly specifies them! + ## mark it as hidden -- no need to expose parameters that are internally set this way + # alias_schema.category = ParameterCategory.Hidden + # propagate info from recipe schema if orig_schema and orig_schema.info: alias_schema.info = orig_schema.info # required flag overrides, if set from our own schema @@ -580,14 +594,6 @@ def _add_alias(self, alias_name: str, alias_target: Union[str, Tuple], alias_schema.category = category elif orig_schema is not None and orig_schema.category is not None: alias_schema.category = orig_schema.category - # parameter is not required if alias target is set in step - if step_param_name in step.params or \ - step_param_name in step.cargo.defaults or \ - schema.default is not UNSET: - alias_schema.required = False - alias_schema.default = UNSET - # mark it as hidden -- no need to expose parameters that are internally set this way - alias_schema.category = ParameterCategory.Hidden # if step parameter is implicit, mark the alias as implicit. Note that this only applies to outputs if schema.implicit: From a2de44e51604af41efee01c90116ce6c7332f823 Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Tue, 30 Apr 2024 12:28:33 +0200 Subject: [PATCH 2/3] fixes #286 --- scabha/configuratt/deps.py | 6 +++--- stimela/commands/doc.py | 9 +++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/scabha/configuratt/deps.py b/scabha/configuratt/deps.py index 1986c78..81191cd 100644 --- a/scabha/configuratt/deps.py +++ b/scabha/configuratt/deps.py @@ -15,9 +15,9 @@ @dataclass class FailRecord(object): filename: str - origin: Optional[str] - modulename: Optional[str] - fname: Optional[str] + origin: Optional[str] = None + modulename: Optional[str] = None + fname: Optional[str] = None @dataclass class RequirementRecord(object): diff --git a/stimela/commands/doc.py b/stimela/commands/doc.py index 7f35249..b634b7c 100644 --- a/stimela/commands/doc.py +++ b/stimela/commands/doc.py @@ -82,7 +82,7 @@ def load_recipe(name: str, section: Dict): # load config and recipes from all given files if files_to_load: - load_recipe_files(files_to_load) + top_level_recipes = load_recipe_files(files_to_load) destroy_progress_bar() @@ -109,9 +109,10 @@ def load_recipe(name: str, section: Dict): # if nothing was specified, and only one cab/only one recipe is defined, print that if not names_to_document: - if len(stimela.CONFIG.lib.recipes) == 1 and not stimela.CONFIG.cabs: - recipes_to_document.update(stimela.CONFIG.lib.recipes.keys()) - elif len(stimela.CONFIG.cabs) == 1 and not stimela.CONFIG.lib.recipes: + if len(top_level_recipes) == 1: + recipes_to_document.update(top_level_recipes) + log.info("a single top-level recipe is defined, documenting it by default. Use -l to list all defined recipes/cabs") + elif len(stimela.CONFIG.cabs) == 1 and not top_level_recipes: cabs_to_document.update(stimela.CONFIG.cabs.keys()) if recipes_to_document or cabs_to_document: From cc73754e5430ff51b7dbfac9d8b0c2e480ac1907 Mon Sep 17 00:00:00 2001 From: Oleg Smirnov Date: Tue, 30 Apr 2024 12:30:21 +0200 Subject: [PATCH 3/3] fixes #283 --- stimela/commands/doc.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stimela/commands/doc.py b/stimela/commands/doc.py index b634b7c..363c346 100644 --- a/stimela/commands/doc.py +++ b/stimela/commands/doc.py @@ -133,14 +133,14 @@ def load_recipe(name: str, section: Dict): subtree = top_tree.add("Recipes:") table = Table.grid("", "", padding=(0,2)) for name, recipe in stimela.CONFIG.lib.recipes.items(): - table.add_row(f"[bold]{name}[/bold]", recipe.info) + table.add_row(f"[bold]{name}[/bold]", getattr(recipe, 'info', '')) subtree.add(table) if stimela.CONFIG.cabs: subtree = top_tree.add("Cabs:") table = Table.grid("", "", padding=(0,2)) for name, cab in stimela.CONFIG.cabs.items(): - table.add_row(f"[bold]{name}[/bold]", cab.info) + table.add_row(f"[bold]{name}[/bold]", getattr(cab, 'info', '')) subtree.add(table) rich_print(top_tree)