Skip to content

Commit be9395c

Browse files
authored
some more doc fixes (#287)
* Some more docstring enhancements * clean before building docs * enable autorefs and more markdown extensions
1 parent 4ec608e commit be9395c

File tree

12 files changed

+55
-22
lines changed

12 files changed

+55
-22
lines changed

mkdocs.yml

+9
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ theme:
2525
name: Switch to dark mode
2626
- media: "(prefers-color-scheme: dark)"
2727
scheme: slate
28+
accent: lime
2829
toggle:
2930
icon: material/brightness-4
3031
name: Switch to light mode
@@ -35,6 +36,7 @@ theme:
3536
plugins:
3637
- search
3738
- awesome-pages
39+
- autorefs
3840
- mike
3941
- mkdocstrings:
4042
handlers:
@@ -51,6 +53,13 @@ markdown_extensions:
5153
- admonition
5254
- pymdownx.snippets:
5355
check_paths: true
56+
- pymdownx.highlight:
57+
anchor_linenums: true
58+
line_spans: __span
59+
pygments_lang_class: true
60+
- pymdownx.inlinehilite
61+
- pymdownx.superfences
62+
- pymdownx.details
5463

5564
extra:
5665
version:

pyslurm/core/job/job.pxd

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ from pyslurm.slurm cimport (
6868

6969

7070
cdef class Jobs(dict):
71-
"""A collection of Job objects.
71+
"""A collection of [pyslurm.Job][] objects.
7272
7373
Args:
7474
jobs (Union[list, dict], optional=None):

pyslurm/core/job/job.pyx

+9-13
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,9 @@ cdef class Jobs(dict):
167167
This function fills in the "steps" attribute for all Jobs in the
168168
collection.
169169
170-
Note: Pending Jobs will be ignored, since they don't have any Steps
171-
yet.
170+
!!! note
171+
172+
Pending Jobs will be ignored, since they don't have any Steps yet.
172173
173174
Raises:
174175
RPCError: When retrieving the Job information for all the Steps
@@ -241,7 +242,8 @@ cdef class Job:
241242
242243
Implements the slurm_load_job RPC.
243244
244-
Note:
245+
!!! note
246+
245247
If the Job is not pending, the related Job steps will also be
246248
loaded.
247249
@@ -454,8 +456,6 @@ cdef class Job:
454456
release the Job again. If you specify the mode as "user", the
455457
User will also be able to release the job.
456458
457-
Note: Uses the modify() function to set the Job's priority to 0.
458-
459459
Raises:
460460
RPCError: When holding the Job was not successful.
461461
@@ -478,9 +478,6 @@ cdef class Job:
478478
def release(self):
479479
"""Release a currently held Job, allowing it to be scheduled again.
480480
481-
Note: Uses the modify() function to reset the priority back to
482-
be controlled by the slurmctld's priority calculation routine.
483-
484481
Raises:
485482
RPCError: When releasing a held Job was not successful.
486483
@@ -1223,14 +1220,13 @@ cdef class Job:
12231220
def get_resource_layout_per_node(self):
12241221
"""Retrieve the resource layout of this Job on each node.
12251222
1226-
The dict returned contains the following information for each node:
1227-
* cpu_ids (str)
1228-
* gres (dict)
1229-
* memory (int)
1223+
!!! warning
1224+
1225+
Return type may still be subject to change in the future
12301226
12311227
Returns:
12321228
(dict): Resource layout, where the key is the name of the name and
1233-
its value another dict with the components described above.
1229+
its value another dict with the CPU-ids, memory and gres.
12341230
"""
12351231
# The code for this function is a modified reimplementation from here:
12361232
# https://github.com/SchedMD/slurm/blob/d525b6872a106d32916b33a8738f12510ec7cf04/src/api/job_info.c#L739

pyslurm/core/job/step.pxd

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ from pyslurm.core.job.task_dist cimport TaskDistribution
5050

5151

5252
cdef class JobSteps(dict):
53-
"""A collection of [`pyslurm.JobStep`][] objects for a given Job.
53+
"""A collection of [pyslurm.JobStep][] objects for a given Job.
5454
5555
Args:
5656
job (Union[Job, int]):

pyslurm/core/job/submission.pxd

+2-2
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,8 @@ cdef class JobSubmitDescription:
312312
313313
* "no" or "exclusive"
314314
No sharing of resources is allowed. (--exclusive from sbatch)
315-
distribution (Union[dict, str]):
316-
TODO
315+
distribution (str):
316+
Task distribution for the Job, same as --distribution from sbatch
317317
time_limit (str):
318318
The time limit for the job.
319319
This is the same as -t/--time from sbatch.

pyslurm/core/job/submission.pyx

+24
Original file line numberDiff line numberDiff line change
@@ -105,11 +105,35 @@ cdef class JobSubmitDescription:
105105
def load_environment(self, overwrite=False):
106106
"""Load values of attributes provided through the environment.
107107
108+
!!! note
109+
110+
Instead of `SBATCH_`, pyslurm uses `PYSLURM_JOBDESC_` as a prefix to
111+
identify environment variables which should be used to set
112+
attributes.
113+
108114
Args:
109115
overwrite (bool):
110116
If set to True, the value from an option found in the
111117
environment will override the current value of the attribute
112118
in this instance. Default is False
119+
120+
Examples:
121+
Lets consider you want to set the name of the Job and its
122+
Account name. Therefore, you will need to have set these two
123+
environment variables:
124+
125+
```bash
126+
export PYSLURM_JOBDESC_ACCOUNT="myaccount"
127+
export PYSLURM_JOBDESC_NAME="myjobname"
128+
```
129+
130+
In python, you can do this now:
131+
132+
>>> import pyslurm
133+
>>> desc = pyslurm.JobSubmitDescription(...other args...)
134+
>>> desc.load_environment()
135+
>>> print(desc.name, desc.account)
136+
myjobname, myaccount
113137
"""
114138
self._parse_env(overwrite)
115139

pyslurm/core/node.pxd

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ from pyslurm.utils.uint cimport *
5858

5959

6060
cdef class Nodes(dict):
61-
"""A collection of Node objects.
61+
"""A collection of [pyslurm.Node][] objects.
6262
6363
Args:
6464
nodes (Union[list, dict, str], optional=None):

pyslurm/core/node.pyx

+3-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ cdef class Nodes(dict):
131131
def reload(self):
132132
"""Reload the information for nodes in a collection.
133133
134-
Note: Only information for nodes which are already in the collection at
134+
!!! note
135+
136+
Only information for nodes which are already in the collection at
135137
the time of calling this method will be reloaded.
136138
137139
Raises:

pyslurm/db/job.pxd

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ cdef class JobSearchFilter:
149149

150150

151151
cdef class Jobs(dict):
152-
"""A collection of [`pyslurm.db.Job`][] objects."""
152+
"""A collection of [pyslurm.db.Job][] objects."""
153153
cdef:
154154
SlurmList info
155155
Connection db_conn

pyslurm/db/stats.pxd

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ from pyslurm.utils cimport cstr
3737
cdef class JobStatistics:
3838
"""Statistics for a Slurm Job or Step.
3939
40-
Note:
40+
!!! note
41+
4142
For more information also see the sacct manpage.
4243
4344
Attributes:

pyslurm/db/step.pxd

+1-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ from pyslurm.db.tres cimport TrackableResources, TrackableResource
4444

4545

4646
cdef class JobSteps(dict):
47-
"""A collection of [`pyslurm.db.JobStep`][] objects"""
47+
"""A collection of [pyslurm.db.JobStep][] objects"""
4848
pass
4949

5050

scripts/builddocs.sh

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#!/bin/bash
22

3+
python setup.py clean
34
pip install -r doc_requirements.txt
45
pip install --no-build-isolation -e .
56
mkdocs build

0 commit comments

Comments
 (0)