Electron
@covalent.electron
Electron decorator to be applied to a function. Returns the wrapper function with the same functionality as func.
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.
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.
deps_module
An optional DepsModule (or similar) object specifying which user modules to load 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
files
An optional list of FileTransfer objects which copy files to/from remote or local filesystems.
Returns
Electron object containing the decorated function.
Return Type
An electron (or task) object that is a modular component of a workflow and is returned by electron
An electron (or task) object that is a modular component of a workflow and is returned by electron
function
Function to be executed.
node_id
Node id of the electron.
metadata
Metadata to be used for the function execution.
kwargs
Keyword arguments if any.
Methods
add_collection_node_to_graph
(graph, prefix)
Adds the node to the lattice’s transport graph in the case where a collection of electrons is passed as an argument to another electron.
connect_node_with_others
(node_id, …)
Adds a node along with connecting edges for all the arguments to the electron.
get_metadata
(name)
Get value of the metadata of given name.
get_op_function
(operand_1, operand_2, op)
Function to handle binary operations with electrons as operands.
set_metadata
(name, value)
Function to add/edit metadata of given name and value to electron’s metadata.
wait_for
(electrons)
Waits for the given electrons to complete before executing this one.
Attributes:
Get transportable electron object and metadata.
Adds the node to the lattice’s transport graph in the case where a collection of electrons is passed as an argument to another electron.
Parameters
graph (*TransportGraph) – Transport graph of the lattice
prefix (str
) – Prefix of the node
Returns
Node id of the added node
Return Type
node_id
Adds a node along with connecting edges for all the arguments to the electron.
Parameters
node_id (int
) – Node number of the electron
param_name (str
) – Name of the parameter
param_value (Union
[Any
, ForwardRef
]) – Value of the parameter
param_type (str
) – Type of parameter, positional or keyword
transport_graph (*TransportGraph) – Transport graph of the lattice
Returns
None
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.
Function to handle binary operations with electrons as operands. This will not execute the operation but rather create another electron whose execution will be postponed according to the default electron configuration/metadata.
This also makes sure that if these operations are being performed outside of a lattice, then they are performed as is.
Parameters
Returns
Electron object corresponding to the operation execution. Behaves as a normal function call if outside a lattice.
Return Type
electron
Function to add/edit metadata of given name and value to an electron’s metadata.
Parameters
name (str
) – Name of the metadata to be added/edited.
value (Any
) – Name of the metadata to be added/edited.
Return Type
None
Returns
None
Waits for the given electrons to complete before executing the electron object (implicit parameter) on which the method is being called. Adds the necessary edges between this and those electrons without explicitly connecting their inputs/outputs.
Useful when execution of this electron relies on a side-effect from the another one.