feat(sdk): extract Fern Python client to clients/python package#4255
feat(sdk): extract Fern Python client to clients/python package#4255mmabrouk wants to merge 2 commits intochore/sdk/relocate-to-sdks-pythonfrom
Conversation
The generated Fern Python client previously lived inside the SDK tree
at sdk/agenta/client/backend/, coupling the handwritten SDK and the
generated client by package path rather than by API contract. This
extracts the generated client into a standalone clients/python/
package exposing AgentaApi, AsyncAgentaApi, AgentaApiEnvironment, and
~100+ Pydantic DTO types.
A bridge in sdks/python/agenta/client/__init__.py replaces sys.modules
entries so all existing `from agenta.client.* import ...` imports
continue to work unchanged - no consumer migration required.
Adds:
- clients/python/agenta_client/ - generated standalone Python client
- clients/scripts/generate.sh - regen entrypoint (--openapi-url or
--openapi-file), with a Python post-processor that renames
duplicate TypeScript createAccounts methods (workaround for a
route collision now also fixed at source via include_in_schema=False)
- sdks/python/oss/tests/test_fern_client.py - structure tests that
validate imports, instantiation, and sub-module presence (no API
calls)
- ruff.toml + .pre-commit-config.yaml exclude clients/ from lint and
format (Fern-generated code)
- docs/designs/fern-clients/{proposal,plan,research,gap}.md - design
notes
- Design doc updates referencing the new generate.sh path
Removes:
- sdk/agenta/client/* - old generated client artifacts purged in
favor of the standalone clients/python package
…it complement to client extraction)
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
Superseded by re-sliced PRs that fix CI failures. See new PR layout for details. |
Summary
The generated Fern Python client previously lived inside the SDK tree
at
sdk/agenta/client/backend/, coupling the handwritten SDK and thegenerated client by package path rather than by API contract. This
extracts the generated client into a standalone
clients/python/package exposing
AgentaApi,AsyncAgentaApi,AgentaApiEnvironment,and ~100+ Pydantic DTO types.
A bridge in
sdks/python/agenta/client/__init__.pyreplacessys.modulesentries so all existingfrom agenta.client.* import ...imports continue to work unchanged.No consumer migration is required.
What changed
Adds:
clients/python/agenta_client/— the standalone Fern-generatedPython client (~752 files: clients, types, errors, environment)
clients/scripts/generate.sh— regen entrypoint with--openapi-url <URL>and--openapi-file <path>modes. Alsocontains a Python post-processor (
fix_typescript_admin_duplicates)that renames the duplicate
createAccountsmethod generated byFern. The duplicate is now also fixed at the source via
include_in_schema=False(PRfix/api/admin-accounts-openapi); the post-processor remains as abelt-and-suspenders for older OpenAPI specs.
sdks/python/oss/tests/test_fern_client.py— structure tests thatvalidate all client imports, instantiation, and sub-module presence
(no API calls)
clients/python/{pyproject.toml,README.md}andclients/README.mdruff.toml— excludesclients/from ruff (Fern-generated).pre-commit-config.yaml—exclude: ^clients/on the ruff hooksdocs/designs/fern-clients/{proposal,plan,research,gap}.md—design notes
docs/design/chat-interface-rfc/,docs/design/fern-sdk-update/) referencing the new generate.sh pathRemoves:
sdk/agenta/client/*— old generated client artifacts that don'thave a one-to-one mapping in the new package, plus a 95-file cleanup
of stale generated files
Diff
clients/python/agenta_client/(excluded from ruff/pre-commit per the
ruff.tomland.pre-commit-config.yamlchanges in this PR)Commits
2 commits, kept separate due to a GitButler squash conflict around
rename detection. Squash-merge recommended:
feat(sdk): extract Fern Python client to clients/python packagechore(sdk): remove obsolete sdk/agenta/client/* artifacts(split-commit complement to the extraction)
Risks
sdks/python/agenta/client/__init__.pyuses
sys.modulesrewriting to mapagenta.client.*→agenta_client.*. This is the load-bearing piece. Test coverageis in
sdks/python/oss/tests/test_fern_client.pywhich validatesimports, instantiation, and sub-module presence.
agenta_client.*types may havefield-by-field equivalents but renamed Pydantic class identities
vs the old
agenta.client.backend.types.*. If any consumer importsa type and uses
isinstance()against it, that check could breaksilently. Grep for
isinstance(..., backend\.types\.usages andverify before merging.
but is run manually. A future PR should add a CI guard that fails if
the committed
clients/python/differs from a fresh regen againstthe OpenAPI spec.
ruff.tomland thepre-commit config. This is intentional but means ruff will not catch
drift between hand-written and generated code at the package
boundary.
QA
pip install -e sdks/python && pip install -e clients/pythoninstalls both packages
python -c "from agenta.client.backend import AgentaApi; print(AgentaApi)"— should resolve via the bridge to
agenta_client.AgentaApipython -c "from agenta_client import AgentaApi"— directimport works
pytest sdks/python/oss/tests/test_fern_client.py— allstructure tests pass
cd sdks/python && pytest oss/tests/— confirms no regression in consumers that still import via
agenta.client.*from agenta.client.backend.types.config_dto import ConfigDto)and confirm it loads
bash clients/scripts/generate.sh --openapi-file ./openapi.json— should produce a no-op diff against committed
clients/python/ruff checkfrom repo root — confirmclients/is excludedNotes
chore/sdk/relocate-to-sdks-python(which is itselfstacked on
chore/infra/per-service-container-workdir).fix/api/admin-accounts-openapi(which removesthe duplicate
createAccountsat the OpenAPI source). That PR isparallel against
main; its removal of the duplicate eventuallylets us drop the post-gen rename patch in
clients/scripts/generate.sh.