Skip to content

Commit 7b6a459

Browse files
authored
Merge pull request #5259 from chu11/python_joblist_jobid
python: allow JobID to take a JobID
2 parents 434fdf6 + 64d580e commit 7b6a459

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

src/bindings/python/flux/job/JobID.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ class JobID(int):
5353
"""
5454

5555
def __new__(cls, value):
56+
if isinstance(value, JobID):
57+
return cls(value.orig_str)
5658
if isinstance(value, int):
5759
jobid = value
5860
else:

src/bindings/python/flux/job/list.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
import flux.constants
1515
from flux.future import WaitAllFuture
16+
from flux.job import JobID
1617
from flux.job.info import JobInfo
1718
from flux.rpc import RPC
1819

@@ -211,7 +212,7 @@ def __init__(
211212
self.since = since
212213
self.name = name
213214
self.queue = queue
214-
self.ids = ids
215+
self.ids = list(map(JobID, ids)) if ids else None
215216
self.errors = []
216217
for fname in filters:
217218
for x in fname.split(","):

t/python/t0010-job.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -468,6 +468,12 @@ def test_24_jobid(self):
468468
# Ensure encode back to same type works
469469
self.assertEqual(getattr(jobid, key), test[key])
470470

471+
# JobID can also take a JobID
472+
jobid1 = job.JobID(1234)
473+
jobid2 = job.JobID(jobid1)
474+
self.assertEqual(jobid1, jobid2)
475+
self.assertEqual(jobid2.orig, "1234")
476+
471477
def test_25_job_list_attrs(self):
472478
expected_attrs = [
473479
"userid",

0 commit comments

Comments
 (0)