PYME.recipes.recipe module¶
- class PYME.recipes.recipe.Recipe(*args, **kwargs)¶
Bases:
HasTraits
- add_module(module)¶
- add_modules_and_execute(modules, rollback_on_failure=True)¶
Adds modules to the recipe and then execute the recipe. Added to make UI interaction in PYMEVis a bit nicer when modules added from the menu fail, this function gives the option (enabled by default) of rolling back the additions should execute fail.
- Parameters
- moduleslist
a list of modules to add
- rollback_on_failurebool
rollback and remove modules (and their outputs) if .execute() fails
- clear()¶
- dependancyGraph()¶
- downstream_outputs(keys)¶
- execute(progress_callback=None, **kwargs)¶
Execute the recipe. Recipe execution is lazy / incremental in that modules will only be executed if their outputs are no longer in the namespace or their inputs have changed.
- Parameters
- progress_callbacka function, progress_callback(recipe, module)
This function is called after the successful execution of each module in the recipe. To abort the recipe, an exception may be raised in progress_callback.
- kwargsany values to set in the recipe namespace prior to executing.
- Returns
- outputthe value of the ‘output’ variable in the namespace if present, otherwise none. output is only used in
dh5view and ignored in recipe batch processing. It might well disappear completely in the future.
- execute_on_invalidation = <PYME.misc.mock_traits.CStr object>¶
- property file_inputs¶
- classmethod fromJSON(data)¶
- classmethod fromMD(md)¶
- classmethod fromYAML(data)¶
- gather_outputs(context={})¶
Find all OutputModule instances and call their generate methods with the recipe context
- Parameters
- contextdict
A context dictionary used to substitute and create variable names.
- get_cleaned_module_list()¶
- property inputs¶
- invalidate_data()¶
- layout()¶
Added as a visualisation aid for the web-based recipe editor. Very much a work in progress and not guaranteed to remain in it’s current form.
TODO - does this logic belong here???? TODO - rename?? (potentially make it webui specific)??? TODO - potential issues on Py3 with how jigna treats namedtuple?
- loadInput(filename, key='input', metadata_defaults={})¶
Load input data from a file and inject into namespace
- property module_outputs¶
- modules = <PYME.misc.mock_traits.List object>¶
- new_output_name(stub)¶
- property outputs¶
- property pipeline_view¶
- prune_dependencies_from_namespace(keys_to_prune, keep_passed_keys=False)¶
- resolveDependencies()¶
- reverseDependancyGraph()¶
- save(context={})¶
Find all OutputModule instances and call their save methods with the recipe context
- Parameters
- contextdict
A context dictionary used to substitute and create variable names.
- save_yaml(uri)¶
Save the recipe text to .yaml using the cluster-aware unified IO library
WARNING: Experimental - this was added as a quick hack to get web-based recipe editing working, and WILL LIKELY BE REMOVED without deprecation once that moves to using a recipe-manager. Whilst arguably the least contentious of the web-editor additions, it is unclear whether the saving logic (past dumping to YAML in the toYAML() method) should reside within the recipe itself. As the recipe class is proxied into the browser, there are also potential security implications here, particularly as this accepts both filenames and clusterURIs. As a consequence, saving should probably be factored out into something which can operate in an appropriate sandbox (the other option is to sandbox unifiedIO).
- Parameters
- uri: str
A filename or PYME-CLUSTER:// URI
- toJSON()¶
- toYAML()¶
- to_html(show_progress=True, show_errors=True)¶
- to_svg()¶
- update_from_file(filename)¶
Update the contents of the recipe from a .yaml file
WARNING: This function will likely be REMOVED WITHOUT NOTICE. It is a quick hack to get the prototype web-based recipe editor working, but will be surplus to requirements once we have a proper recipe manager in the web based editor. It’s logically obtuse to consider something the same recipe once you’ve completely replaced it with a recipe that has been loaded from file. It is much more sensible to create a new recipe instance when loading a recipe from file, and this is the recommended approach.
- Parameters
- filename: str
filename or PYME-CLUSTER:// URI
- update_from_yaml(data)¶
Update from a yaml formatted recipe description
- Parameters
- data: str
either yaml formatted text, or the path to a yaml file.
- Returns
- None
- upstream_inputs(keys)¶
- exception PYME.recipes.recipe.RecipeError¶
Bases:
Exception
- exception PYME.recipes.recipe.RecipeExecutionError(msg, recipe=None)¶
Bases:
RecipeError
- exception PYME.recipes.recipe.RecipeModuleNotFoundError¶
Bases:
RecipeError