seisflows.system.workstation

The workstation class is the foundational System module in SeisFlows, it provides utilities for submitting jobs in SERIAL on a small-scale machine, e.g., a workstation or a laptop. All other System classes build on this class.

Module Contents

Classes

Workstation

Workstation System

class seisflows.system.workstation.Workstation(ntask=1, nproc=1, mpiexec=None, log_level='DEBUG', verbose=False, workdir=os.getcwd(), path_output=None, path_system=None, path_par_file=None, path_output_log=None, path_log_files=None, **kwargs)

Workstation System

Defines foundational structure for System module. When used standalone, runs solver tasks either in serial (if nproc`==1; i.e., without MPI) or in parallel (if `nproc>1; i.e., with MPI). All other tasks are run in serial.

Parameters

type ntask

int

param ntask

number of individual tasks/events to run during workflow. Must be <= the number of source files in path_specfem_data

type nproc

int

param nproc

number of processors to use for each simulation. Choose 1 for serial simulations, and nproc>1 for parallel simulations.

type mpiexec

str

param mpiexec

MPI executable on system. Defaults to ‘mpirun -n ${NPROC}’

type log_level

str

param log_level

logger level to pass to logging module. Available: ‘debug’, ‘info’, ‘warning’, ‘critical’

type verbose

bool

param verbose

if True, formats the log messages to include the file name, line number and message type. Useful for debugging but also very verbose.

Paths

type path_output_log

str

param path_output_log

path to a text file used to store the outputs of the package wide logger, which are also written to stdout

type path_par_file

str

param path_par_file

path to parameter file which is used to instantiate the package

type path_log_files

str

param path_log_files

path to a directory where individual log files are saved whenever a number of parallel tasks are run on the system.

***

check()

Checks parameters and paths

setup()

Create the SeisFlows directory structure in preparation for a SeisFlows workflow. Ensure that if any config information is left over from a previous workflow, that these files are not overwritten by the new workflow. Should be called by submit()

Note

This function is expected to create dirs: SCRATCH, SYSTEM, OUTPUT and the following log files: output, error

Note

Logger is configured here as all workflows, independent of system, will be calling setup()

Return type

tuple of str

Returns

(path to output log, path to error log)

submit(workdir=None, parameter_file='parameters.yaml')

Submits the main workflow job as a serial job submitted directly to the system that is running the master job

Parameters
  • workdir (str) – path to the current working directory

  • parameter_file (str) – parameter file name used to instantiate the SeisFlows package

run(funcs, single=False, **kwargs)

Executes task multiple times in serial.

Note

kwargs will be passed to the underlying method that is called

Parameters
  • funcs (list of methods) – a list of functions that should be run in order. All kwargs passed to run() will be passed into the functions.

  • single (bool) – run a single-process, non-parallel task, such as smoothing the gradient, which only needs to be run by once. This will change how the job array and the number of tasks is defined, such that the job is submitted as a single-core job to the system.

_get_log_file(task_id)

To mimic clusters which assign job numbers to spawned processes, our on-system runs will also assign job numbers simply be incrementing the number on the log files on system.