Skip to content

Commit

Permalink
python: add flux.job.list docstrings
Browse files Browse the repository at this point in the history
Problem: Some flux.job.list functions are undocumented.

Solution: Add docstrings.
  • Loading branch information
wihobbs committed Oct 14, 2023
1 parent c26f97f commit 3e8fd51
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/bindings/python/flux/job/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,14 @@

class JobListRPC(RPC):
def get_jobs(self):
"""Returns all jobs in the RPC."""
return self.get()["jobs"]

def get_jobinfos(self):
"""Yields a JobInfo object for each job in its current state.
:rtype: JobInfo
"""
for job in self.get_jobs():
yield JobInfo(job)

Expand Down Expand Up @@ -75,6 +80,7 @@ def job_list(
def job_list_inactive(
flux_handle, since=0.0, max_entries=1000, attrs=["all"], name=None, queue=None
):
"""Same as ``flux.job.list.job_list``, but lists only inactive jobs."""
return job_list(
flux_handle,
max_entries=max_entries,
Expand All @@ -96,12 +102,24 @@ def get_job(self):
return self.get()["job"]

def get_jobinfo(self):
"""Returns a ``JobInfo`` object for the job.
:rtype: JobInfo
"""
return JobInfo(self.get_job())


# list-id is not like list or list-inactive, it doesn't return an
# array, so don't use JobListRPC
def job_list_id(flux_handle, jobid, attrs=["all"]):
"""Query job information for a single ``jobid``.
Sends an RPC to the job-list module to query information about the provided jobid.
Use the ``get_job()`` or ``get_jobinfo()`` method on the returned ``JobListIdRPC`` to
obtain the job data as a dict or a JobInfo object.
:rtype: JobListIdRPC
"""
payload = {"id": int(jobid), "attrs": attrs}
rpc = JobListIdRPC(flux_handle, "job-list.list-id", payload)
# save original JobId argument for error reporting
Expand Down

0 comments on commit 3e8fd51

Please sign in to comment.