haddock.libs.libgrid module

class haddock.libs.libgrid.GRIDScheduler(tasks: list[CNSJob], params: dict)[source]

Bases: object

Scheduler to manage and run jobs on the GRID via DIRAC.

params: dict
static process_job(job: GridJob) Tuple[GridJob, bool][source]

Process a single job: update status, retrieve output if done, handle retries if failed.

NOTE: This function is parallelized, that is why things like cleaning, download, retry

are here. If you are adding new functionality, consider if it should be here or in the sequential part of the code.

run() None[source]

Execute the tasks.

tasks: list[CNSJob]
class haddock.libs.libgrid.GridJob(cnsjob: CNSJob)[source]

Bases: object

GridJob is a class tha represents a job to be run on the GRID via DIRAC.

clean() None[source]

Clean up the temporary directory where the job lives.

create_jdl() None[source]

Create the JDL file that describes the job to DIRAC.

create_job_script() None[source]

Create the job script that will be executed in the grid.

static parse_output(output_str: str) dict[str, str][source]

Parse the output string from DIRAC commands into a dictionary.

prepare_payload(cns_exec_path: Path, cns_script_path: Path, toppar_path: Path) None[source]

Prepare the payload.zip file containing all necessary files.

process_input_f() None[source]

Process the input file to adjust paths and identify outputs.

!! IMPORTANT !!

This is a very important step. The .inp files coming from the modules

have several paths that are absolute paths in the local filesystem.

When this job is running in the GRID, the paths will no longer be valid.

This processing here will identify all the paths and input files in the

.inp file and replace them with a structure that will be valid in the GRID.

!! IMPORTANT !!

retrieve_output() None[source]

Retrieve the output files from DIRAC.

submit() None[source]

Interface to submit the job to DIRAC.

update_status() None[source]

Update the status of the job by querying DIRAC.

class haddock.libs.libgrid.JobStatus(value)[source]

Bases: Enum

An enumeration.

COMPLETING = 'Completing'
DONE = 'Done'
FAILED = 'Failed'
MATCHED = 'Matched'
RUNNING = 'Running'
UNKNOWN = 'Unknown'
WAITING = 'Waiting'
classmethod from_string(value)[source]

Convert string to JobStatus enum.

haddock.libs.libgrid.ping_dirac() bool[source]

Ping the Dirac server to check if it’s reachable.

haddock.libs.libgrid.validate_dirac() bool[source]

Check if the DIRAC client is valid and configured.