Skip to content
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

Export a usable Python implementation via shared library #1476

Merged
merged 48 commits into from
Jun 30, 2022

Conversation

crisidev
Copy link
Contributor

@crisidev crisidev commented Jun 21, 2022

Motivation and Context

#1367

Description

This PR add several functionalities to the Python/Rust code-generation, making it usable for models that are not using Streaming and Union shapes.

  • Export codegenerated shapes as shared library that can be imported by the Python interpreter.
  • Add complete end-to-end testing running in CI.
  • Register signals and handle workers processes lifecycle.
  • Use a custom SymbolProvider to override non-primitive types that are exposed to Python.
  • Implement support for DateTime.
  • Cast Python exception into Rust error types.

Testing

A Python service based on the Pokemon service is run during CI.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@crisidev crisidev force-pushed the crisidev/oxipy-module branch from 7799af2 to 6b88878 Compare June 21, 2022 16:26
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@crisidev
Copy link
Contributor Author

crisidev commented Jun 29, 2022

@rcoh @Velfi @jdisanti: the PR is long and very server / python specific. There are some simple changes I made to the ByteStream type inside the codegen folder. I'd probably need a review from you of only this part.

If you are curious about the rest of the server changes, I'll be happy to get reviews on that part as well, but it is not necessary.

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

.github/workflows/ci.yml Show resolved Hide resolved
Comment on lines +188 to +189
fun ByteStream(runtimeConfig: RuntimeConfig) =
RuntimeType("ByteStream", CargoDependency.SmithyHttp(runtimeConfig), "${runtimeConfig.crateSrcPrefix}_http::byte_stream")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do this change impact anything?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so.. the CI is happy. I can see it does some changes inside the SDK, but only in comments: https://d2luzm2xt3nokh.cloudfront.net/codegen-diff/5a5aa2f3d6b95b42c5a73dbee59b1a340a83c932/a7afa9c387054bd503d97266cb5cbc84cb667a47/diff-aws-sdk.html

@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@crisidev crisidev requested a review from rcoh June 30, 2022 11:32
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.


override fun toMemberName(shape: MemberShape): String = when (val container = model.expectShape(shape.container)) {
is StructureShape -> shape.memberName.toSnakeCase()
is UnionShape -> shape.memberName.toPascalCase()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supported? (nit)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Union is not supported yet, but once it will be this will work out of the box.

cargo doc --no-deps --open

clean:
cargo clean || echo "Unable to run cargo clean"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe you want to use @echo

Copy link
Contributor Author

@crisidev crisidev Jun 30, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why? I am in a subshell..

@crisidev crisidev enabled auto-merge (squash) June 30, 2022 15:39
@github-actions
Copy link

A new generated diff is ready to view.

A new doc preview is ready to view.

@crisidev crisidev merged commit 5312ff1 into main Jun 30, 2022
@crisidev crisidev deleted the crisidev/oxipy-module branch June 30, 2022 16:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
server Rust server SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants