bartender.schedulers.dirac#
Attributes#
Classes#
DIRAC scheduler. |
Functions#
|
Return description.output_dir relative to user's home directory. |
|
Extract text file from tarfile. |
Module Contents#
- bartender.schedulers.dirac.logger#
- class bartender.schedulers.dirac.DiracScheduler(config: bartender.schedulers.dirac_config.DiracSchedulerConfig)#
Bases:
bartender.schedulers.abstract.AbstractSchedulerDIRAC scheduler.
[More info](http://diracgrid.org/).
- Parameters:
config (bartender.schedulers.dirac_config.DiracSchedulerConfig) –
- wms_client#
- monitoring#
- async submit(description: bartender.schedulers.abstract.JobDescription) str#
Submit a job description for running.
The job submitted to DIRAC will do the following:
Download description.job_dir / input.tar from grid storage.
Unpack input.tar.
- Run description.command
Capturing stdout and stderr as stdout.txt and stderr.txt files.
Capturing return code in return_code file.
- Pack output.tar.
Excluding files from input.tar.
Upload output.tar to grid storage as description.job_dir / output.tar.
- Parameters:
description (bartender.schedulers.abstract.JobDescription) – Description for a job.
- Raises:
RuntimeError – When submission fails.
- Returns:
Identifier that can be used later to interact with job.
- Return type:
- async state(job_id: str) bartender.db.models.job_model.State#
Get state of a job.
Once job is completed, then scheduler can forget job.
- Parameters:
job_id (str) – Identifier of job.
- Raises:
RuntimeError – When getting job status fails.
- Returns:
State of job.
- Return type:
bartender.db.models.job_model.State
- async states(job_ids: list[str]) list[bartender.db.models.job_model.State]#
Get state of jobs.
Once a job is completed, then scheduler can forget job.
- Parameters:
- Raises:
RuntimeError – When getting jobs status fails.
- Returns:
States of jobs.
- Return type:
list[bartender.db.models.job_model.State]
- async cancel(job_id: str) None#
Cancel a queued or running job.
Once a queued job is cancelled, then the scheduler can forget job.
- Parameters:
job_id (str) – Identifier of job.
- Raises:
RuntimeError – When cancelling of job fails.
- Return type:
None
- async logs(job_id: str, job_dir: pathlib.Path) Tuple[str, str]#
Get stdout and stderr of a job.
If job has not completed, then will raise an exception. If job completed succesfully, then stdout,txt and stderr.txt are read from job_dir. If job failed, then stdout and stderr are read from grid storage.
Logs of a failed job includes logs of unpacking/packing the input and output files.
The logs can be fetched on command line with dirac-wms-job-get-output <job id>.
- Parameters:
job_id (str) – Identifier of job.
job_dir (pathlib.Path) – Directory where stdout.txt and stderr.txt files of job are stored.
- Raises:
RuntimeError – When fetching of logs fails.
- Returns:
Tuple of stdout and stderr.
- Return type:
- async _job_script(description: bartender.schedulers.abstract.JobDescription, scriptdir: pathlib.Path) pathlib.Path#
- Parameters:
description (bartender.schedulers.abstract.JobDescription) –
scriptdir (pathlib.Path) –
- Return type:
- _job_script_content(description: bartender.schedulers.abstract.JobDescription) str#
- Parameters:
description (bartender.schedulers.abstract.JobDescription) –
- Return type:
- _command_script(description: bartender.schedulers.abstract.JobDescription) str#
- Parameters:
description (bartender.schedulers.abstract.JobDescription) –
- Return type:
- async _jdl_script(description: bartender.schedulers.abstract.JobDescription, scriptdir: pathlib.Path) str#
- Parameters:
description (bartender.schedulers.abstract.JobDescription) –
scriptdir (pathlib.Path) –
- Return type:
- bartender.schedulers.dirac._relative_output_dir(description: bartender.schedulers.abstract.JobDescription) pathlib.Path#
Return description.output_dir relative to user’s home directory.
user home directory is /<vo>/user/<initial>/<user> to write /tutoVO/user/c/ciuser/bartenderjobs/job1/input.tar OutputPath must be bartenderjobs/job1
- Parameters:
description (bartender.schedulers.abstract.JobDescription) – Description of job.
- Returns:
.description.output_dir relative to user’s home directory.
- Return type:
- async bartender.schedulers.dirac._extract_text_file(tar: tarfile.TarFile, src: str, target: pathlib.Path) None#
Extract text file from tarfile.
- Parameters:
tar (tarfile.TarFile) – Tarfile to extract file from.
src (str) – Name of file to extract.
target (pathlib.Path) – Path to write file to.
- Return type:
None