Page MenuHomeSoftware Heritage

cli: speedup the `swh` cli command startup time
ClosedPublic

Authored by douardda on Thu, Sep 10, 3:59 PM.

Details

Summary

by moving import statements in functions and using conditional
import of typechecking modules (especially StorageInterface which
triggers the loading of 300+ modules).

Related to T2575.

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

douardda created this revision.Thu, Sep 10, 3:59 PM

Build has FAILED

Patch application report for D3907 (id=13766)

Rebasing onto b24be0c78f...

Current branch diff-target is up to date.
Changes applied before test
commit 8f15eb8ab23cfd82dd1763e0340946b69fbb1868
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Sep 10 11:25:08 2020 +0200

    cli: speedup the `swh` cli command startup time
    
    by moving import statements in functions and using conditional
    import of typechecking modules (especially StorageInterface which
    triggers the loading of 300+ modules).
    
    Related to T2575.

Link to build: https://jenkins.softwareheritage.org/job/DSCH/job/tests-on-diff/58/
See console output for more information: https://jenkins.softwareheritage.org/job/DSCH/job/tests-on-diff/58/console

douardda updated this revision to Diff 13779.Thu, Sep 10, 4:23 PM

add warnings

Build has FAILED

Patch application report for D3907 (id=13779)

Rebasing onto b24be0c78f...

Current branch diff-target is up to date.
Changes applied before test
commit 8f15eb8ab23cfd82dd1763e0340946b69fbb1868
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Sep 10 11:25:08 2020 +0200

    cli: speedup the `swh` cli command startup time
    
    by moving import statements in functions and using conditional
    import of typechecking modules (especially StorageInterface which
    triggers the loading of 300+ modules).
    
    Related to T2575.

Link to build: https://jenkins.softwareheritage.org/job/DSCH/job/tests-on-diff/59/
See console output for more information: https://jenkins.softwareheritage.org/job/DSCH/job/tests-on-diff/59/console

vlorentz added inline comments.
swh/scheduler/cli/task.py
303–307

you can probably do it with strings, which is cleaner:

def iter_origins(
    storage: "StorageInterface",
    page_token: "Optional[str]" = None,
) -> "Iterator[Origin]":
douardda updated this revision to Diff 13808.Thu, Sep 10, 5:32 PM

use string annotation instead of comment one, as suggested by vlorentz

Build has FAILED

Patch application report for D3907 (id=13808)

Rebasing onto b24be0c78f...

Current branch diff-target is up to date.
Changes applied before test
commit a5cfc1ca68f3408ec0f73a15dc5f1a95bc170060
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Sep 10 11:25:08 2020 +0200

    cli: speedup the `swh` cli command startup time
    
    by moving import statements in functions and using conditional
    import of typechecking modules (especially StorageInterface which
    triggers the loading of 300+ modules).
    
    Related to T2575.

Link to build: https://jenkins.softwareheritage.org/job/DSCH/job/tests-on-diff/60/
See console output for more information: https://jenkins.softwareheritage.org/job/DSCH/job/tests-on-diff/60/console

douardda updated this revision to Diff 13812.Thu, Sep 10, 5:46 PM

fix a doctest

Build is green

Patch application report for D3907 (id=13812)

Rebasing onto b24be0c78f...

Current branch diff-target is up to date.
Changes applied before test
commit f5c815435bf604e409a322dd543ef513c01afc13
Author: David Douard <david.douard@sdfa3.org>
Date:   Thu Sep 10 11:25:08 2020 +0200

    cli: speedup the `swh` cli command startup time
    
    by moving import statements in functions and using conditional
    import of typechecking modules (especially StorageInterface which
    triggers the loading of 300+ modules).
    
    Related to T2575.

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

vlorentz accepted this revision.Thu, Sep 10, 6:48 PM
This revision is now accepted and ready to land.Thu, Sep 10, 6:48 PM
This revision was automatically updated to reflect the committed changes.