Skip to content

Commit

Permalink
python: add flux.job.list docstrings
Browse files Browse the repository at this point in the history
  • Loading branch information
wihobbs committed Oct 12, 2023
1 parent 75d0379 commit 8fba3dc
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 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,13 @@

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 +79,9 @@ def job_list(
def job_list_inactive(
flux_handle, since=0.0, max_entries=1000, attrs=["all"], name=None, queue=None
):
"""
List only inactive jobs
"""
return job_list(
flux_handle,
max_entries=max_entries,
Expand All @@ -96,12 +103,22 @@ def get_job(self):
return self.get()["job"]

def get_jobinfo(self):
"""
Returns a JobInfo object for the job.
"""
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"]):
"""Watch a job by providing an ID.
This is a non-blocking function that allows users to asynchronously
get job event data. Returns a RPC future that is fulfilled each time
the job enters a new state.
: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 8fba3dc

Please sign in to comment.