Relay class
Relay records the workflow in a tape recorder fashion. This helps in
construction of the workflow as a directed-acyclic graph. The
runner.relay.Relay emphasises simplicity, speed and flexibility
in implementing the workflow.
- class runner.relay.Relay(label, parents=None, runnerdata=None, runnername=None)[source]
Relay
dbrows into a workflow- Parameters:
label (str) – unique label of relay, for easy access in graph
parents (list) – list of parents as input to the relay. Parents can be
Atomsobject, id in the database, orRelay.runnerdata (
RunnerData) – the runner data to be attached to the row.runnername (str) – name of the runner that handles the row run.
Note
In the case of
Atomsobject as parent, the object can be the only one in the list.- cancel(cancel_all=False)[source]
Cancel row job
- Parameters:
all (bool) – Cancel all runs in the parent relay too.
- commit(database=None)[source]
Commits the relay to the database, i.e. adds data to the database.
- Parameters:
database (str) – ASE database to commit to. If None (default) then stored database from previous commit is used.
- Returns:
the id of the row commited to in the database.
- Return type:
int
- property database
database associated with the relay
- classmethod from_database(index, database)[source]
Get relay from database
- Parameters:
index (int) – id of row in database
database (str) – ASE database
- Returns:
relay associated with id
- Return type:
Relay object
- classmethod from_json(filename)[source]
Get relay from json file.
- Parameters:
filename (str) – json filename
- get_parent_relay(item)[source]
Returns a Relay instance of one of the parents associated with item, in the parent relay
- Parameters:
item (str or int) – id or label associated with parent relay
- get_relay_graph(filename, add_tasks=False)[source]
Save the relay as a directional acyclic graph, with status
- Parameters:
filename (str) – png filename to save the graph
add_tasks (bool) – adds task information to the graph
- get_row(cycle_time=10, wait=True)[source]
Get atoms row attached with the relay. Waits for the run if not finished.
- Parameters:
cycle_time (float) – time (s) to cycle the query.
wait (bool) – wait for run to finish
- Returns:
atoms row of attached with the relay
- Return type:
row
- get_status()[source]
Returns status of the present row
- Returns:
status of present row
- Return type:
str
- property label
runnername associated with the relay
- needs_commit()[source]
Checks all parents to confirm if relay needs a commit
- Returns:
if relay needs a commit
- Return type:
bool
Note
set_property methods should be used to update the relay. This marks the relay needs commit. If the set_property methods aren’t used, then relay will not commit the changes.
- property parents
parents associated with the relay
- replace_runnerdata(runnerdata)[source]
Replace RunnerData for the relay and all relays with same runner name as the given RunnerData
- Parameters:
runnerdata (
RunnerData) – RunnerData to supplant.
- property row
Atoms row attached with the relay, awaits for the run to finish
- property runnerdata
runnerdata associated with the relay
- property runnername
runnername associated with the relay
- start(force=False, force_all=False)[source]
Submits the relay for run. Rows with submitted parents are also submitted.
- NB: rows with status ‘submit’ or ‘running’ are not
resubmitted.
- Parameters:
force (bool) – resubmit row with ‘done’ status too.
force_all (bool) – resubmit all parent rows with ‘done’ status too.
- Returns:
if a row is submitted
- Return type:
bool
- property status
Returns status of present relay row