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

Python: Get most CI green #530

Merged
merged 8 commits into from
Aug 23, 2024
Merged

Python: Get most CI green #530

merged 8 commits into from
Aug 23, 2024

Conversation

lucasmcdonald3
Copy link
Contributor

@lucasmcdonald3 lucasmcdonald3 commented Aug 22, 2024

Issue #, if available:

Description of changes:

This gets most CI green. (Caveat: it does this by having separate transpile commands for NET/Java vs Python, but this SHOULD only be separate until NET/Java get on 4.8.)

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 August 22, 2024 23:22
@lucasmcdonald3 lucasmcdonald3 requested a review from a team as a code owner August 22, 2024 23:22
uses: gradle/gradle-build-action@v2
with:
arguments: :codegen-client:pTML :codegen-core:pTML :rust-runtime:pTML
build-root-directory: smithy-dafny-codegen-modules/smithy-rs

- name: Install smithy-dafny-codegen Python dependencies locally
Copy link
Contributor

Choose a reason for hiding this comment

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

Just FYI I had to do this because smithy-rs packages aren't published at all yet, but I assume you have to do it here because you're still patching the smithy-python code?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also it might be worth a reusable .github/actions for this since it's not very DRY.

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 and yes (both because Smithy-Python isn't on Maven and because I have patches.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made a GHA for "Install Smithy-Dafny codegen dependencies"

Copy link
Contributor

@robin-aws robin-aws Aug 23, 2024

Choose a reason for hiding this comment

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

FYI I snuck these targets in for human usage too: https://github.com/smithy-lang/smithy-dafny/blob/main-1.x/Makefile#L13 :)

Probably good to add the python dependency there too, perhaps in this PR so we don't forget?

@@ -5,9 +5,6 @@ rootProject.name = "smithy-dafny"
include(":smithy-dafny-codegen")
include(":smithy-dafny-codegen-cli")
include(":smithy-dafny-codegen-test")
// TODO: Once Smithy-Python is published to Maven, and we do not rely on a fork, use that
Copy link
Contributor

Choose a reason for hiding this comment

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

This should probably be tracked in an issue for both Python and Rust

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You mean an issue in Smithy-Python/rs that says "Publish codegen to Maven"? I agree

Copy link
Contributor Author

Choose a reason for hiding this comment

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

DISABLED_TESTS.add("SimpleTypes/SimpleFloat");
DISABLED_TESTS.add("SimpleTypes/SimpleShort");
DISABLED_TESTS.add("SimpleTypes/SimpleTimestamp");
DISABLED_TESTS.add("aws-sdks/ddb-lite");
Copy link
Contributor

Choose a reason for hiding this comment

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

FYI the -lite models should be very easy to turn on as well, since the projection is handled before hitting any language-specific logic.

Copy link
Contributor Author

@lucasmcdonald3 lucasmcdonald3 Aug 23, 2024

Choose a reason for hiding this comment

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

Took a look, I'll leave these unimplemented for now.
Even though the models are "lite", they use the gradle build process, which seems to need extra work to get working.
I think Python and Go will need extra work to figure out how to pass in extra args for the "dependency-module-names" and "library-name" flags.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough, there's no real motivation to get those working now anyway - they are mainly useful during the development of new languages and you're already past that stage.

_transpile_implementation_all: transpile_implementation

# TODO-new-cli: As part of supporting Dafny 4.8+, Java and NET SHOULD migrate to the new Dafny CLI,
Copy link
Contributor

Choose a reason for hiding this comment

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

This feels slightly off and could be more precise - is it because the legacy CLI will eventually be fully deprecated? It seems more like other languages need features that are only in the new CLI.

Copy link
Contributor Author

@lucasmcdonald3 lucasmcdonald3 Aug 23, 2024

Choose a reason for hiding this comment

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

Yes, but the more immediate desire is that Java/NET/Python/Go have the same build command.
This reduces risk of accidental "forks" in one build process or the other.
(I know we will need some Makefile checking that says "only add --compile-suffix:1 for Java/NET", but that is a small "fork".)

This is meant to assert that "we have a 4.8 upgrade coming up, these targets SHOULD be merged as part of that upgrade"

Copy link
Contributor

Choose a reason for hiding this comment

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

The _new_cli duplication seems reasonable to me. Only question is whether this PR also ensures they are as well tested. It seems like it is since Python will only use them?

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, right now only Python.
My goal is to get this into main soon so Rishav and Shubham can onboard to a "shared" solution.

@@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
include "SimpleAggregateImpl.dfy"

module SimpleAggregate refines AbstractSimpleAggregateService {
module {:extern "simple.aggregate.internaldafny"} SimpleAggregate refines AbstractSimpleAggregateService {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this a breaking change for existing projects?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope! This is the current state of main-1.x.
I'm putting the extern names back in the python-reviewed branch so that when I merge this branch in, there is no diff between its Dafny source and main's.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah I actually missed that this is not targeting main-1.x itself.

Copy link
Contributor

Choose a reason for hiding this comment

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

Consider implementing --generate project-files for Python in the future, so many libraries don't have to provide this file.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good to know, thanks. I didn't realize we had this

lucasmcdonald3 and others added 6 commits August 23, 2024 08:57
Corrected GetStringUTF8 to use this trait
Corrected the description of the existing test that incorrectly said the string was in UTF-8 (it's a Dafny string so it's implicitly UTF-16 instead)
Added identically structured test of GetStringUTF8
Updated benerated Rust code to make sure this case is handled too.
@lucasmcdonald3 lucasmcdonald3 merged commit a26ebae into python-reviewed Aug 23, 2024
73 of 74 checks passed
@lucasmcdonald3 lucasmcdonald3 deleted the ci branch August 23, 2024 22:03
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