carputils.job
.Jobcarputils.job.
Job
(ID)A sequence of commands plus the tools to execute them.
A job defines a series of commands that can be executed in different ways. Each job has an ID, which defines where the output of its commands is placed, plus a series of commands that can either be run immediately as they are registered or delayed for later execution in different ways.
A job is instantiated with its ID:
>>> job = Job('2015-11-25_important_sim')
and its ID can then be accessed as an attribute:
>>> print job.ID
2015-11-25_important_sim
Commands are then registered for the job with the register()
method:
>>> from carputils.job.command import ShellCommand
>>> job.register(ShellCommand(['ls', '-l'], 'List directory'))
however, for convenience, a number of methods such as bash()
are
provided to avoid the need to construct your own commands manually:
>>> job.bash(['ls', '-l'])
On a normal system, commands are executed immeditately once registered
(unless the ‘delayed’ keyword argument is set to True), however on batch
systems, commands are stored. The script()
method may then be
used to generate a bash script executing the stored commands.
The submit()
method may also be used to automatically generate
and submit the job on HPC systems, using the carputils platform.
>>> job.submit()
Users will generally only need to use the convenience submission methods, as the job creation and batch script generation and submission is done automatically by the carputils framework.
bash
(cmd, message=None, delayed=False, *args, **kwargs)Execute an arbitrary command in the shell.
bench
(cmd, simname=None, msg=None, *args, **kwargs)Execute a BENCH simulation.
Runs a BENCH sim with mpiexec, automatically adding the number of processes and command configuration.
carp
(cmd, simname=None, polling_subdirs=True, *args, **kwargs)Execute an openCARP simulation.
Runs an openCARP sim with mpiexec, automatically adding the number of processes and debugger/profiler options from the current run configuration.
cp
(path_from, path_to, cpdir=False, *args, **kwargs)Copy a file.
cvstool
(cmd, stdout=None, stderr=None, *args, **kwargs)Execute cvstool
gunzip
(filename, *args, **kwargs)Unzip a .gz file.
link
(target, link_name=None, *args, **kwargs)Make a symbolic link.
meshalyzer
(geom, *args, **kwargs)Run meshalyzer.
meshtool
(cmd, *args, stdout=None, stderr=None, **kwargs)Execute meshtool
mkdir
(directory, parents=False, *args, **kwargs)Make a directory.
mpi
(cmd, message='Executing MPI Command', *args, **kwargs)Execute a command with MPI.
Runs a command with mpiexec, automatically adding the number of processes and debugger/profiler options from the current run configuration.
mv
(path_from, path_to, *args, **kwargs)Move a file.
python
(cmd, *args, **kwargs)Execute a python script.
# FIXME: update documentation Runs a pythonCARP sim with mpiexec, automatically adding the number of processes and debugger/profiler options from the current run configuration.
register
(command, delayed=False)Register a command to be executed.
rm
(filename, rmdir=False, *args, **kwargs)Remove a file or a directory
script
()Generate a bash script running the command sequence
submit
(argv=None)Submit the command sequence to the batch system.