-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Parse YAML ExpansionService configs directly using SnakeYAML #31406
Parse YAML ExpansionService configs directly using SnakeYAML #31406
Conversation
Checks are failing. Will not request review until checks are succeeding. If you'd like to override that behavior, comment |
assign set of reviewers |
Assigning reviewers. If you would like to opt out of this review, comment R: @kennknowles for label java. Available commands:
The PR bot will only process comments in the main thread (not review comments). |
Failures don't seem to be related. |
@kennknowles @Abacn friendly ping since I'd like to get this into the 2.57.0 release. |
@@ -41,10 +41,8 @@ dependencies { | |||
implementation project(path: ":sdks:java:core", configuration: "shadow") | |||
implementation project(path: ":runners:java-fn-execution") | |||
implementation project(path: ":sdks:java:harness") | |||
implementation "org.yaml:snakeyaml:2.0" |
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.
put this in the BeamModulePlugin?
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.
Done.
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.
Had to revert, pls see the top level comment.
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.
Moved back to the top level.
try (InputStream stream = new FileInputStream(allowListFileObj)) { | ||
return AllowList.parseFromYamlStream(stream); | ||
} catch (FileNotFoundException e) { | ||
throw new RuntimeException(e); |
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.
Would be nice to add a message to these RuntimeException wrappers, like "when opening file to parse as ExpansionServiceConfig"
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.
Done.
File configFileObj = new File(configFile); | ||
if (!configFileObj.exists()) { | ||
throw new IllegalArgumentException("Config file " + configFile + " does not exist"); | ||
} | ||
try { | ||
return mapper.readValue(configFileObj, ExpansionServiceConfig.class); | ||
try (InputStream stream = new FileInputStream(configFileObj)) { |
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.
Here too, would be nice to add a message to these RuntimeException wrappers, like "when opening file to parse as ExpansionServiceConfig"
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.
Done.
Yaml yaml = new Yaml(); | ||
Map<Object, Object> config = yaml.load(inputStream); | ||
|
||
if (config != null) { |
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.
Readability: Reverse the if
statement and make it if (config == null) throw IllegalArgumentException
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.
Done.
public abstract String getVersion(); | ||
|
||
@SuppressWarnings("mutable") |
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.
Would making it ImmutableList be just as good as suppression?
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 added these since I got some random warnings when compiling but seems like this didn't fully resolve the issue. So removing these suppressions for now.
fa1c9b7
to
4e9f30c
Compare
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.
Thanks. PTAL.
@@ -41,10 +41,8 @@ dependencies { | |||
implementation project(path: ":sdks:java:core", configuration: "shadow") | |||
implementation project(path: ":runners:java-fn-execution") | |||
implementation project(path: ":sdks:java:harness") | |||
implementation "org.yaml:snakeyaml:2.0" |
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.
Done.
try (InputStream stream = new FileInputStream(allowListFileObj)) { | ||
return AllowList.parseFromYamlStream(stream); | ||
} catch (FileNotFoundException e) { | ||
throw new RuntimeException(e); |
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.
Done.
File configFileObj = new File(configFile); | ||
if (!configFileObj.exists()) { | ||
throw new IllegalArgumentException("Config file " + configFile + " does not exist"); | ||
} | ||
try { | ||
return mapper.readValue(configFileObj, ExpansionServiceConfig.class); | ||
try (InputStream stream = new FileInputStream(configFileObj)) { |
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.
Done.
Yaml yaml = new Yaml(); | ||
Map<Object, Object> config = yaml.load(inputStream); | ||
|
||
if (config != null) { |
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.
Done.
public abstract String getVersion(); | ||
|
||
@SuppressWarnings("mutable") |
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 added these since I got some random warnings when compiling but seems like this didn't fully resolve the issue. So removing these suppressions for now.
4e9f30c
to
27c70b8
Compare
Seems like this results in a test failure. Looking. |
27c70b8
to
3f024f5
Compare
Seems like simply defining SnakeYAML at top level causes "./gradlew :runners:java-fn-execution:test" to fail due to the conflict [1]. So reverted that and defining the dependency at the sub-module level now. [1] #26743 (comment) |
Oh I just meant defining |
Yeah, there's an actual conflict tracked here: #26743 This PR was a workaround. |
3f024f5
to
eba6ef0
Compare
This is not a release blocker anymore since #31473 was merged but I think it's still good to get this in to simplify by removing the Jackson dependency from the Expansion Service. PTAL. |
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.
LGTM when green
Thanks. Java pre-commit passed. Two other failures seems to be unrelated and just flake test suites. |
Hadoop IO Direct failure is due to this change. It's passing on master branch: https://github.com/apache/beam/actions/workflows/beam_PreCommit_Java_Hadoop_IO_Direct.yml?query=event%3Aschedule The cause is snakeyaml version change: snakeyaml 2.x is not compatible with cassandra-all used in the test I tried to pin snakeyaml version in #31473 but here more beam component introduced snakeyaml 2.x dependency and the pinned dependency appearently got overwritten |
Hmm, this is just bumping the existing dependency in core from 2.0 to 2.2. Lemme try some tests. Feel free to send a revert if needed. |
Seems like #31485 fixes the issue. |
This fixes #31405.
Thank you for your contribution! Follow this checklist to help us incorporate your contribution quickly and easily:
addresses #123
), if applicable. This will automatically add a link to the pull request in the issue. If you would like the issue to automatically close on merging the pull request, commentfixes #<ISSUE NUMBER>
instead.CHANGES.md
with noteworthy changes.See the Contributor Guide for more tips on how to make review process smoother.
To check the build health, please visit https://github.com/apache/beam/blob/master/.test-infra/BUILD_STATUS.md
GitHub Actions Tests Status (on master branch)
See CI.md for more information about GitHub Actions CI or the workflows README to see a list of phrases to trigger workflows.