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

feat: Adds shape visitors for local service #672

Merged
merged 3 commits into from
Nov 1, 2024

Conversation

ShubhamChaturvedi7
Copy link
Contributor

Issue #, if available:

Description of changes:

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

@ShubhamChaturvedi7 ShubhamChaturvedi7 marked this pull request as ready for review October 29, 2024 17:32
@ShubhamChaturvedi7 ShubhamChaturvedi7 requested a review from a team as a code owner October 29, 2024 17:32

@Override
public String timestampShape(final TimestampShape shape) {
// TODO: Figure out timestamp types when working on timestampShape
Copy link
Contributor

Choose a reason for hiding this comment

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

I would prefer to raise an exception at codegen time if this is encountered -- safer to make codegen fail on unhandled shapes

Copy link
Contributor Author

Choose a reason for hiding this comment

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

AFAIK throwing exception fails the codegen on DDBv2 (new model specifically for Go) shapes, hence the nil part.

Copy link
Contributor

Choose a reason for hiding this comment

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

Is DafnyToSmithyShapeVisitor used for both LocalService and AWS SDK shapes?

(Python only implements TimestampShape for AWS SDKs. It raises an exception at codegen time for LocalServices.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahh I should be able to do that. I'll fix it up in a follow up PR since it's going to be again about ShapeVisitors.

Copy link
Contributor

@lucasmcdonald3 lucasmcdonald3 left a comment

Choose a reason for hiding this comment

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

The more I digest this the more I like it.

If you could do a once-over to add some single-line comments inside some of the longer functions to help explain what's going on, that would help others understand it more quickly.

I would really like to see some generated code in context before I approve this but it seems reasonable.

}

@Override
public String timestampShape(final TimestampShape shape) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Ditto as in the reverse conversion -- raise exception at codegen time here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same issue here with the exception.

Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need Timestamps in LocalService?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Responded above, will follow up in the next PR.

@ShubhamChaturvedi7
Copy link
Contributor Author

ShubhamChaturvedi7 commented Oct 31, 2024

The more I digest this the more I like it.

If you could do a once-over to add some single-line comments inside some of the longer functions to help explain what's going on, that would help others understand it more quickly.

I would really like to see some generated code in context before I approve this but it seems reasonable.

Added some comments, renamed some variables to make it self explanatory, and did some better formatting to ease readability - our java formatter is really aggressive and breaks line more than what is generally done in Java. This hinders readability and makes method longer than what it actually should be.

Avoided adding lots of comments since it again gets stale and pollutes code (I favor self explanatory code than comments). Let me know if you think we can do few things better.

Here's an example of the generated code: https://github.com/aws/aws-cryptographic-material-providers-library/blob/Golang/dev/AwsCryptographyPrimitives/runtimes/go/ImplementationFromDafny-go/awscryptographyprimitivessmithygenerated/to_native.go#L67

Copy link
Contributor

@lucasmcdonald3 lucasmcdonald3 left a comment

Choose a reason for hiding this comment

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

TimestampShape exceptions will be in a new PR

@ShubhamChaturvedi7 ShubhamChaturvedi7 merged commit e72cf37 into Golang/reviewed Nov 1, 2024
80 checks passed
@ShubhamChaturvedi7 ShubhamChaturvedi7 deleted the Golang/visitors branch November 1, 2024 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants