perf: refactor wizard to avoid expensive imports at CLI startup #615
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR Goal?
On the login node on GPSC-C, the CLI can take 4 or 5 seconds to respond to a
<tab>
because it's loading a lot of stuff. The biggest culprits are typer, rich, and other things required to actually provide CLI help and autocompletion, but I noticed the wizard is doing some imports we can defer too, so I refactored it.This results in a 15% or so speed up of
everyvoice -h
once already loaded from cache, and I'm not sure how much on a first try when not in disk cache yet (that's harder to measure!). Not the big difference I was hoping for, but still worth committing and pushing.Plus, the refactored code is a little cleaner than the original imho.
Feedback sought?
Regular review
The diff will look huge, but it's not: stuff removed from
wizard/__init__.py
has been moved verbatim towizard/tour.py
.Priority?
low
Tests added?
was already covered, adjusted where needed
How to test?
run
everyvoice test cli
and maybeeveryvoice new-project
and see no failures.Confidence?
high: this is just moving definitions from one file to another, using VSCode's refactoring tools and then testing and adjusting the few little bits it didn't handle.
Note: I thought of having the Step classes in
step.py
and the Tour class intour.py
, but doing so created circular imports since each uses the other for typing hints, and therefore I decided it made most sense to keep them all together intour.py
.Version change?
no
Related PRs?