Lattice
@covalent.lattice(_func=None, *, backend=None, executor=None, workflow_executor=None, deps_bash=None, deps_pip=None, call_before=[], call_after=[], triggers=None)
Lattice decorator to be called upon a function. Returns a new Lattice <covalent._workflow.lattice.Lattice> object.
PARAMETERS
_func (Optional
[Callable
]) – function to be decorated
KEYWORD ARGUMENTS
- backend – DEPRECATED: Same as executor.
- executor – Alternative executor object to be used in the execution of each node. If not passed, the local executor is used by default..
- workflow_executor – Executor for postprocessing the workflow. Defaults to the built-in dask executor or the local executor depending on whether Covalent is started with the –no-cluster.
- deps_bash – An optional DepsBash object specifying a list of shell commands to run before _func.
- deps_pip – An optional DepsPip object specifying a list of PyPI packages to install before running _func.
- call_before – An optional list of DepsCall objects specifying python functions to invoke before the electron
- call_after – An optional list of DepsCall objects specifying python functions to invoke after the electron
- triggers – Any triggers that need to be attached to this lattice, default is None
RETURNS
Lattice object inside which the decorated function exists.
RETURN TYPE
class covalent._workflow.lattice.Lattice(workflow_function, transport_graph=None) [source]
A lattice workflow object that holds the work flow graph and is returned by lattice
decorator.
workflow_function
The workflow function that is decorated by lattice
decorator.
transport_graph
The transport graph which will be the basis on how the workflow is executed.
metadata
Dictionary of metadata of the lattice.
post_processing
post_processing
kwargs
Keyword arguments passed to the workflow function.
electron_outputs
Dictionary of electron outputs received after workflow execution.
Methods:
build_graph(*args, **kwargs) | Builds the transport graph for the lattice by executing the workflow function which will trigger the call of all underlying electrons and they will get added to the transport graph for later execution. |
dispatch(*args, **kwargs) | DEPRECATED: Function to dispatch workflows. |
dispatch_sync(*args, **kwargs) | DEPRECATED: Function to dispatch workflows synchronously by waiting for the result too. |
draw(*args, **kwargs) | Generate lattice graph and display in UI taking into account passed in arguments. |
get_metadata(name) | Get value of the metadata of given name. |
set_metadata(name, value) | Function to add/edit metadata of given name and value to lattice’s metadata. |
build_graph(*args, **kwargs)[source]
Builds the transport graph for the lattice by executing the workflow function which will trigger the call of all underlying electrons and they will get added to the transport graph for later execution.
Also redirects any print statements inside the lattice function to null and ignores any exceptions caused while executing the function.
GRAPH WILL NOT BE BUILT AFTER AN EXCEPTION HAS OCCURRED.
PARAMETERS
- *args – Positional arguments to be passed to the workflow function.
- **kwargs – Keyword arguments to be passed to the workflow function.
RETURN TYPE
None
RETURNS
None
dispatch(*args, **kwargs)[source]
DEPRECATED: Function to dispatch workflows.
PARAMETERS
- *args – Positional arguments for the workflow
- **kwargs – Keyword arguments for the workflow
RETURN TYPE
str
RETURNS
Dispatch id assigned to job
dispatch_sync(*args, **kwargs)[source]
DEPRECATED: Function to dispatch workflows synchronously by waiting for the result too.
PARAMETERS
- *args – Positional arguments for the workflow
- **kwargs – Keyword arguments for the workflow
RETURN TYPE
RETURNS
Result of workflow execution
draw(*args, **kwargs)[source]
Generate lattice graph and display in UI taking into account passed in arguments.
PARAMETERS
- *args – Positional arguments to be passed to build the graph.
- **kwargs – Keyword arguments to be passed to build the graph.
RETURN TYPE
None
RETURNS
None
get_metadata(name)[source]
Get value of the metadata of given name.
PARAMETERS
name (str
) – Name of the metadata whose value is needed.
RETURNS
Value of the metadata of given name.
RETURN TYPE
value
RAISES
KeyError – If metadata of given name is not present.
set_metadata(name, value)[source]
Function to add/edit metadata of given name and value to lattice’s metadata.
PARAMETERS
- name (
str
) – Name of the metadata to be added/edited.
- value (
Any
) – Value of the metadata to be added/edited.
RETURN TYPE
None
RETURNS
None