Skip to content

Conversation

@aajtodd
Copy link
Contributor

@aajtodd aajtodd commented Oct 27, 2021

Issue #

N/A

Description of changes

  • 🚨 chore: add task to sync models so we don't have to continue to rely on other repos (e.g. aws-sdk-go-v2) as the source for models. You can now pull down the source models repo and sync it directly.
    • (this would be easily lost in the sync changes, look at codegen/sdk/build.gradle.kts)
  • chore: sync latest models

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@aajtodd aajtodd requested review from ianbotsf and kggilmer October 27, 2021 17:30
Copy link
Contributor

@ianbotsf ianbotsf left a comment

Choose a reason for hiding this comment

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

Very nice! Love that we have our own way to do this now.


pairs.forEach { (source, existing) ->
// ensure we don't accidentally take a new API version
if (source.version != existing.version) error("upstream version of ${source.path} does not match destination of existing model version ${existing.modelFile.name}")
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: This line is 176 chars long. Do we have any expectations about line length in Gradle scripts?

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, but we could put it into braces such that the error is on a new line, e.g.:

if (...) {
    error(...)
}

Is that preferable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also I'm not even sure if this check matters or not but I erred on the side of caution

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I generally prefer code with limited line length. It helps me keep multiple windows open in my IDE and reduces cognitive load when reading PRs.

Comment on lines +491 to +495
// models with no upstream source in aws-models
orphaned.forEach { sdkId ->
val existing = existingModelsBySdkId[sdkId]!!
logger.warn("Cannot find a model file for ${existing.modelFile.name} (sdkId=${existing.sdkId}) but it exists in aws-sdk-kotlin!")
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Question: Should this be an error instead? I don't know how often this actually happens (vs how often this would indicate a bug). In either case, it seems like we'd want a human to definitively acknowledge it or take action (e.g., manually deleting the service from aws-sdk-kotlin).

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 wasn't sure...it hasn't happened yet (on the one time I have synced using this script 🤣 ). I can go either way. I had sort of wanted logger.warn to spit out colored output so that these log messages were more visible but I don't see any difference 🤷

Copy link
Contributor

Choose a reason for hiding this comment

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

Warnings rely on good intent and careful diligence on the part of operators. Errors force us to make explicit, intentional decisions no matter how many other things are competing for our attention.

@kggilmer
Copy link
Contributor

kggilmer commented Oct 28, 2021

You can now pull down the source models repo and sync it directly.

This means that there is a new workflow by which we locally pull the models repo, run the task, and submit a PR? Is that the workflow?

chore: sync latest models

Did this new approach get used to sync latest models?

Copy link
Contributor

@kggilmer kggilmer left a comment

Choose a reason for hiding this comment

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

I would like some basic docs on how aws models should be updated so we're all doing it consistently, but nothing to block the PR.

return getProperty("awsModelsDir")?.let { File(it) }?.absolutePath
}

tasks.create("syncModels") {
Copy link
Contributor

Choose a reason for hiding this comment

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

suggestion

as we already have various models, i think it would be better to qualify this task as you do in the println. syncAwsModels or something.


// generate warnings at the end so they are more visible
if (orphaned.isNotEmpty() || newSources.isNotEmpty()) {
println("\nWarnings:")
Copy link
Contributor

Choose a reason for hiding this comment

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

question

why are we mixing println() and logger.xxx()...is it that info doesn't print by default or something?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I had hoped logger.warn did something more...visible 🤷 . They could all be println if you prefer

Copy link
Contributor

Choose a reason for hiding this comment

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

it's nbd. something to add to consideration for gradle build cleanup. i think it would be a regression to use println, better to figure out how to make the logger work as we'd like it to.



fun discoverAwsModelsRepoPath(): String? {
val discovered = rootProject.file("../aws-models")
Copy link
Contributor

Choose a reason for hiding this comment

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

concern

Unless I missed it in comments, I think we need a blurb somewhere that describes the steps to update models with this new code.

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 can add something but in general

cd <path/to/local/aws-models>
git pull  // ensure we are up to date with latest commits
cd <path/to/aws-sdk-kotlin>
./gradlew syncModels

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

@aajtodd aajtodd merged commit 5521114 into main Oct 28, 2021
@aajtodd aajtodd deleted the chore-sync-models branch October 28, 2021 18:35
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.

3 participants