AbstractWorkflow and Workflow

The workflows of the MyBigDFT package are meant to ease the calculation of some interesting quantities requiring to launch multiple BigDFT calculations by providing an API that focuses on the main parameters of such nested calculations.

Here are defined an AbstractWorkflow class (meant to be the base class of all the other workflow classes implemented in the workflows module) and a Workflow class, which represents the simplest way of implementing such a child class (intended to be used when one wants to create a toy implementation of a new workflow).

class mybigdft.workflows.workflow.AbstractWorkflow(queue)[source]

Bases: abc.ABC

This abstract class is the base class of all the workflows of this module. It defines the queue of jobs as a list of Job instances, that are run sequentially when the run() method is used.

Parameters

queue (list) – List of all the jobs to run.

property queue
Returns

All the jobs of the workflow.

Return type

list

property logfiles
Returns

A dictionary of all the logfiles of the workflow, with the name of the associated job as key.

Return type

dict

run(nmpi=1, nomp=1, force_run=False, dry_run=False, restart_if_incomplete=False, timeout=None)[source]

Run all the calculations if the post-processing was not already performed.

Warning

If force_run or dry_run is set to True, then any previous value of the post-processing attributes is deleted and set back to their default value, so that the post-processing is not considered as being performed.

Parameters
  • nmpi (int) – Number of MPI tasks.

  • nomp (int) – Number of OpenMP tasks.

  • force_run (bool) – If True, the calculations are run even though a logfile already exists.

  • dry_run (bool) – If True, the input files are written on disk, but the bigdft-tool command is run instead of the bigdft one.

  • restart_if_incomplete (bool) – If True, the job is restarted if the existing logfile is incomplete.

  • timeout (float or int or None) – Number of minutes after which each job must be stopped.

Warns

UserWarning – If the post-processing was already completed.

property is_completed
Returns

True if all the post-processing attributes are no longer set to their default value.

Return type

bool

abstract post_proc()[source]

This should be an abstract method used to post-process the output of the calculations and get some meaningful results out of them.

class mybigdft.workflows.workflow.Workflow(queue=None)[source]

Bases: mybigdft.workflows.workflow.AbstractWorkflow

This is a usable workflow that one can play with, but without post-processing. This means you can add jobs to the queue and run them as usual, but you must then code the post-processing yourself, in a separate function taking the workflow as parameter.

This latter scheme can even be part of the development cycle of a new workflow that could be later added to the MyBigDFT project: you first define roughly the jobs to be added to the queue for your workflow, and then develop a post-processing function taking your workflow as argument. When you are happy with the result, it is then easy to re-use most of the code to create a workflow class deriving from the AbstractWorkflow class.

To do that, you only have to make sure that you override the __init__ method to create the queue of jobs, then define which are the post-processing arguments and create properties to access them, and finally override the post_proc method to make sure these attributes are properly initialized.

Parameters

queue (list) – List of all the jobs to run.

The queue can be empty:

>>> wf = Workflow()
>>> wf.queue
[]
>>> wf.logfiles
{}
property completed
Returns

True if the post_proc method was run successfully.

Return type

bool

property is_completed
Returns

True if all the post-processing attributes are no longer set to their default value.

Return type

bool

property logfiles
Returns

A dictionary of all the logfiles of the workflow, with the name of the associated job as key.

Return type

dict

post_proc()[source]

Set the post-processing attribute completed to True

property queue
Returns

All the jobs of the workflow.

Return type

list

run(nmpi=1, nomp=1, force_run=False, dry_run=False, restart_if_incomplete=False, timeout=None)

Run all the calculations if the post-processing was not already performed.

Warning

If force_run or dry_run is set to True, then any previous value of the post-processing attributes is deleted and set back to their default value, so that the post-processing is not considered as being performed.

Parameters
  • nmpi (int) – Number of MPI tasks.

  • nomp (int) – Number of OpenMP tasks.

  • force_run (bool) – If True, the calculations are run even though a logfile already exists.

  • dry_run (bool) – If True, the input files are written on disk, but the bigdft-tool command is run instead of the bigdft one.

  • restart_if_incomplete (bool) – If True, the job is restarted if the existing logfile is incomplete.

  • timeout (float or int or None) – Number of minutes after which each job must be stopped.

Warns

UserWarning – If the post-processing was already completed.