-
Notifications
You must be signed in to change notification settings - Fork 195
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
Python: Event Streaming #2482
Python: Event Streaming #2482
Conversation
A new generated diff is ready to view.
A new doc preview is ready to view. |
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.
7498599
to
b610cb2
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
A new generated diff is ready to view.
A new doc preview is ready to view. |
21209b9
to
b7afb23
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
b7afb23
to
86b681f
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
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.
Reviewed with @crisidev
codegen-core/src/main/kotlin/software/amazon/smithy/rust/codegen/core/rustlang/RustType.kt
Show resolved
Hide resolved
} | ||
|
||
companion object { | ||
data class EventStreamSymbol(val innerT: RustType, val errorT: RustType) |
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.
Let's discuss about this approach
...tlin/software/amazon/smithy/rust/codegen/server/python/smithy/PythonServerCargoDependency.kt
Outdated
Show resolved
Hide resolved
private val pyO3Asyncio = PythonServerCargoDependency.PyO3Asyncio.toType() | ||
private val tokio = PythonServerCargoDependency.Tokio.toType() | ||
private val futures = PythonServerCargoDependency.Futures.toType() | ||
private val parkingLot = PythonServerCargoDependency.ParkingLot.toType() |
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.
Let's create an issue to whether we can switch to std::sync::Mutex
instead of parking_lot::Mutex
...ithy/rust/codegen/server/python/smithy/generators/PythonServerEventStreamWrapperGenerator.kt
Outdated
Show resolved
Hide resolved
...ithy/rust/codegen/server/python/smithy/generators/PythonServerEventStreamWrapperGenerator.kt
Show resolved
Hide resolved
86b681f
to
c8ee180
Compare
A new generated diff is ready to view.
A new doc preview is ready to view. |
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.
LGTM!
A new generated diff is ready to view.
A new doc preview is ready to view. |
* Add `RustType.Application` and `PythonType.Application` variants * Use `RustType.Application` for event streaming symbols * Call symbol provider to get `Receiver` type instead of hardcoding * Add Python specific event streaming symbol provider * Add event streaming wrapper generator * Generate correct type information for event streaming types * Add `CapturePokemon` operation to Python Pokemon service * Add `InternalServerError` variant to all event streaming errors * Use `PythonServerCargoDependency` for PyO3Asyncio imports * Return an attribute error instead of panicking in `IntoPy` impls of wrappers * Add `Sync` bound to `new` methods of wrappers * Revert "Add `InternalServerError` variant to all event streaming errors" This reverts commit b610cb2. * Add `PythonServerEventStreamErrorGenerator` to generate Python specific error types for unions * Try to extract error type or inner type from incoming streaming value and ignore the value otherwise for now * Allow missing type-stubs for `aiohttp` * Propogate modelled errors through stream * Raise modelled exceptions rather than sending through stream * Allow senders from Python side to raise modelled exceptions * Update `EventStreamSymbolProviderTest` to use `Application` type instead of `Opaque` type * Fix `ktlint` issues * Group up common variables in `codegenScope` * Document `RustType.Application` * Format `codegen-server-test/python/model/pokemon.smithy` * Use `tokio-stream` crate instead of `futures` crate * Use a better error message if user tries to reuse a stream * Add some details about event streams to example Pokemon service --------- Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
* Add `RustType.Application` and `PythonType.Application` variants * Use `RustType.Application` for event streaming symbols * Call symbol provider to get `Receiver` type instead of hardcoding * Add Python specific event streaming symbol provider * Add event streaming wrapper generator * Generate correct type information for event streaming types * Add `CapturePokemon` operation to Python Pokemon service * Add `InternalServerError` variant to all event streaming errors * Use `PythonServerCargoDependency` for PyO3Asyncio imports * Return an attribute error instead of panicking in `IntoPy` impls of wrappers * Add `Sync` bound to `new` methods of wrappers * Revert "Add `InternalServerError` variant to all event streaming errors" This reverts commit b610cb2. * Add `PythonServerEventStreamErrorGenerator` to generate Python specific error types for unions * Try to extract error type or inner type from incoming streaming value and ignore the value otherwise for now * Allow missing type-stubs for `aiohttp` * Propogate modelled errors through stream * Raise modelled exceptions rather than sending through stream * Allow senders from Python side to raise modelled exceptions * Update `EventStreamSymbolProviderTest` to use `Application` type instead of `Opaque` type * Fix `ktlint` issues * Group up common variables in `codegenScope` * Document `RustType.Application` * Format `codegen-server-test/python/model/pokemon.smithy` * Use `tokio-stream` crate instead of `futures` crate * Use a better error message if user tries to reuse a stream * Add some details about event streams to example Pokemon service --------- Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
* Add `RustType.Application` and `PythonType.Application` variants * Use `RustType.Application` for event streaming symbols * Call symbol provider to get `Receiver` type instead of hardcoding * Add Python specific event streaming symbol provider * Add event streaming wrapper generator * Generate correct type information for event streaming types * Add `CapturePokemon` operation to Python Pokemon service * Add `InternalServerError` variant to all event streaming errors * Use `PythonServerCargoDependency` for PyO3Asyncio imports * Return an attribute error instead of panicking in `IntoPy` impls of wrappers * Add `Sync` bound to `new` methods of wrappers * Revert "Add `InternalServerError` variant to all event streaming errors" This reverts commit b610cb2. * Add `PythonServerEventStreamErrorGenerator` to generate Python specific error types for unions * Try to extract error type or inner type from incoming streaming value and ignore the value otherwise for now * Allow missing type-stubs for `aiohttp` * Propogate modelled errors through stream * Raise modelled exceptions rather than sending through stream * Allow senders from Python side to raise modelled exceptions * Update `EventStreamSymbolProviderTest` to use `Application` type instead of `Opaque` type * Fix `ktlint` issues * Group up common variables in `codegenScope` * Document `RustType.Application` * Format `codegen-server-test/python/model/pokemon.smithy` * Use `tokio-stream` crate instead of `futures` crate * Use a better error message if user tries to reuse a stream * Add some details about event streams to example Pokemon service --------- Co-authored-by: Matteo Bigoi <1781140+crisidev@users.noreply.github.com>
Motivation and Context
Closes #1752
Description
Testing
TODOs
Checklist
CHANGELOG.next.toml
if I made changes to the smithy-rs codegen or runtime cratesCHANGELOG.next.toml
if I made changes to the AWS SDK, generated SDK code, or SDK runtime cratesBy submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.