PERF: delay preset sync until tab completion is accessed #1317
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.
Description
Delays preset file reading until tab-completion has been attempted. Stashes this information on the device instance itself. This is not the default behavior, and you must opt into this by supplying the optional argument
defer_loading
tosetup_presets_paths
Motivation and Context
Presets have taken a very long time to load recently, and the first place to look is often file i/o. This delays this as long as possible while attempting to preserve the behavior hutch scientists use: tab completion.
This has also been made optional. Both
setup_presets_paths
andPresets.sync()
now take an optionaldefer_loading
argument, that if true will skip the preset data loading stepIn a nutshell:
Presets.sync()
method callPresets.sync()
withdefer_loading=False
(the default)How Has This Been Tested?
Tests pass
Tested interactively through hutch-python, loading some subset of 559 xcs presets
There's some variation but I'm not going to do a battery of tests here
Why isn't this just 0 s?
There's still some path access going on in hutch-python, it's just stopping short of actually opening the presets file.
Where Has This Been Documented?
This PR, a stray comment
Pre-merge checklist