Page MenuHomeSoftware Heritage

Replace usage of arrow datetime objects in favor of pure datetime ones
ClosedPublic

Authored by douardda on Dec 2 2020, 9:52 AM.

Details

Summary

Note that the arrow library remains used for its humanize() feature in the cli
pretty printing function.

Closes T2835.

Diff Detail

Repository
rDSCH Scheduling utilities
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

Build is green

Patch application report for D4642 (id=16472)

Rebasing onto 1b390a7b01...

Current branch diff-target is up to date.
Changes applied before test
commit 87d72c892939211da4ef4bb7f2d721bc51c3470a
Author: David Douard <david.douard@sdfa3.org>
Date:   Wed Dec 2 09:49:33 2020 +0100

    Replace usage of arrow datetime objects in favor of pure datetime ones
    
    Note that the arrow library remains used for its humanize() feature in the cli
    pretty printing function.
    
    Closes T2835.

See https://jenkins.softwareheritage.org/job/DSCH/job/tests-on-diff/81/ for more details.

lgtm

I'd argue to completely remove the arrow dependency though...

swh/scheduler/celery_backend/pika_listener.py
20

jsyk, we should probably move this oneliner in swh.core

it's duplicated in other modules (e.g. swh.storage.utils.now comes to mind, but not only there)...

swh/scheduler/cli/task.py
118

Can't we use something else? (i'm unsure what humanize really does)

If we keep the arrow dependency, i fear its use will come back at one point or another...

Other remarks, questions, inline.

This revision is now accepted and ready to land.Dec 2 2020, 10:09 AM
olasd added inline comments.
swh/scheduler/celery_backend/pika_listener.py
20

meh, it's a trivial oneliner, I don't think it's really worth a dependency shuffle (OTOH it's really annoying that this pattern is still not available in the stdlib)

swh/scheduler/cli/task.py
118

It turns a time interval into a human readable sentence ("a few seconds ago", ...).

I agree this feature is probably not worth the extra dependency on its own.

swh/scheduler/cli/task.py
118

(we could replace it with python-humanize, which works with native python types instead of it's own special flakes)

swh/scheduler/celery_backend/pika_listener.py
20

I'm on @olasd side here, at least for now.

swh/scheduler/cli/task.py
118

let's try with humanize (I thought we already depend on it somewhere, but cannot find the dep)

Replace usage of arrow for its humanize() feature by the humanize module

Build is green

Patch application report for D4642 (id=16505)

Rebasing onto 1b390a7b01...

Current branch diff-target is up to date.
Changes applied before test
commit 3c8707599ae1cc721c5ee80b6def30e2374725b6
Author: David Douard <david.douard@sdfa3.org>
Date:   Wed Dec 2 09:49:33 2020 +0100

    Replace usage of arrow datetime objects in favor of pure datetime ones
    
    Note that the humanize library is now used in the cli pretty printing
    function (in place of the arrow hiumanize feature).
    
    As a result, displayed output from some cli commands may slightly differ.
    
    Closes T2835.

See https://jenkins.softwareheritage.org/job/DSCH/job/tests-on-diff/82/ for more details.