-
Notifications
You must be signed in to change notification settings - Fork 55
chore: add sync models task and sync latest models #374
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
Conversation
There was a problem hiding this 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}") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
| // 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!") | ||
| } |
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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 🤷
There was a problem hiding this comment.
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.
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?
Did this new approach get used to sync latest models? |
There was a problem hiding this 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.
codegen/sdk/build.gradle.kts
Outdated
| return getProperty("awsModelsDir")?.let { File(it) }?.absolutePath | ||
| } | ||
|
|
||
| tasks.create("syncModels") { |
There was a problem hiding this comment.
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:") |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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") |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
|
Kudos, SonarCloud Quality Gate passed!
|








Issue #
N/A
Description of changes
aws-sdk-go-v2) as the source for models. You can now pull down the source models repo and sync it directly.codegen/sdk/build.gradle.kts)By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.