-
Notifications
You must be signed in to change notification settings - Fork 25
feat: Add WASM compatibility fallback from serpyco-rs to serpyco #671
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?
Conversation
- Add conditional dependencies in pyproject.toml using environment markers - Use sys_platform != 'emscripten' for serpyco-rs, sys_platform == 'emscripten' for serpyco - Update imports in airbyte_protocol_serializers.py, airbyte_protocol.py, entrypoint_wrapper.py, and test_source.py - Add conditional import logic to detect WASM/Pyodide environments at runtime - Maintain API compatibility between serpyco-rs and serpyco libraries - All tests pass with conditional imports Co-Authored-By: AJ Steers <[email protected]>
Original prompt from AJ Steers:
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
👋 Greetings, Airbyte Team Member!Here are some helpful tips and reminders for your convenience. Testing This CDK VersionYou can test this version of the CDK using the following: # Run the CLI from this branch:
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@devin/1753304881-serpyco-wasm-fallback#egg=airbyte-python-cdk[dev]' --help
# Update a connector to use the CDK from this branch ref:
cd airbyte-integrations/connectors/source-example
poe use-cdk-branch devin/1753304881-serpyco-wasm-fallback Helpful ResourcesPR Slash CommandsAirbyte Maintainers can execute the following slash commands on your PR:
|
…compliance - Change single quotes to double quotes in sys.platform conditional imports - Resolves MyPy Check and Ruff Format Check CI failures - All local linting and formatting checks now pass Co-Authored-By: AJ Steers <[email protected]>
- Resolved merge conflict in airbyte_protocol_serializers.py - Accepted remote USE_RUST_BACKEND approach which is cleaner - Combined with local formatting fixes for double quotes Co-Authored-By: AJ Steers <[email protected]>
…ports - Use TYPE_CHECKING conditional imports to avoid MyPy duplicate name definitions - Maintains runtime conditional import behavior for WASM compatibility - Local MyPy check now passes successfully on all 415 source files Co-Authored-By: AJ Steers <[email protected]>
- Fix import block sorting in airbyte_protocol_serializers.py - Remove extra blank line for proper formatting - All local Ruff checks now pass Co-Authored-By: AJ Steers <[email protected]>
feat: Add WASM compatibility fallback from serpyco-rs to serpyco
Summary
This PR implements a safe fallback mechanism from
serpyco-rs
to pure Pythonserpyco
when running in WASM/Pyodide environments. The key changes:pyproject.toml
to installserpyco-rs
only whensys_platform != 'emscripten'
andserpyco
whensys_platform == 'emscripten'
sys.platform == 'emscripten'
to detect WASM environmentsCustomType
,Serializer
,SchemaValidationError
, andAlias
This enables the CDK to work in WASM builds where Rust compilation (required by serpyco-rs) is not available, falling back to the pure Python implementation.
Review & Testing Checklist for Human
poetry install
orpip install
works correctly in a Pyodide environment and installsserpyco
instead ofserpyco-rs
sys.platform == 'emscripten'
detection is reliableCustomType
,Serializer
withomit_none
,SchemaValidationError
,Alias
) have identical APIs betweenserpyco
andserpyco-rs
serpyco
fallbackRecommended test plan: Set up a Pyodide environment, install the CDK, and run basic serialization operations to ensure the fallback works end-to-end.
Diagram
Notes
Link to Devin run: https://app.devin.ai/sessions/131f07de5c85420b977fd878c5e7d90e
Requested by: @aaronsteers