-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
python: fix handling of JobInfo properties and to_dict()
method with missing attributes
#5493
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
Problem: When a JobInfo is not fully populated with attributes, e.g. when not all attrs were requested in a job-list RPC, or when using flux.job.result(), the to_dict() method raises an AttributeError exception because some derived attributes are not present in the JobInfo object. Skip attributes that raise AttributeError.
Problem: If the status and/or expiration properties of a JobInfo object are not set, then getting the t_remaining attribute throws an AttributeError, but this attribute should instead be set to 0.0 when unset. Add a try/except block around the calculation of remaining time and return 0.0 for this attribute if AttributeError or KeyError are caught.
Problem: Testing of the returned JobInfo objects from flux.job.result() does not include ensuring that the to_dict method works and that accessing the t_remaining property doesn't raise an exception. Enhance the testing of flux.job.result() to include this testing.
Codecov Report
@@ Coverage Diff @@
## master #5493 +/- ##
=======================================
Coverage 83.65% 83.65%
=======================================
Files 484 484
Lines 81487 81493 +6
=======================================
+ Hits 68169 68176 +7
+ Misses 13318 13317 -1
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much Mark!
I tested it in a container with the same commands I put in #5491 and it works great. |
Thanks @jameshcorbett and @wihobbs. I'll set MWP. |
This PR fixes #5491, however it does it in two ways
t_remaining
JobInfo
attribute whenexpiration
and/orstatus
attrs are missingto_dict()
This allows
to_dict()
to work withJobInfo
objects returned fromflux.job.result()
.