-
Notifications
You must be signed in to change notification settings - Fork 679
MAINT Add run_initializers_async, Entra auth, and config-file support #1418
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -284,14 +284,33 @@ async def initialize_pyrit_async( | |||||||||
| ) | ||||||||||
| CentralMemory.set_memory_instance(memory) | ||||||||||
|
|
||||||||||
| # Combine directly provided initializers with those loaded from scripts | ||||||||||
| await run_initializers_async(initializers=initializers, initialization_scripts=initialization_scripts) | ||||||||||
|
|
||||||||||
|
|
||||||||||
| async def run_initializers_async( | ||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little worried about this as is. I think there are three things we need to make sure we've thought through:
Because these are all lumped together, I like keeping it bundled. There is some performance hit because we're nuking the state and resetting things, reloading env... but I don't think it's a huge deal. And in some ways it's nice (e.g. if we update the .env file). It's a bit awkard to re-call, but I think it makes it less error prone. The biggest reason I think we'd want to separate is if we're doing additive initializer execution, but I don't think that's something we want near term? |
||||||||||
| *, | ||||||||||
| initializers: Optional[Sequence["PyRITInitializer"]] = None, | ||||||||||
| initialization_scripts: Optional[Sequence[Union[str, pathlib.Path]]] = None, | ||||||||||
| ) -> None: | ||||||||||
| """ | ||||||||||
| Run initializers and initialization scripts without re-initializing memory or environment. | ||||||||||
|
|
||||||||||
| This is useful when memory and environment are already set up (e.g. via | ||||||||||
| :func:`initialize_pyrit_async`) and only the initializer step needs to run. | ||||||||||
|
|
||||||||||
| Args: | ||||||||||
| initializers: Optional sequence of PyRITInitializer instances to execute directly. | ||||||||||
| initialization_scripts: Optional sequence of Python script paths containing | ||||||||||
| PyRITInitializer classes. | ||||||||||
|
|
||||||||||
| Raises: | ||||||||||
| ValueError: If initializers are invalid or scripts cannot be loaded. | ||||||||||
|
||||||||||
| ValueError: If initializers are invalid or scripts cannot be loaded. | |
| ValueError: If one or more provided initializers are invalid. | |
| FileNotFoundError: If an initialization script path does not exist. | |
| Exception: If an error occurs while importing initialization scripts or executing initializers. |
Copilot
AI
Mar 1, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
run_initializers_async is a new public API surface but there are no unit tests covering its behavior (e.g., that it loads initializers from scripts, executes in execution_order, and does not reset defaults / reinitialize memory). Since initialize_pyrit_async already has orchestration tests, consider adding focused tests for this new function as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
probably too big for here, but one thing on my mind is it'd be nice to pass constructor arguments to initializers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also probably execution order; rn it's built into the class but maybe it should actually be the order we call it or something.