soprano.hpc.submitter.castep#

Definition of CastepSubmitter class.

A basic “rolling” submitter for Castep calculations, grabbing from one folder and depositing results in another.

Classes

CastepSubmitter(name, queue, submit_script)

Initialize the Submitter object

class soprano.hpc.submitter.castep.CastepSubmitter(name, queue, submit_script, max_jobs=4, check_time=10, max_time=3600, temp_folder=None, remote_workdir=None, remote_getfiles=['*.*'], ssh_timeout=1.0, continuation=False)[source]#

Bases: Submitter

Initialize the Submitter object

Args:
name (str): name to be used for this Submitter (two Submitters
with the same name can’t be launched in the same
working directory)
queue (QueueInterface): object describing the properties of the
interface to the queue system in use
submit_script (str): text of the script to use when submitting a
job to the queue. All tags of the form <name>
will be replaced with the job’s name, and all
similar tags of the form <[arg]> will be
replaced if the argument name is present in
the job’s args dictionary
max_jobs (Optional[int]): maximum number of jobs to submit at a
given time. Default is 4
check_time (Optional[float]): time in seconds between consecutive
checks for the queue status and
attempts to submit new jobs. Default
is 10
max_time (Optional[float]): time in seconds the Submitter will run
for before shutting down. If set to
zero the thread won’t stop until
killed with Submitter.stop.
temp_folder (Optional[str]): where to store the temporary folders
for the calculations. By default it’s
the current folder.
remote_workdir (Optional[str]): if present, uses a directory on a
remote machine by logging in via
SSH. Must be in the format
<host>:<path/to/directory>.
Host must be defined in the user’s
~/.ssh/config file - check the
docs for RemoteTarget for more
information. It is possible to
omit the colon and directory, that
will use the home directory of the
given folder; that is HEAVILY
DISCOURAGED though. Best practice
would be to create an empty
directory on the remote machine
and use that, to avoid accidental
overwriting/deleting of important
files.
remote_getfiles (Optional[list(str)]): list of files to be
downloaded from the remote
copy of the job’s temporary
directory. By default, all
of them. Can be a list
using specific names,
wildcards etc. Filenames
can also use the
placeholder {name} to
signify the job name, as
well as any other element
from the arguments.
ssh_timeout (Optional[float]): connection timeout in seconds
(default is 1 second)
continuation (Optional[bool]): if True, when the Submitter is
stopped it will not terminate the
current jobs; rather, it will store
the list in a pickle file.
If the submitter is ran from the
same folder then it will “pick up
from where it left” and try
recovering those jobs, then
restart. If one wishes for
additional values to be saved and
restored, the save_state and
load_state methods need to be
defined.
_main_loop()#

Main loop run as separate thread. Should not be edited when inheriting from the class

_putjob_remote(njob)#

Copy the files generated for a job to a remote work directory

add_signal(command, callback)#

Add a signal listener to this submitter. Unix systems only allow for up to TWO user-defined signals to be specified.

Args:
command (str): command that should be used to call this signal.
This would be used as:
python -m soprano.hpc.submitter <command> <file>
and will trigger the callback’s execution
callback (function<self> => None): method of the user defined
Submitter class to use as a callback when the
given signal is sent. Should accept and return
nothing.
check_job(job_id, name, args, folder)#

Checks if given job is complete or not

finish_job(name, args, folder)[source]#

Save required output files to the output folder

finish_run()[source]#

Try removing the temporary keywords directory

load_state(loaded)#

Replace attributes from loaded data in dictionary form

next_job()[source]#

Grab the next job from folder_in

remove_signal(command)#

Remove a previously defined custom signal by its assigned command.

Args:
command (str): command assigned to the signal handler to remove.
save_state()#

Return a dictionary containing serialisable data to be saved from one run to the next

set_parameters(folder_in, folder_out, castep_command, castep_path=None, copy_extensions=['.castep'], pspot_files=[], dryrun_test=False)[source]#

Set the parameters of the CASTEP Submitter

Args:
folder_in (str): path of the folder to extract cell files from
folder_out (str): path of the folder where the results will be
saved
castep_command (str): command used to call the CASTEP executable
on this system
castep_path (Optional[str]): folder where the CASTEP executable is
located (if not part of the system
PATH)
pspot_files (Optional[list[str]]): additional pseudopotential
files to be copied in the input
temporary folders
copy_extensions (Optional[list[str]]): extensions of output files
to copy to the output
folder (by default only
.castep file)
dryrun_test (Optional[bool]): run a dryrun test on files before
actually running the calculation.
Off by default.
setup_job(name, args, folder)[source]#

Copy files to temporary folder to prepare for execution

start_run()[source]#

Operations to perform when the daemon thread starts running

static stop(fname, subname)#

Stop Submitter process from filename and name, return False if failed