Skip to content

Commit bf0f8d3

Browse files
committed
Documented custom attributes a bit better
1 parent 66af485 commit bf0f8d3

File tree

6 files changed

+28
-0
lines changed

6 files changed

+28
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,5 @@ psi_j_python.egg-info/
1717
venv*
1818
.venv*
1919
build/
20+
docs/.web-build
21+
web-build/

src/psij/executors/batch/cobalt.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ class CobaltJobExecutor(BatchSchedulerExecutor):
3636
monitor, and cancel jobs.
3737
3838
Creates a batch script with #COBALT directives when submitting a job.
39+
40+
Custom attributes prefixed with `cobalt.` are rendered as long-form directives in the script.
41+
For example, setting `custom_attributes['cobalt.m'] = 'co'` results in the `#COBALT --m=co`
42+
directive being placed in the submit script.
3943
"""
4044

4145
# see https://Cobalt.schedmd.com/squeue.html

src/psij/executors/batch/lsf.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ class LsfJobExecutor(BatchSchedulerExecutor):
3535
monitor, and cancel jobs.
3636
3737
Creates a batch script with #BSUB directives when submitting a job.
38+
39+
Renders all custom attributes of the form `lsf.<name>` into the corresponding
40+
LSF directive. For example, setting
41+
`job.spec.attributes.custom_attributes['lsf.core_isolation'] = '0' results in a
42+
`#BSUB -core_isolation 0` directive being placed in the submit script.
3843
"""
3944

4045
# see https://www.ibm.com/docs/en/spectrum-lsf/10.1.0?topic=bjobs-description

src/psij/executors/batch/pbs_base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ class GenericPBSJobExecutor(BatchSchedulerExecutor):
5858
monitor, and cancel jobs.
5959
6060
Creates a batch script with #PBS directives when submitting a job.
61+
62+
Custom attributes prefixed with `pbs.` are rendered as directives in the script.
63+
For example, setting `custom_attributes['pbs.c'] = 'n'` results in the `#PBS -c n`
64+
directive being placed in the submit script, which disables checkpointing.
6165
"""
6266

6367
def __init__(self, generator: TemplatedScriptGenerator, url: Optional[str] = None,

src/psij/executors/batch/slurm.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ class SlurmJobExecutor(BatchSchedulerExecutor):
2828
monitor, and cancel jobs.
2929
3030
Creates a batch script with #SBATCH directives when submitting a job.
31+
32+
Renders all custom attributes set on a job's attributes with a `slurm.` prefix into
33+
corresponding Slurm directives with long-form parameters. For example,
34+
`job.spec.attributes.custom_attributes['slurm.qos'] = 'debug'` causes a directive
35+
`#SBATCH --qos=debug` to be placed in the submit script.
3136
"""
3237

3338
# see https://slurm.schedmd.com/squeue.html

src/psij/job_attributes.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,14 @@ def __init__(self, duration: timedelta = timedelta(minutes=10),
3131
:param custom_attributes: Specifies a dictionary of custom attributes. Implementations of
3232
:class:`~psij.JobExecutor` define and are responsible for interpreting custom
3333
attributes.
34+
The typical usage scenario for custom attributes is to pass information to the executor
35+
or underlying job execution mechanism that cannot otherwise be passed using the classes
36+
and properties provided by PSI/J. A specific example is that of the subclasses of
37+
:class:`~psij.executors.batch.batch_scheduler_executor.BatchSchedulerExecutor`, which
38+
look for custom attributes prefixed with their name and a dot (e.g., `slurm.constraint`,
39+
`pbs.c`, `lsf.core_isolation`) and translate them into the corresponding batch
40+
scheduler directives (e.g., `#SLURM --constraint=...`, `#PBS -c ...`,
41+
`#BSUB -core_isolation ...`).
3442
3543
All constructor parameters are accessible as properties.
3644
"""

0 commit comments

Comments
 (0)