Skip to content

[v2] Implement lazy plugin initialization#10356

Merged
aemous merged 5 commits into
lazy-plugin-initializationfrom
pr/lazy-plugins
May 29, 2026
Merged

[v2] Implement lazy plugin initialization#10356
aemous merged 5 commits into
lazy-plugin-initializationfrom
pr/lazy-plugins

Conversation

@aemous
Copy link
Copy Markdown
Contributor

@aemous aemous commented May 27, 2026

Issue #, if available:

Notes:

  • This PR (4/4) is part of an ongoing effort to reduce AWS CLI initialization time by lazily deferring plugins until they are needed. This PR uses the constructs introduced in previous PRs to lazily import plugins when they are needed (event emission time, command invocation time, and/or help docs generation time).

Description of changes:

  • Switch from using HierarchicalEmitter to LazyInitEmitter to facilitate lazy plugin loading.
  • Delete handlers.py and load plugin registry from plugin.py.
  • Update exe/pyinstaller/hook-awscli.py, to dynamically import builtin plugin modules from the plugin registry.
  • Update a few functional/unit tests that previously used register() against events, to use register_last() instead. This is required for the tests to pass, because previously the tests would register after the builtin handlers in botocore, but since switching to lazy initialization, the test code would run before the boto handlers are executed.
  • Add tests that improve test coverage on the lazy plugin initialization components.
  • Add clarifying comments to tests/unit/test_lazy_emitter.py.
  • Add changelog entry.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@aemous aemous requested a review from a team May 27, 2026 16:02
@aemous aemous added v2 performance This PR or issue is related to performance. labels May 27, 2026
@aemous aemous changed the title [v2] Implement lazy plugin initialization. [v2] Implement lazy plugin initialization May 27, 2026
@hssyoo hssyoo self-requested a review May 28, 2026 14:23
Copy link
Copy Markdown
Contributor

@hssyoo hssyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, had a few minor comments

Comment thread awscli/plugin.py Outdated
Comment thread exe/pyinstaller/hook-awscli.py Outdated
Comment thread tests/functional/test_handlers_registry.py
Comment thread tests/functional/test_lazy.py Outdated
@aemous aemous requested a review from hssyoo May 29, 2026 16:03
Copy link
Copy Markdown
Contributor

@hssyoo hssyoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🏆

@aemous aemous merged commit 34dfb7e into lazy-plugin-initialization May 29, 2026
143 of 145 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance This PR or issue is related to performance. v2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants