-
Notifications
You must be signed in to change notification settings - Fork 979
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
Display consistent format for job runtime #10504
Conversation
@jmchilton or @dannon |
Can we also have a unit test for
If this is too annoying to handle, I think there might be a library for this. |
@kxk302 This looks great to me -- that was definitely a bug before, good catch. Do you want to rebase this branch to drop the other commits related to the vscode config? |
I can add unit tests for sure, probably tomorrow though. |
I can cherry-pick this change into my other branch, so we'd have 1 PR. Would that work? |
@kxk302 I think it's fine to leave this as a separate PR since it's totally unrelated. I'd just do a simple |
Got it. Sorry I become slower near the end of the day :) |
331a280
to
d8bb1b6
Compare
@dannon Updated string formatting |
@kxk302 Thanks. Next time you can just 'accept suggestions' (in batch if there are multiple), too, and it'll make a commit for you, also crediting the suggester. |
Added unit tests. |
The only check failing seems to client test (ToolsView.test.js). I don't think this is related to my code change. Could someone please verify and if so merge this? Thanks. |
Co-authored-by: Nicola Soranzo <nicola.soranzo@gmail.com>
@kxk302 thank you for adding the test! See my inline comment. Plural vs. singular - up to you. I'm OK either way. |
@ic4f I updated the method and the test to handle singular/plural seconds/minutes. Made the method a bit convoluted, but I guess nobody can pick on the grammar :) |
lib/galaxy/job_metrics/formatting.py
Outdated
@@ -12,9 +12,25 @@ def seconds_to_str(value): | |||
"""Convert seconds to a simple simple string describing the amount of time.""" | |||
mins, secs = divmod(value, 60) | |||
hours, mins = divmod(mins, 60) | |||
if value < 60: | |||
|
|||
if value == 0: |
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.
Great! As a suggestion, you could simplify this, if you like. It's just 3 cases: value < 60; if not then value < 3600; and the rest - i.e., if/elif/else. As for the s
suffix - you could pre-calculate it: it's ''
or 's'
for secs/mins/hours depending on whether they == 1
.
Co-authored-by: Nicola Soranzo <nicola.soranzo@gmail.com>
Co-authored-by: Nicola Soranzo <nicola.soranzo@gmail.com>
Co-authored-by: Nicola Soranzo <nicola.soranzo@gmail.com>
Co-authored-by: Nicola Soranzo <nicola.soranzo@gmail.com>
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.
Thank you for making all the changes, looks great!
This fixes the formatting reported in #10473