fix(crew): make smallestai.atoms.crew export its public API (lazy) - #119
Merged
Merged
Conversation
crew/__init__.py was docstring-only, so 'from smallestai.atoms.crew import AtomsCrewApp' raised ImportError (customer-reported) even though the docstring advertised that path. Add a PEP 562 __getattr__ that lazily imports the public symbols (AtomsCrewApp, CrewSession, OutputCrewNode, BackgroundCrewNode, OpenAIClient, function_tool, ToolRegistry) from their submodules. Lazy so importing the package doesn't eagerly pull crew runtime deps (fastapi/uvicorn); the .server submodule paths still work. TYPE_CHECKING block keeps type/IDE resolution. Verified: package import needs no fastapi; short import resolves.
|
crim doesn't review pull requests automatically here. Comment |
Executes 'from smallestai.atoms.crew import AtomsCrewApp, CrewSession, ...' so the exact ImportError a customer hit can't silently come back. Lives in tests/custom (fernignored), runs in the SDK test CI.
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.
Why
A customer hit
ImportErroronfrom smallestai.atoms.crew import AtomsCrewApp(smallestai 5.12.0).crew/__init__.pywas docstring-only — it exported nothing, even though the docstring advertised that exact import. Only the submodule pathsmallestai.atoms.crew.serverworked. Our own docs (overview.mdx) used the broken short path too (fixed in docs #451).Fix
Add a PEP 562
__getattr__that lazily imports the public symbols from their submodules:AtomsCrewApp,CrewSession,OutputCrewNode,BackgroundCrewNode,OpenAIClient,function_tool,ToolRegistry.Lazy on purpose:
serverimportsfastapi/uvicorn, so an eagerfrom .server import ...would makeimport smallestai.atoms.crewrequire those deps. With__getattr__, the package imports with no extra deps and each symbol resolves on first access. ATYPE_CHECKINGblock preserves type-checker/IDE resolution. The.serversubmodule paths keep working.Verified
import smallestai.atoms.crewsucceeds without eagerly importing fastapi.from smallestai.atoms.crew import AtomsCrewApp(the customer's failing line) resolves.__all__/__dir__populated; unknown attribute raisesAttributeError.crew/**is.fernignored, so this survives SDK regeneration.