customizers
Functions to customize workflow steps.
customize_funcs ¶
customize_funcs(
names: list[str] | str,
funcs: list[Callable] | Callable,
param_defaults: dict[str, dict[str, Any]] | None = None,
param_swaps: dict[str, dict[str, Any]] | None = None,
decorators: dict[str, Callable | None] | None = None,
) -> tuple[Callable, ...] | Callable
Customize a set of functions with decorators and common parameters.
Parameters:
-
names
(list[str] | str
) –The names of the functions to customize, in the order they should be returned.
-
funcs
(list[Callable] | Callable
) –The functions to customize, in the order they are described in
names
. -
param_defaults
(dict[str, dict[str, Any]] | None
, default:None
) –Default parameters to apply to each function. The keys of this dictionary correspond to the strings in
names
. If the key"all"
is present, it will be applied to all functions. If the value isNone
, no custom parameters will be applied to that function. -
param_swaps
(dict[str, dict[str, Any]] | None
, default:None
) –User-overrides of parameters to apply to each function. The keys of this dictionary correspond to the strings in
names
. If the key"all"
is present, it will be applied to all functions. If the value isNone
, no custom parameters will be applied to that function. -
decorators
(dict[str, Callable | None] | None
, default:None
) –Custom decorators to apply to each function. The keys of this dictionary correspond to the strings in
names
. If the key"all"
is present, it will be applied to all functions. If a value isNone
, no decorator will be applied that function.
Returns:
-
tuple[Callable, ...] | Callable
–The customized functions, returned in the same order as provided in
funcs
.
Source code in quacc/wflow_tools/customizers.py
redecorate ¶
Redecorate a pre-decorated function with a custom decorator.
Parameters:
-
func
(Callable
) –The pre-decorated function.
-
decorator
(Callable | None
) –The new decorator to apply. If
None
, the function is stripped of its decorators.
Returns:
-
Callable
–The newly decorated function.
Source code in quacc/wflow_tools/customizers.py
strip_decorator ¶
Strip the decorators from a function.
Parameters:
-
func
(Callable
) –The function to strip decorators from.
Returns:
-
Callable
–The function with all decorators removed.
Source code in quacc/wflow_tools/customizers.py
update_parameters ¶
update_parameters(
func: Callable,
params: dict[str, Any],
decorator: (
Literal["job", "flow", "subflow"] | None
) = "job",
) -> Callable
Update the parameters of a (potentially decorated) function.
Parameters:
-
func
(Callable
) –The function to update.
-
params
(dict[str, Any]
) –The parameters and associated values to update.
-
decorator
(Literal['job', 'flow', 'subflow'] | None
, default:'job'
) –The decorator associated with
func
.
Returns:
-
Callable
–The updated function.