HPS-MC
 
Loading...
Searching...
No Matches
Swif Class Reference

Submit jobs to the 'swif2' workflow system at JLAB. More...

Inheritance diagram for Swif:
Auger BatchSystem Batch

Public Member Functions

 __init__ (self)
 
 parse_args (self, args)
 Parse command line arguments and perform setup.
 
 submit (self)
 Batch submission method for Auger.
 
- Public Member Functions inherited from Auger
 submit_job (self, job_id)
 Make this a no-op.
 
 build_cmd (self, job_id)
 This is the basic implementation of building a command to run the job from a batch system.
 
- Public Member Functions inherited from Batch
 default_rundir (self, job_id=None)
 

Public Attributes

 workflow
 
 project
 
 swif_site
 
 max_concurrent
 
 recreate
 
 setup_script
 
- Public Attributes inherited from Auger
 setup_script
 
 email
 
 memory
 
 diskspace
 
 job_length
 
 config_files
 
 job_steps
 
 script
 
- Public Attributes inherited from BatchSystem
 site
 
 email
 
 queue
 
 os
 
 memory
 
 diskspace
 
 job_length
 
- Public Attributes inherited from Batch
 parser
 
 script_name
 
 script
 
 jobstore
 
 debug
 
 log_dir
 
 run_dir
 
 check_output
 
 job_ids
 
 job_steps
 
 start_job_num
 
 end_job_num
 
 config_files
 

Static Public Attributes

str DEFAULT_PROJECT = 'hallb-pro'
 Default JLAB project/allocation.
 
str DEFAULT_SITE = 'jlab/enp'
 Default swif2 site name, passed to 'swif2 create -site-name'.
 
str DEFAULT_OS = 'el9'
 Default OS constraint, passed to add-job as '-constraint'.
 
 VALID_PARTITIONS = frozenset(['production', 'ifarm', 'priority', 'jupyter', 'gpu'])
 Valid slurm partitions on the JLAB farm (from 'sinfo').
 
dict LEGACY_TRACK_PARTITIONS
 Legacy Auger "track" names (accepted by the old add-jsub) mapped to their closest valid slurm partition.
 

Protected Member Functions

 _partition (self)
 Resolve the swif2 (slurm) partition.
 
 _run_swif2 (self, args, check=True, quiet=False)
 Run a single 'swif2' subcommand, echoing its (non-empty) output.
 
 _create_cmd (self)
 
 _create_workflow (self)
 Ensure the swif2 workflow exists (add-job requires it to already exist).
 
 _add_job_cmd (self, job_params)
 Build the 'swif2 add-job' argument list for a single job.
 
 _job_inputs (self, job_params)
 Yield (local_dest, remote_uri) pairs for a job's inputs, applying swif2 URI schemes.
 
 _job_outputs (self, job_params)
 Yield (local_src, remote_uri) pairs for a job's outputs, resolving ptag sources and applying schemes.
 
 _write_job_script (self, job_id)
 Write an executable tcsh wrapper script that sets up the (c-shell) environment and runs the job, and return its absolute path.
 
- Protected Member Functions inherited from Auger
 _create_job_xml (self)
 
 _jsub (self, xml_filename)
 
 _get_auger_ids (self, out)
 
 _write_req (self, req, filename='temp.xml')
 
 _create_req (self, req_name)
 
 _create_job (self, params)
 Needed for resolving ptag output sources.
 
 _add_job (self, req, job_params)
 
- Protected Member Functions inherited from Batch
 _logfile (self, job_id)
 Get the base name of a log file for the job.
 
 _get_filtered_job_ids (self)
 Get a list of job IDs to submit based on parsed command line options and whether output files are being checked.
 
 _job_ids_missing_output (self, job_ids)
 Get a list of IDs for jobs that are missing output files.
 

Static Protected Member Functions

 _echo (text)
 Print the non-empty lines of some swif2 output.
 
 _swif_uri (path)
 Convert a filesystem path to a swif2 remote URI.
 
- Static Protected Member Functions inherited from BatchSystem
 _site ()
 
- Static Protected Member Functions inherited from Batch
 _outputs_exist (job)
 Check if all output files exist for the given job.
 

Detailed Description

Submit jobs to the 'swif2' workflow system at JLAB.

The legacy 'swif2 add-jsub' command (which consumed an Auger XML request file) has been deprecated by JLAB and is being removed. This class now builds the workflow with 'swif2 create' and adds each job with 'swif2 add-job', mapping the parameters that the parent Auger class used to encode in XML directly onto add-job command-line flags, then starts the workflow with 'swif2 run'.

Note that 'swif2 create' fails if a workflow of the same name already exists. Existing workflows generated by this class should be fully cancelled and removed before resubmitting under the same name.

Definition at line 680 of file batch.py.

Constructor & Destructor Documentation

◆ __init__()

__init__ (   self)

Reimplemented from Auger.

Definition at line 715 of file batch.py.

Member Function Documentation

◆ _add_job_cmd()

_add_job_cmd (   self,
  job_params 
)
protected

Build the 'swif2 add-job' argument list for a single job.

This reproduces, as add-job flags, the per-job information the parent Auger class used to write into the request XML: resource limits, inputs, outputs, stdout/stderr, the job name, and the command to run.

Parameters
job_paramsraw job data dict from the job store
Returns
list of arguments following the 'swif2' executable

Definition at line 852 of file batch.py.

◆ _create_cmd()

_create_cmd (   self)
protected

Definition at line 817 of file batch.py.

◆ _create_workflow()

_create_workflow (   self)
protected

Ensure the swif2 workflow exists (add-job requires it to already exist).

If a workflow of the same name already exists this is not an error: the create is skipped and jobs are added to the existing workflow. Pass –recreate to cancel and recreate it instead. Any other create failure is fatal. The create output is captured and only echoed on success or a genuine failure, so the benign 'already exists' case does not surface swif's scary error text.

Definition at line 827 of file batch.py.

◆ _echo()

_echo (   text)
staticprotected

Print the non-empty lines of some swif2 output.

Definition at line 811 of file batch.py.

◆ _job_inputs()

_job_inputs (   self,
  job_params 
)
protected

Yield (local_dest, remote_uri) pairs for a job's inputs, applying swif2 URI schemes.

http inputs are skipped (they are not staged by swif), matching the previous Auger behavior.

Definition at line 906 of file batch.py.

◆ _job_outputs()

_job_outputs (   self,
  job_params 
)
protected

Yield (local_src, remote_uri) pairs for a job's outputs, resolving ptag sources and applying schemes.

Definition at line 919 of file batch.py.

◆ _partition()

_partition (   self)
protected

Resolve the swif2 (slurm) partition.

The old Auger "track" (debug mode -> 'debug', else the queue, else the 'production' default) is validated against the farm's real partitions: legacy track names are remapped to a valid partition with a warning, and anything else unknown is a hard error.

Returns
a valid slurm partition name

Definition at line 743 of file batch.py.

◆ _run_swif2()

_run_swif2 (   self,
  args,
  check = True,
  quiet = False 
)
protected

Run a single 'swif2' subcommand, echoing its (non-empty) output.

Parameters
argslist of arguments following the 'swif2' executable
checkif True, raise on a non-zero exit; if False, return the result for the caller to inspect
quietif True, do not echo the command output (the caller handles it based on the outcome)
Returns
a (returncode, output) tuple

Definition at line 791 of file batch.py.

◆ _swif_uri()

_swif_uri (   path)
staticprotected

Convert a filesystem path to a swif2 remote URI.

Tape paths get the 'mss:' scheme; ordinary filesystem paths (e.g. /lustre, /work) are left bare, matching both the old Auger behavior and the remote URIs observed on live JLAB workflows (swif canonicalizes tape URIs to 'mss:jlab:...' on its own). Paths that already carry a scheme are returned unchanged.

Definition at line 933 of file batch.py.

◆ _write_job_script()

_write_job_script (   self,
  job_id 
)
protected

Write an executable tcsh wrapper script that sets up the (c-shell) environment and runs the job, and return its absolute path.

The script contents reproduce the old Auger <Command> CDATA block. It is written to the log dir (on /farm_out, which is shared with the compute nodes) and passed to add-job as the job command; passing a script path avoids the shell metacharacters that swif truncates out of an inline command string.

Parameters
job_idjob ID
Returns
absolute path to the generated script

Definition at line 946 of file batch.py.

◆ parse_args()

parse_args (   self,
  args 
)

Parse command line arguments and perform setup.

Reimplemented from BatchSystem.

Definition at line 730 of file batch.py.

◆ submit()

submit (   self)

Batch submission method for Auger.

This differs from some of the other systems in that it doesn't loop over individual job IDs. Instead a single XML file is submitted for all the jobs at once.

Reimplemented from Auger.

Definition at line 768 of file batch.py.

Member Data Documentation

◆ DEFAULT_OS

str DEFAULT_OS = 'el9'
static

Default OS constraint, passed to add-job as '-constraint'.

Observed value on live JLAB workflows.

Definition at line 701 of file batch.py.

◆ DEFAULT_PROJECT

str DEFAULT_PROJECT = 'hallb-pro'
static

Default JLAB project/allocation.

Passed to add-job as '-account' (i.e. sbatch '-A'). Was "hps" in the old Auger XML; the working JLAB value is "hallb-pro". Override with '–project'.

Definition at line 695 of file batch.py.

◆ DEFAULT_SITE

str DEFAULT_SITE = 'jlab/enp'
static

Default swif2 site name, passed to 'swif2 create -site-name'.

Observed on live JLAB workflows.

Definition at line 698 of file batch.py.

◆ LEGACY_TRACK_PARTITIONS

dict LEGACY_TRACK_PARTITIONS
static
Initial value:
= {
'simulation': 'production',
'analysis': 'production',
'debug': 'priority',
'one_pass': 'production',
}

Legacy Auger "track" names (accepted by the old add-jsub) mapped to their closest valid slurm partition.

These are not slurm partitions and would be rejected by sbatch, so we remap them (with a warning).

Definition at line 708 of file batch.py.

◆ max_concurrent

max_concurrent

Definition at line 738 of file batch.py.

◆ project

project

Definition at line 736 of file batch.py.

◆ recreate

recreate

Definition at line 739 of file batch.py.

◆ setup_script

setup_script

Definition at line 963 of file batch.py.

◆ swif_site

swif_site

Definition at line 737 of file batch.py.

◆ VALID_PARTITIONS

VALID_PARTITIONS = frozenset(['production', 'ifarm', 'priority', 'jupyter', 'gpu'])
static

Valid slurm partitions on the JLAB farm (from 'sinfo').

add-job's '-partition' must be one of these.

Definition at line 704 of file batch.py.

◆ workflow

workflow

Definition at line 733 of file batch.py.


The documentation for this class was generated from the following file: