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

Verdi: Load config / profile lazily to speed up tab-completion #6140

Merged
merged 2 commits into from
Oct 11, 2023

Commits on Oct 11, 2023

  1. CLI: Make loading of config lazy

    The `VerdiContext` class, which provides the custom context of the
    `verdi` commands, loads the configuration. This has a non-negligible
    cost and so slows down the responsiveness of the CLI. This is especially
    noticeable during tab-completion.
    
    The `obj` custom object of the `VerdiContext` is replaced with a
    subclass of `AttributeDict` that lazily populates the `config` key when
    it is called with the loaded `Config` class. In addition, the defaults
    of some options of the `verdi setup` command, which load a value from
    the config and so require the config, are turned into partials such that
    they also are lazily evaluated. These changes should give a reduction in
    load time of `verdi` of the order of ~50 ms.
    
    A test of `verdi setup` had to be updated to explicitly provide a value
    for the email. This is because now the default is evaluated lazily, i.e.
    when the command is actually called in the test. At this point, there is
    no value for this config option and so the default is empty. Before, the
    default would be evaluated as soon as `aiida.cmdline.commands.cmd_setup`
    was imported, at which point an existing config would still contain
    these values, binding them to the default, even if the config would be
    reset afterwards before the test.
    danielhollas authored and sphuber committed Oct 11, 2023
    Configuration menu
    Copy the full SHA
    64111ab View commit details
    Browse the repository at this point in the history
  2. minor touchups

    sphuber committed Oct 11, 2023
    Configuration menu
    Copy the full SHA
    d7f78c3 View commit details
    Browse the repository at this point in the history