gaps.hpc.HpcJobManager#

class HpcJobManager(user=None, queue_dict=None)[source]#

Bases: ABC

Abstract HPC job manager framework

Parameters:
  • user (str | None, optional) – HPC username. None will get your username using getpass.getuser(). By default, None.

  • queue_dict (dict | None, optional) – Parsed HPC queue dictionary from parse_queue_str(). None will get the queue info from the hardware. By default, None.

Methods

cancel(arg)

Cancel a job.

check_status_using_job_id(job_id)

Check the status of a job using the HPC queue and job ID.

check_status_using_job_name(job_name)

Check the status of a job using the HPC queue and job name.

make_script_str(name, **kwargs)

Generate the submission script.

parse_queue_str(queue_str)

Parse the hardware queue string into a nested dictionary.

query_queue()

Run the HPC queue command and return the raw stdout string.

reset_query_cache()

Reset the query dict cache so that hardware is queried again.

submit(name[, keep_sh])

Submit a job on the HPC.

Attributes

COLUMN_HEADERS

Column header names.

COMMANDS

Command names.

MAX_NAME_LEN

Q_SUBMITTED_STATUS

String representing the submitted status for this manager.

SHELL_FILENAME_FMT

USER

queue

HPC queue keyed by job ids with values as job properties.

classmethod parse_queue_str(queue_str)[source]#

Parse the hardware queue string into a nested dictionary.

This function parses the queue output string into a dictionary keyed by integer job ids with values as dictionaries of job properties (queue printout columns).

Parameters:

queue_str (str) – HPC queue output string. Typically a space-delimited string with line breaks.

Returns:

queue_dict (dict) – HPC queue parsed into dictionary format keyed by integer job ids with values as dictionaries of job properties (queue printout columns).

property queue#

HPC queue keyed by job ids with values as job properties.

Type:

dict

reset_query_cache()[source]#

Reset the query dict cache so that hardware is queried again.

check_status_using_job_id(job_id)[source]#

Check the status of a job using the HPC queue and job ID.

Parameters:

job_id (int) – Job integer ID number.

Returns:

status (str | None) – Queue job status string or None if not found.

check_status_using_job_name(job_name)[source]#

Check the status of a job using the HPC queue and job name.

Parameters:

job_name (str) – Job name string.

Returns:

status (str | None) – Queue job status string or None if not found.

cancel(arg)[source]#

Cancel a job.

Parameters:

arg (int | list | str) – Integer job id(s) to cancel. Can be a list of integer job ids, ‘all’ to cancel all jobs, or a feature (-p short) to cancel all jobs with a given feature

submit(name, keep_sh=False, **kwargs)[source]#

Submit a job on the HPC.

Parameters:
  • name (str) – HPC job name.

  • keep_sh (bool, optional) – Option to keep the submission script on disk. By default, False.

  • **kwargs – Extra keyword-argument pairs to be passed to make_script_str().

Returns:

  • out (str) – Standard output from submission. If submitted successfully, this is the Job ID.

  • err (str) – Standard error. This is an empty string if the job was submitted successfully.

abstract query_queue()[source]#

Run the HPC queue command and return the raw stdout string.

Returns:

stdout (list) – HPC queue output string that can be split into a list on line breaks.

abstract make_script_str(name, **kwargs)[source]#

Generate the submission script.

abstract property COLUMN_HEADERS#

Column header names.

Type:

namedtuple

abstract property COMMANDS#

Command names.

Type:

namedtuple

abstract property Q_SUBMITTED_STATUS#

String representing the submitted status for this manager.

Type:

str