Skip to content

Commit

Permalink
make SchedResourceList optional in flux.job.info
Browse files Browse the repository at this point in the history
Problem: We currently cannot package rlist.h with the install (at
least without more work) and since this is a required import for
flux.job.info, without it the Python bindings (installed via pip)
will error.
Solution: the flux.resource module is not technically required,
so we can fallback to catching the ImportError instead and using
the same empty (dummy) class to handle self.resources

Signed-off-by: vsoch <vsoch@users.noreply.github.com>
  • Loading branch information
vsoch committed May 3, 2023
1 parent e79b7fd commit ed8b0ac
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/bindings/python/flux/job/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,13 @@
from flux.job.JobID import JobID
from flux.job.stats import JobStats
from flux.memoized_property import memoized_property
from flux.resource import SchedResourceList
from flux.uri import JobURI

try:
from flux.resource import SchedResourceList
except ImportError:
SchedResourceList = None


def statetostr(stateid, fmt="L"):
return raw.flux_job_statetostr(stateid, fmt).decode("utf-8")
Expand Down Expand Up @@ -212,7 +216,7 @@ class InstanceInfo:
def __init__(self, uri=None):
self.initialized = False
try:
if not uri:
if not uri or SchedResourceList is None:
raise ValueError
handle = flux.Flux(str(uri))
future = handle.rpc("sched.resource-status")
Expand Down

0 comments on commit ed8b0ac

Please sign in to comment.