Skip to content

Commit

Permalink
Merge pull request #3111 from grondo/more-f58-jobids
Browse files Browse the repository at this point in the history
Use F58 as the default representation for JOBIDs in most user-facing commands
  • Loading branch information
mergify[bot] committed Aug 7, 2020
2 parents dd0105d + 9ad2ef7 commit 17df5bc
Show file tree
Hide file tree
Showing 26 changed files with 276 additions and 160 deletions.
13 changes: 9 additions & 4 deletions src/bindings/python/flux/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def _convert_jobspec_arg_to_string(jobspec):
if isinstance(jobspec, Jobspec):
jobspec = jobspec.dumps()
elif isinstance(jobspec, six.text_type):
jobspec = jobspec.encode("utf-8")
jobspec = jobspec.encode("utf-8", errors="surrogateescape")
elif jobspec is None or jobspec == ffi.NULL:
# catch this here rather than in C for a better error message
raise EnvironmentError(errno.EINVAL, "jobspec must not be None/NULL")
Expand Down Expand Up @@ -136,6 +136,11 @@ def encode(self, encoding="dec"):
"""Encode a JobID to alternate supported format"""
return id_encode(self, encoding)

@property
def dec(self):
"""Return decimal integer representation of a JobID"""
return self.encode()

@property
def f58(self):
"""Return RFC19 F58 representation of a JobID"""
Expand All @@ -162,10 +167,10 @@ def kvs(self):
return self.encode("kvs")

def __str__(self):
return self.encode()
return self.encode("f58")

def __repr__(self):
return f"JobID({self})"
return f"JobID({self.dec})"


class SubmitFuture(Future):
Expand Down Expand Up @@ -981,7 +986,7 @@ def setattr_shell_option(self, key, val):
self.setattr("system.shell.options." + key, val)

def dumps(self, **kwargs):
return json.dumps(self.jobspec, **kwargs)
return json.dumps(self.jobspec, ensure_ascii=False, **kwargs)

@property
def resources(self):
Expand Down

0 comments on commit 17df5bc

Please sign in to comment.