Bases: pylada.process.process.Process
Executes an external program
This process creates and manages the execution of an external program, say VASP or CRYSTAL, via a subprocess.Popen instance. The external program can be launched with or without MPI, with or without standard output/input/error files. It is always launched within a specified directory.
A typical use case, taken from process/test/program.py, is the following:
program = ProgramProcess( executable, outdir=dir,
cmdline=['--sleep', 0, '--order', 4],
stdout=stdout, dompi=True )
program.start(comm)
try: program.wait()
except Fail:
# do something
The above launches an external program taking a set of arguments. Its output is piped to a specific file for later grepping. It is launched using the super-computer’s MPI interface, with the number of processors specified by comm. It is launched in a directory dir. The snippet above has python wait for the external program to finish, while checking for exceptions if the program fails. The external program is started only once start() is called.
Note
A Fail exception is thrown when the program returns with a non-zero exit code. However, some propietary MPI crapware, such as Cray’s. will return 0 whenever MPI::Finalize() is called, even when the program itself returns non-zero. As a result, it is not possible to rely on a Fail exception being thrown correctly on all machines at all times.
Initializes a process.
Parameters: |
|
---|
Command line for the program.
A function to modify command-line parameters.
This function is only invoked for mpirun programs. It can be used to, say, make sure a program is launched only with an even number of processes. It should add ‘placement’ to the dictionary.
Whether to run with mpi or not.
Called if program fails.
Some program, such as CRYSTAL, return error codes when unconverged. However, does not necessarily mean the program failed to run. This function is called when a failure occurs, to make sure it is real or not. It should raise Fail if an error has occurred and return normally otherwise.
Callback when the processes finishes.
Called even on error. Should take two arguments:
- process: holds this instance
- error: True if an error occured.
It is called before the _cleanup() method. In other words, the process is passed as it is when the error is found.
Directory where to run job.
Polls current job.
Returns: | True if external program is finished. |
---|---|
Raises Fail: | If external program returns a non-zero exit code. |
External program to execute.
Starts current job.
Parameters: | comm (Communicator) – Holds information about how to launch an mpi-aware process. |
---|---|
Returns: | True if process is already finished. |
Raises: |
|
Name of standard error file, if any.
Name of standard error file, if any.
Name of standard output file, if any.