Skip to content

[BEAM-1353] Easy PTransform style guide compliance fixes#1943

Closed
jkff wants to merge 8 commits intoapache:masterfrom
jkff:style-guide
Closed

[BEAM-1353] Easy PTransform style guide compliance fixes#1943
jkff wants to merge 8 commits intoapache:masterfrom
jkff:style-guide

Conversation

@jkff
Copy link
Contributor

@jkff jkff commented Feb 8, 2017

This leaves out the more complex / potentially-controversial ones.

R: @dhalperi


private static class Globally<T> extends PTransform<PCollection<T>, PCollection<T>> {
/** Implementation of {@link #globally()}. */
public static class Globally<T> extends PTransform<PCollection<T>, PCollection<T>> {
Copy link
Contributor

Choose a reason for hiding this comment

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

I may have missed the relevant section in the PTransform style guide -- why is it good to expose the classes if the user need not further configure them?

Copy link
Contributor

Choose a reason for hiding this comment

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

In other words, why not "principle of least visibility"?

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 started a thread about this on beam-dev https://lists.apache.org/thread.html/f448eb9f531bec2c0cd70e790dc8d2198d8a1bf9d2b85f94d9ac904a@%3Cdev.beam.apache.org%3E . There indeed is no section about that, but perhaps my arguments in the thread shall be convincing.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not seeing how this discussion is related to that discussion.

It's more internally-evolvable to return PTransform than to return any concrete class.

And the argument about runner intercepting isn't relevant post-FnApi. No runner can inspect the Java classes specifically, only their standard serialized form.

@asfbot
Copy link

asfbot commented Feb 8, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/7180/

Build result: FAILURE

[...truncated 4847 lines...]Caused by: org.apache.maven.reporting.MavenReportException: Exit code: 1 - /home/jenkins/jenkins-slave/workspace/beam_PreCommit_Java_MavenInstall@2/runners/google-cloud-dataflow-java/src/main/java/org/apache/beam/runners/dataflow/DataflowRunner.java:2046: error: reference not found * {@link org.apache.beam.sdk.io.Write.Bound Write.Bound} to provide Google ^Command line was: /usr/local/asfpackages/java/jdk1.8.0_102/jre/../bin/javadoc @options @packagesRefer to the generated Javadoc files in '/home/jenkins/jenkins-slave/workspace/beam_PreCommit_Java_MavenInstall@2/runners/google-cloud-dataflow-java/target/apidocs' dir. at org.apache.maven.plugin.javadoc.AbstractJavadocMojo.executeJavadocCommandLine(AbstractJavadocMojo.java:5163) at org.apache.maven.plugin.javadoc.AbstractJavadocMojo.executeReport(AbstractJavadocMojo.java:2075) at org.apache.maven.plugin.javadoc.JavadocJar.execute(JavadocJar.java:188) ... 33 more2017-02-08T01:37:33.474 [ERROR] 2017-02-08T01:37:33.474 [ERROR] Re-run Maven using the -X switch to enable full debug logging.2017-02-08T01:37:33.474 [ERROR] 2017-02-08T01:37:33.474 [ERROR] For more information about the errors and possible solutions, please read the following articles:2017-02-08T01:37:33.474 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoExecutionException2017-02-08T01:37:33.475 [ERROR] 2017-02-08T01:37:33.475 [ERROR] After correcting the problems, you can resume the build with the command2017-02-08T01:37:33.475 [ERROR] mvn -rf :beam-runners-google-cloud-dataflow-javachannel stoppedSetting status of c37d550 to FAILURE with url https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/7180/ and message: 'Build finished. 'Using context: Jenkins: Maven clean install
--none--

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.006%) to 69.599% when pulling e4ff843 on jkff:style-guide into 8c1a577 on apache:master.

@asfbot
Copy link

asfbot commented Feb 8, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/7181/
--none--

@jkff
Copy link
Contributor Author

jkff commented Feb 9, 2017

I've revised my changes to the "glorified combine" transforms according to the beam-dev thread.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 3e46f94 on jkff:style-guide into ** on apache:master**.

@coveralls
Copy link

Coverage Status

Changes Unknown when pulling 3e46f94 on jkff:style-guide into ** on apache:master**.

@asfbot
Copy link

asfbot commented Feb 9, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/7225/
--none--

@asfbot
Copy link

asfbot commented Feb 9, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/7224/
--none--

@Test
public void testWriteUnbounded() {
PCollection<String> unbounded = p.apply(CountingInput.unbounded())
.apply(ToString.of());
Copy link
Contributor

Choose a reason for hiding this comment

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

We decided this one the other way. @eljefe6a

Copy link
Contributor

Choose a reason for hiding this comment

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

Are the other violations going to be separate PRs or part of this PR. Should we discuss the method name here or on the list?

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 can just take out this commit from the PR if the rest looks fine. The list or the JIRA thread is probably the best place.

Copy link
Contributor

Choose a reason for hiding this comment

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

Moving this discussion to the list.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.001%) to 69.136% when pulling 74ab2e0 on jkff:style-guide into 16736a6 on apache:master.

@asfbot
Copy link

asfbot commented Feb 28, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/7944/
--none--

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.02%) to 69.182% when pulling a3e26dd on jkff:style-guide into a41afdc on apache:master.

@asfbot
Copy link

asfbot commented Feb 28, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/7982/
--none--

Copy link
Contributor

@dhalperi dhalperi left a comment

Choose a reason for hiding this comment

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

LGTM

@Override
public TimestampedValue<T> addInput(TimestampedValue<T> accumulator,
TimestampedValue<T> input) {
TimestampedValue<T> input) {
Copy link
Contributor

Choose a reason for hiding this comment

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

optional style: usually the old indent is preferred

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 usually apply google-java-format on the changed bits but in this case I guess I forgot.

Coder<TimestampedValue<T>> inputCoder) throws CannotProvideCoderException {
public Coder<TimestampedValue<T>> getAccumulatorCoder(
CoderRegistry registry, Coder<TimestampedValue<T>> inputCoder)
throws CannotProvideCoderException {
Copy link
Contributor

Choose a reason for hiding this comment

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

optional style: usually the throws clause is further indented (I believe)

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 looked at some other instances of a throws on a new line in the codebase, and this style seems more common. It is also what google-java-format produces.

"inputCoder must be a TimestampedValueCoder, but was %s", inputCoder);
public Coder<T> getDefaultOutputCoder(
CoderRegistry registry, Coder<TimestampedValue<T>> inputCoder)
throws CannotProvideCoderException {
Copy link
Contributor

Choose a reason for hiding this comment

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

(similar throws clause)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ditto.

*/
public static class SampleAny<T> extends PTransform<PCollection<T>, PCollection<T>> {
/** Implementation of {@link #any(long)}; do not use directly. */
@VisibleForTesting
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this test is Sample-dependent only for convenience. Is it worth changing the test to avoid the need to make this public?

*/
public static PTransform<PCollection<?>, PCollection<String>> elements() {
return new SimpleToString();
public static Elements elements() {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm clearly dumb, because I've asked this question in different flavors a few times, but once more for good measure. Sorry!

The last few commits in this PR left inner transforms generic; why is Elements public? Is it for further customization, or another reason for a difference in visibility?

Copy link
Contributor

Choose a reason for hiding this comment

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

No reason. I thought all of the public to private changes were being done in a different PR and all at once.

Copy link
Contributor Author

@jkff jkff left a comment

Choose a reason for hiding this comment

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

Also (github won't let me reply on original comments for some reason):

  • Removed the VisibleForTesting thing in Sample.Any
  • Made ToString classes back private (forgot to do it last time after the discussion on the thread)

Should be good to go after jenkins is green.

@Override
public TimestampedValue<T> addInput(TimestampedValue<T> accumulator,
TimestampedValue<T> input) {
TimestampedValue<T> input) {
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 usually apply google-java-format on the changed bits but in this case I guess I forgot.

Coder<TimestampedValue<T>> inputCoder) throws CannotProvideCoderException {
public Coder<TimestampedValue<T>> getAccumulatorCoder(
CoderRegistry registry, Coder<TimestampedValue<T>> inputCoder)
throws CannotProvideCoderException {
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 looked at some other instances of a throws on a new line in the codebase, and this style seems more common. It is also what google-java-format produces.

"inputCoder must be a TimestampedValueCoder, but was %s", inputCoder);
public Coder<T> getDefaultOutputCoder(
CoderRegistry registry, Coder<TimestampedValue<T>> inputCoder)
throws CannotProvideCoderException {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ditto.

@dhalperi
Copy link
Contributor

Thanks Eugene. I will merge when green.

@asfbot
Copy link

asfbot commented Mar 1, 2017

Refer to this link for build results (access rights to CI server needed):
https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/7987/

Build result: FAILURE

[...truncated 1.64 MB...] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at java.lang.Thread.run(Thread.java:745)Caused by: org.apache.maven.plugin.compiler.CompilationFailureException: Compilation failure/home/jenkins/jenkins-slave/workspace/beam_PreCommit_Java_MavenInstall@2/runners/spark/src/test/java/org/apache/beam/runners/spark/translation/streaming/CreateStreamTest.java:[117,71] cannot find symbol symbol: method withoutDefaults() location: class org.apache.beam.sdk.transforms.PTransform<org.apache.beam.sdk.values.PCollection<java.lang.Integer>,org.apache.beam.sdk.values.PCollection<java.lang.Long>> at org.apache.maven.plugin.compiler.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:1029) at org.apache.maven.plugin.compiler.TestCompilerMojo.execute(TestCompilerMojo.java:170) at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:134) at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:208) ... 31 more2017-03-01T00:13:08.632 [ERROR] 2017-03-01T00:13:08.632 [ERROR] Re-run Maven using the -X switch to enable full debug logging.2017-03-01T00:13:08.632 [ERROR] 2017-03-01T00:13:08.632 [ERROR] For more information about the errors and possible solutions, please read the following articles:2017-03-01T00:13:08.632 [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException2017-03-01T00:13:08.632 [ERROR] 2017-03-01T00:13:08.632 [ERROR] After correcting the problems, you can resume the build with the command2017-03-01T00:13:08.632 [ERROR] mvn -rf :beam-runners-sparkchannel stoppedSetting status of 70c1864 to FAILURE with url https://builds.apache.org/job/beam_PreCommit_Java_MavenInstall/7987/ and message: 'Build finished. 'Using context: Jenkins: Maven clean install
--none--

@asfbot
Copy link

asfbot commented Mar 1, 2017

@coveralls
Copy link

Coverage Status

Coverage increased (+0.07%) to 69.197% when pulling 0739a38 on jkff:style-guide into 352af85 on apache:master.

@jkff
Copy link
Contributor Author

jkff commented Mar 1, 2017

retest this please

@coveralls
Copy link

Coverage Status

Coverage increased (+0.06%) to 69.193% when pulling 0739a38 on jkff:style-guide into 352af85 on apache:master.

@asfbot
Copy link

asfbot commented Mar 1, 2017

@jkff
Copy link
Contributor Author

jkff commented Mar 1, 2017

OK, this failure is pretty clearly a flake, as well as the previous one.

@dhalperi
Copy link
Contributor

dhalperi commented Mar 1, 2017 via email

@asfgit asfgit closed this in d66029c Mar 1, 2017
@jkff jkff deleted the style-guide branch March 1, 2017 19:24
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.

5 participants