Skip to content

Commit

Permalink
Merge pull request flux-framework#4134 from grondo/issue#3614
Browse files Browse the repository at this point in the history
python: return `JobID` from flux.job.submit, not `int`
  • Loading branch information
mergify[bot] authored Feb 15, 2022
2 parents 10ad36b + fe2dbce commit db2c75e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
5 changes: 3 additions & 2 deletions src/bindings/python/flux/job/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from flux import constants
from flux.util import check_future_error
from flux.future import Future
from flux.job import JobID
from flux.job.Jobspec import _convert_jobspec_arg_to_string
from flux.job._wrapper import _RAW as RAW
from _flux._core import ffi, lib
Expand Down Expand Up @@ -89,14 +90,14 @@ def submit_get_id(future):
:param future: a Flux future object returned by job.submit_async()
:type future: Future
:returns: job ID
:rtype: int
:rtype: JobID
"""
if future is None or future == ffi.NULL:
raise EnvironmentError(errno.EINVAL, "future must not be None/NULL")
future.wait_for() # ensure the future is fulfilled
jobid = ffi.new("flux_jobid_t[1]")
RAW.submit_get_id(future, jobid)
return int(jobid[0])
return JobID(jobid[0])


def submit(
Expand Down
6 changes: 3 additions & 3 deletions src/cmd/flux-mini.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

import flux
from flux import job
from flux.job import JobspecV1, JobID
from flux.job import JobspecV1
from flux import util
from flux import debugged
from flux.idset import IDset
Expand Down Expand Up @@ -675,7 +675,7 @@ def submit_async(self, args, jobspec=None):
)

def submit(self, args, jobspec=None):
return JobID(self.submit_async(args, jobspec).get_id())
return self.submit_async(args, jobspec).get_id()

def get_parser(self):
return self.parser
Expand Down Expand Up @@ -938,7 +938,7 @@ def event_watch_cb(self, future, args, jobinfo, label=""):

def submit_cb(self, future, args, label=""):
try:
jobid = JobID(future.get_id())
jobid = future.get_id()
if not args.quiet:
print(jobid, file=args.stdout)
except OSError as exc:
Expand Down
4 changes: 2 additions & 2 deletions src/test/throughput.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import flux
from flux import job
from flux.job import JobspecV1, JobID
from flux.job import JobspecV1
from flux.progress import Bottombar


Expand Down Expand Up @@ -155,7 +155,7 @@ def handle_submit(self, args, jobid):
def submit_cb(self, future, args):
# pylint: disable=broad-except
try:
self.handle_submit(args, JobID(future.get_id()))
self.handle_submit(args, future.get_id())
except Exception as exc:
print(f"Submission failed: {exc}", file=sys.stderr)

Expand Down

0 comments on commit db2c75e

Please sign in to comment.