Enrol harnesses in the registry, not the package init - #743
Merged
Merged
Conversation
Every import of a harnesses leaf module ran the package init, which loaded all harnesses and, through providers, druks.sandbox.client. Sandbox imports harnesses leaf modules, so importing druks.workspaces or druks.sandbox.client first hit a partially initialized module. The registry is the only reader of the enrolled subclasses, so it now imports the harness modules.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
python -c "import druks.workspaces"andpython -c "import druks.sandbox.client"failed with a circular import on a fresh interpreter.Any import of a
druks.harnessesleaf module (exceptions,artifacts,datastructures) randruks/harnesses/__init__.py. That init imported every harness, andprovidersimportsdruks.sandbox.client. Sandbox imports those leaf modules itself, so a process that imported sandbox first reacheddruks.sandbox.hostordruks.sandbox.clientwhile it was only partially initialized.harnesses/registry.pyis the only reader of the enrolledHarnesssubclasses, so the harness imports move there. The package init is now empty. A leaf import no longer loads the harnesses.This also fixes the standalone import of
druks.chat.bridge,druks.sandbox.host,druks.sandbox.repo, anddruks.sandbox.runner.