libhpc: HPC execution functions

Module in charge of running tasks in HPC.

class haddock.libs.libhpc.HPCScheduler(task_list: list[haddock.libs.libsubprocess.CNSJob], target_queue: str = '', queue_limit: int = 100, concat: int = 1)[source]

Bases: object

Schedules tasks to run in HPC.

run() None[source]

Run tasks in the Queue.

terminate() None[source]

Terminate all jobs in the queue in a controlled way.

class haddock.libs.libhpc.HPCWorker(tasks: list[haddock.libs.libsubprocess.CNSJob], num: int, job_id: int | None = None, workfload_manager: str = 'slurm', queue: str | None = None)[source]

Bases: object

Defines the HPC Job.

cancel(bypass_statuses: Container[str] = ('finished', 'failed')) None[source]

Cancel the execution.

prepare_job_file(queue_type: str = 'slurm') None[source]

Prepare the job file for all the jobs in the task list.

run() None[source]

Execute the tasks.

update_status() str[source]

Retrieve the status of this worker.

haddock.libs.libhpc.create_CNS_export_envvars(**envvars: Any) str[source]

Create a string exporting envvars needed for CNS.

Parameters:

envvars (dict) – A dictionary containing envvariables where keys are var names and values are the values.

Returns:

str – In the form of: export VAR1=VALUE1 export VAR2=VALUE2 export VAR3=VALUE3

haddock.libs.libhpc.create_slurm_header(job_name: str | Path = 'haddock3_slurm_job', work_dir: str | Path = '.', stdout_path: str | Path = 'haddock3_job.out', stderr_path: str | Path = 'haddock3_job.err', queue: str | None = None, ncores: int = 48) str[source]

Create HADDOCK3 Slurm Batch job file.

Parameters:
  • job_name (str) – The name of the job.

  • work_dir (pathlib.Path) – The working dir of the example. That is, the directory where input, jobs, and logs reside. Injected in create_job_header.

  • time (int) – Time in minutes before job reach TIMEOUT status.

  • **job_params – According to job_setup.

Returns:

str – Slurm-based job file for HADDOCK3.

haddock.libs.libhpc.create_torque_header(job_name: str | Path = 'haddock3_slurm_job', work_dir: str | Path = '.', stdout_path: str | Path = 'haddock3_job.out', stderr_path: str | Path = 'haddock3_job.err', queue: str | None = None, ncores: int = 48) str[source]

Create HADDOCK3 Alcazar job file.

Parameters:
  • job_name (str) – The name of the job.

  • work_dir (pathlib.Path) – The working dir of the example. That is, the directory where input, jobs, and logs reside. Injected in create_job_header.

  • **job_params – According to job_setup.

Returns:

str – Torque-based job file for HADDOCK3 benchmarking.

haddock.libs.libhpc.extract_slurm_status(slurm_out: str) str[source]

Extract job status from slurm scontrol stdout.

Parameters:

slurm_out (str) – StdOut of scontrol show jobid -dd {job_id} command.

Returns:

status (str) – Status of the slurm job. May also return error, when job do not exists.

haddock.libs.libhpc.to_torque_time(time: int) str[source]

Convert time in minutes to the form hh:mm:ss.

Parameters:

time (int) – Time in minutes.

Returns:

hh_mm_ss (str) – Time in the form for HH:MM:SS