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

chore: OrphanedShapes TestModel #744

Open
wants to merge 36 commits into
base: main-1.x
Choose a base branch
from
Open

Conversation

lucasmcdonald3
Copy link
Contributor

@lucasmcdonald3 lucasmcdonald3 commented Dec 11, 2024

Issue #, if available:

Description of changes:

OrphanedShapes TestModel + some missing Python conversions.

The bar I'm aiming for is "orphaned shapes are supported if an extern can convert an orphaned shape to/from Dafny".
This can't be tested via local services because passing a shape in a service's operations makes that shape no longer orphaned.
Externs are a reasonable way to test between native/Dafny code, and shapes passed via extern operations can be orphaned.

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

@lucasmcdonald3 lucasmcdonald3 marked this pull request as ready for review December 11, 2024 22:54
@lucasmcdonald3 lucasmcdonald3 requested a review from a team as a code owner December 11, 2024 22:54
@lucasmcdonald3 lucasmcdonald3 changed the title [DRAFT] chore: OrphanedShapes TestModel chore: OrphanedShapes TestModel Dec 11, 2024
Copy link
Contributor

@robin-aws robin-aws left a comment

Choose a reason for hiding this comment

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

Partial review, looking to clarify the top-level need for the feature first before reviewing the rest

@@ -0,0 +1,57 @@
# OrphanedShapes

## Background
Copy link
Contributor

Choose a reason for hiding this comment

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

Most of this content should exist outside of a specific TestModel IMO. I'd suggest moving a good chunk into a separate file under designs.

I'd also suggest naming the complete list of use cases that leads us to deviate from Smithy-Core's approach, just to be clear about which are fundamental (like config shapes) and which are closer to bugs in our implementations.

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 can do some content moving.

I don't like writing a complete list anywhere. It's a long list (I'd estimate 30+) and it will get stale quickly. This list has recently gotten longer due to Tony's mutations changes.

Copy link
Contributor

Choose a reason for hiding this comment

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

30+ individual reasons we need orphaned shapes? Yikes!

I guess what you're saying is: if I wanted to get to a place where local services didn't need generation for orphaned shapes, I'd be better off building that and testing it against all the existing libraries to identify gaps?

(Thanks for satisfying my curiousity on these question btw, I have no intention of blocking this PR as we clearly should be explicitly testing a feature we depend on, I just want to take the opportunity to understand the scope of the feature better, since you would have had to dive into it a certain depth anyway)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I think so.

I think we're landing on the idea of the "ideal state", which would be using Smithy-Core's shape discovery logic plus a bounded, limited set of orphaned shapes (like local service config shapes).
And the path to get there may just be a breaking change to Smithy-Dafny (made by testing against complex libraries) combined with Smithy model changes to downstream libraries


This TestModel tests some instances of orphaned shapes

- LocalService Config shapes. (Config shapes are "orphaned", but are likely already handled as one-offs by any codegen that's this TestModels' prerequisites)
Copy link
Contributor

Choose a reason for hiding this comment

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

This is the main "legit" reason to deviate at least, and I'm hoping in the future we can model local service client creation as an operational as well somehow, since then it wouldn't be a special case.

This TestModel tests some instances of orphaned shapes

- LocalService Config shapes. (Config shapes are "orphaned", but are likely already handled as one-offs by any codegen that's this TestModels' prerequisites)
- Errors
Copy link
Contributor

Choose a reason for hiding this comment

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

Why are these orphaned? Is it because errors from dependency services are used but not directly connected?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Errors will be orphaned if they are not attached to any operations

Copy link
Contributor

Choose a reason for hiding this comment

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

Right, but I assume we still need conversions for them for some reason, just trying to understand that better

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In my mind, it's because Java generates conversions for orphaned errors, so other languages should also generate conversions for parity.


- LocalService Config shapes. (Config shapes are "orphaned", but are likely already handled as one-offs by any codegen that's this TestModels' prerequisites)
- Errors
- Resources (with @aws.polymorph#reference trait) and their operations
Copy link
Contributor

Choose a reason for hiding this comment

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

These should still be listed as resources on the local service though, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Maybe, but in many cases they aren't

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 also believe that Smithy-Core doesn't discover resources attached to the service -- it's only mixins, operations, and errors)

Copy link
Contributor

Choose a reason for hiding this comment

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

That wouldn't surprise me given no other code generators produce anything for resources yet. I would still argue Smithy-Core probably should traverse them even if no one else does anything for them yet, so I might try to submit that change to Smithy-Core down the road...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

- LocalService Config shapes. (Config shapes are "orphaned", but are likely already handled as one-offs by any codegen that's this TestModels' prerequisites)
- Errors
- Resources (with @aws.polymorph#reference trait) and their operations
- Structures (and structures' members)
Copy link
Contributor

Choose a reason for hiding this comment

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

Which structures other than config structures?

Copy link
Contributor Author

@lucasmcdonald3 lucasmcdonald3 Dec 19, 2024

Choose a reason for hiding this comment

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

The only examples are unused structures in the MPL.

Copy link
Contributor

Choose a reason for hiding this comment

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

Which ones specifically? I don't yet appreciate the use case

Copy link
Contributor Author

Choose a reason for hiding this comment

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

TestModels/.gitignore Show resolved Hide resolved
* Returns true if a conversion function should be written for the shape, false otherwise.
* Conversion functions are only written for "complex" shapes:
* - StructureShapes ("complex" because StructureShapes can be recursive)
* - except for non-AWS SDK StructureShapes with ErrorTrait; these aren't "complex"
Copy link
Contributor

Choose a reason for hiding this comment

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

This won't be true forever as we should lift the smithy-dafny restriction that errors can only have a single string "message" member

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure -- I think that's a "cross that bridge when we come to it" situation

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