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

Extracting existing JMESPath runtime to a separate class #5155

Merged

Conversation

cenedhryn
Copy link
Contributor

that can be used by waiters and other components

Motivation and Context

The new operation context params for auth and endpoint params require the usage of a subset of JMESPath in order to specify a value or set of values in the request.

We already have a JMESPath parser at the codegen level, and a Java class that represents a JMESPath expression in the WaitersRuntime.java class that's copied to services during codegen. This PR extracts that into a separate runtime.

Modifications

  • Creates a new static "runtime" class that only contains generic JMESPath logic, and removes that from WaitersRuntime.java
  • Changes waiters codegen to call the new runtime for acceptor logic
  • Generates the new runtime as part of waiter codegen, or if customization.config contains an eligible endpoint parameter (part of this feature in previous PR)

Considerations

  • Originally intended to not copy JMESPath runtime functionality that isn't used by endpoint param config, but it's only a few hundred lines different.
  • We don't need to provide the ability to only call a scoped subset of JMESPath functionality under certain circumstances at this point. This should be gated at the model level.

@cenedhryn cenedhryn requested a review from a team as a code owner April 25, 2024 23:39
Copy link

sonarcloud bot commented Apr 26, 2024

Quality Gate Failed Quality Gate failed

Failed conditions
72.4% Coverage on New Code (required ≥ 80%)
3.4% Duplication on New Code (required ≤ 3%)

See analysis details on SonarCloud

@@ -104,7 +104,8 @@ private static void configurePackageName(Metadata metadata,
.withPaginatorsPackageName(namingStrategy.getPaginatorsPackageName(service))
.withWaitersPackageName(namingStrategy.getWaitersPackageName(service))
.withEndpointRulesPackageName(namingStrategy.getEndpointRulesPackageName(service))
.withAuthSchemePackageName(namingStrategy.getAuthSchemePackageName(service));
.withAuthSchemePackageName(namingStrategy.getAuthSchemePackageName(service))
.withJPathPackageName(namingStrategy.getJPathPackageName(service));
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we use the full name JmesPath to be more clear?

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 explicitly avoided JmesPath since there has been a lot of discussion around minified versions, not calling that subset JmesPath etc. However, after working with the implementation in Java SDK that distinction has faded - I think the subset will be handled at a model level instead. So if consensus is JmesPath I'm fine with that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

import software.amazon.awssdk.utils.IoUtils;

public final class JPathRuntimeGeneratorTask extends BaseGeneratorTasks {
public static final String RUNTIME_CLASS_NAME = "JPathRuntime";
Copy link
Contributor

Choose a reason for hiding this comment

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

Same here, JmesPathRuntime?

import software.amazon.awssdk.utils.ToString;

@SdkInternalApi
public final class JPathRuntime {
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there any changes between JmesPathRuntime and WaitersRuntime? If so, could you show me the diff?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No, there are no changes in this PR

@@ -57,6 +59,9 @@ protected List<GeneratorTask> createTasks() throws Exception {
tasks.add(generateDefaultProvider());
tasks.add(new RulesEngineRuntimeGeneratorTask(generatorTaskParams));
}
if (shouldGenerateJPathRuntime()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

What are the demerits of always loading the JMESPathRuntime class? Additionally, for waiters, what if we create a class that extends JMESPathRuntime and adds methods only specific to waiters?"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The demerits of always loading JMESPathRuntime is that there are almost 400 services but only 80 of them use waiters.

I don't think the approach of adding methods that are only used in waiters is worth it, because it's just a few hundred lines. It's better to keep the language intact and it will be hard to keep track of different subsets used for different purposes.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks

@cenedhryn cenedhryn merged commit 0323b8f into feature/StringArrayEndpointParams Apr 29, 2024
12 of 16 checks passed
@cenedhryn cenedhryn deleted the salande/jmspath-for-params branch April 29, 2024 21:14
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.

None yet

3 participants