Skip to content
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

humanize granularity doesn't behave as expected #727

Closed
chimaerase opened this issue Dec 6, 2019 · 1 comment · Fixed by #748
Closed

humanize granularity doesn't behave as expected #727

chimaerase opened this issue Dec 6, 2019 · 1 comment · Fixed by #748
Labels

Comments

@chimaerase
Copy link

Issue Description

I'd like to use humanize() to print out human (engineer)-readable durations for a potentially long-running data processing pipeline I'm working on.

For my pipeline, the useful precision for duration output depends on how long a given run takes to execute, and can span seconds to hours. I'd settled on seconds as a useful metric for logging approximate runtime, but humanize() doesn't seem to be giving me the expected output when I add the granularity argument.

>> import arrow
>> now = arrow.utcnow()
>> mins = now.shift(seconds=-200)
>>> mins.humanize(now, only_distance=True)
'3 minutes'
>>> mins.humanize(now, only_distance=True, granularity="second")
'seconds'

I'd expected the final statement to ideally evaluate to "3 minutes 20 seconds", or at least to "200 seconds". If "granularity" is intended to convey a seconds remainder, e.g. in this case of "3 minutes 20 seconds" the output should still be "20 seconds". It's also worth noting that I thought the documentation on the granularity argument could use some fleshing out to disambiguate cases like i've mentioned here.

System Info

  • 🖥 OS name and version: alpine3.9
  • 🐍 Python version: Python 3.7.3 -->
  • 🏹 Arrow version: 0.15.4
@chimaerase chimaerase added the bug label Dec 6, 2019
@systemcatch
Copy link
Collaborator

Hey @chimaerase we have a PR open right now (#722) which should solve the "3 minutes 20 seconds" part of your question.

As to the first part of your post it's definitely a possible bug in humanize, or at the very least surprising behavior. I think it wasn't designed for precision (anything from 10 to 44 seconds returns seconds ago) when granularity is auto. From the looks of it granularity = "second" needs to be altered to allow greater precision.

@jadchaar jadchaar changed the title humanize() granularity doesn't behave as expected humanize granularity doesn't behave as expected Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants