virtmat.middleware.query package

Submodules

virtmat.middleware.query.dbquery module

A simple interface to query fireworks and workflows

virtmat.middleware.query.dbquery.db_select(lpad, filters=None, ids=None, selects=None)

Apply workflow query filters and then select updates from launch

virtmat.middleware.query.dbquery.get_launch(lpad, query)

Return a single firework from a query and its most recent launch

virtmat.middleware.query.wfquery module

Perform simple workflow queries

class virtmat.middleware.query.wfquery.WFQuery(lpad, wf_query=None, fw_query=None, metadata_only=False)

Bases: list

Perform a query in fireworks launchpad

Parameters:
  • lpad (LaunchPad) – a FireWorks LaunchPad object

  • wf_query (dict) – pymongo query for the workflows collection

  • fw_query (dict) – pymongo query for the fireworks collection

check_fw_ids(fw_ids=None)

If None return full list of fw_ids otherwise make a check

Parameters:

fw_ids ([int], None) – list of firework ids

Returns:

list of firework ids

Return type:

retval ([int])

get_data(dname, io_kind)

Return the input/output data for a given data name

Parameters:
  • dname (str) – data name

  • io_kind (str) – one of ‘input’ or ‘output’

Returns:

a list of dictionaries with the following keys:

fw_id (int): firework ID dname (str): data name, the value is the data or None

Return type:

res ([dict])

get_fw_ids()

Return the firework ids, complete list

get_fw_info(fw_ids=None, add_io_info=True)

Provide detailed information about specific nodes

Parameters:
  • fw_ids ([int], None) – list of firework ids

  • add_io_info (bool) – indicates whether to add node inputs and outputs

Returns:

a list of dictionaries with name, fw_id, state,

time stamp, parents, inputs and outputs

Return type:

res ([dict])

get_i_data(dname)

Return the input data for a given data name

Parameters:

dname (str) – data name

Returns:

a list of dictionaries with the following keys:

fw_id (int): firework ID dname (str): data name, the value is the data or None

Return type:

res ([dict])

get_i_names(fw_ids=None)

Return input data names in selected fireworks

Parameters:

fw_ids ([int], None) – list of firework ids

Returns:

a set of input data names in the specified fireworks

Return type:

({str})

get_nodes_providing(dname, match='string')

Return the ids of nodes providing a specified output

Parameters:
  • dname (str) – output data name (or a regular expression)

  • match ('regex' for a regular expression) – either ‘string’ for an exact string match or

  • match

Returns:

a list of matching node ids

Return type:

([int])

get_o_data(dname)

Return the output data for a given data name

Parameters:

dname (str) – data name

Returns:

a list of dictionaries with the following keys:

fw_id (int): firework ID dname (str): data name, the value is the data or None

Return type:

res ([dict])

get_o_names(fw_ids=None)

Return output data names in selected fireworks

Parameters:

fw_ids ([int], None) – list of firework ids

Returns:

a set of output data names in the specified fireworks

Return type:

({str})

get_task_info(fw_ids=None)

Return the dataflow from PyTask firetasks in selected fireworks

Parameters:

fw_ids ([int], None) – list of firework ids

Returns:

list of dictionaries containing the task info

Return type:

res ([dict])

get_wf_ids()

Return the firework ids, one for each worklfow

get_wf_info(fw_ids=None, add_io_info=True)

Display a summary of workflows including specific nodes

Parameters:
  • fw_ids ([int], None) – list of firework ids

  • add_io_info (bool) – display/not display node inputs and outputs

virtmat.middleware.query.wfquery.io_info(fw_dict, io_kind, storage)

Get tuples of data names and types from a firework, restricted to PyTask

Parameters:
  • fw_dict (dict) – Firework dictionary

  • io_kind (str) – Either ‘inputs’ or ‘outputs’

  • storage (dict) – Dictionary where the data has been stored

Returns:

A list of tuples containing data names and data types

Return type:

([tuple])

virtmat.middleware.query.wfquery.task_info(fw_dict)

Get info about dataflow tasks, restricted to PyTask

Parameters:

fw_dict (dict) – Firework dictionary

Returns:

A list of dictionaries with the following keys:

name (str): the Python function called in the PyTask inputs (list, None): List of input data names outputs (list, None): List of output data names

Return type:

res ([dict])

Module contents