Page MenuHomeSoftware Heritage

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

Authored by douardda on Sep 10 2020, 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

Event Timeline

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

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]":

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

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.

This revision is now accepted and ready to land.Sep 10 2020, 6:48 PM