Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixes #284 #285

Merged
merged 3 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions scabha/configuratt/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
13 changes: 7 additions & 6 deletions stimela/commands/doc.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand All @@ -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:
Expand All @@ -132,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)
Expand Down
28 changes: 17 additions & 11 deletions stimela/kitchen/recipe.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you leaving this here for posterity?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For a bit, yes. Want to revisit this after a bit so rather leave my thoughts in.

# 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
Expand All @@ -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:
Expand Down
Loading