Skip to content

[BEAM-2306] Fail build when @Deprecated is used without @deprecated javadoc#3531

Closed
alex-filatov wants to merge 4 commits intoapache:masterfrom
alex-filatov:beam-2306-check-missing-deprecated
Closed

[BEAM-2306] Fail build when @Deprecated is used without @deprecated javadoc#3531
alex-filatov wants to merge 4 commits intoapache:masterfrom
alex-filatov:beam-2306-check-missing-deprecated

Conversation

@alex-filatov
Copy link
Contributor

@alex-filatov alex-filatov commented Jul 10, 2017

Add checkstyle check to fail the build when @Deprecated is used without @deprecated javadoc (or vice versa).

The check is disabled for existing violations where reason for deprecation and/or alternative is not clear.

…s used without @deprecated javadoc (or vice versa).

The check is disabled for existing violations where reason for deprecation and/or alternative is not clear.
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.009%) to 70.963% when pulling 0694dcc on alex-filatov:beam-2306-check-missing-deprecated into 9f904dc on apache:master.

@alex-filatov
Copy link
Contributor Author

R: @kennknowles

Copy link
Member

@kennknowles kennknowles left a comment

Choose a reason for hiding this comment

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

Thanks! I've added a lot of content, so we can just not have any undocumented deprecation left.

}

/**
* @deprecated use {@link #setTimer(StateNamespace, String, Instant, TimeDomain)}.
Copy link
Member

Choose a reason for hiding this comment

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

I think here you can do @inheritdoc so you don't have to spell it out again. And same throughout.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately doesn't work. Only main description, @param, @returns, @throws are inheritable.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, too bad. Thanks for clarifying.

PCollectionView.class.getSimpleName());
}

// CHECKSTYLE.OFF: MissingDeprecated
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for putting this together! I will just provide commentary for these so you don't have to use exclusions.

@deprecated runners should move away from translating `CreatePCollectionView`
    and treat this as part of the translation for a `ParDo` side input.

}

/** Registers {@link CreatePCollectionViewTranslator}. */
// CHECKSTYLE.OFF: MissingDeprecated
Copy link
Member

Choose a reason for hiding this comment

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

Same as above.

* A marker {@link DoFn} for writing the contents of a {@link PCollection} to a streaming
* {@link PCollectionView} backend implementation.
*/
// CHECKSTYLE.OFF: MissingDeprecated
Copy link
Member

Choose a reason for hiding this comment

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

I think this @Deprecated can just be switched to @Internal. The important thing is that this is not for users anyhow.

*/
public abstract class Coder<T> implements Serializable {
/** The context in which encoding or decoding is being done. */
// CHECKSTYLE.OFF: MissingDeprecated
Copy link
Member

Choose a reason for hiding this comment

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

@deprecated to implement a coder, do not use any `Context`. Just implement only those abstract methods which do not accept a `Context` and leave the default implementations for methods accepting a `Context`.

*/
// CHECKSTYLE.OFF: MissingDeprecated
@Deprecated
// CHECKSTYLE.ON: MissingDeprecated
Copy link
Member

Choose a reason for hiding this comment

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

@deprecated `getCoderFromDescriptor(TypeDescriptor, Map)

Copy link
Member

Choose a reason for hiding this comment

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

There is no intended alternative, this is a visibility issue and this code should be moved into the CombineFns class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So purpose of the deprecation here is to attract attention to the @Internal annotation? In this case I propose to remove deprecation for consistency with the remaining codebase.

Copy link
Member

Choose a reason for hiding this comment

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

See above comment - just deprecated to indicate that it is going to change. So even though it is @Internal (and the javadoc should be loud about this, like in other places) it is helpful for contributors to see their IDEs strikethrough the method.

*/
// CHECKSTYLE.OFF: MissingDeprecated
@Deprecated
// CHECKSTYLE.ON: MissingDeprecated
Copy link
Member

Choose a reason for hiding this comment

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

@deprecated `getCoderFromDescriptor(TypeDescriptor, Map)

Copy link
Member

Choose a reason for hiding this comment

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

getCoderFromDescriptor doesn't exist, do you mean the private getCoderFromTypeDescriptor?.

Also, this method has no replacement and is really meant to be copied into ParDo having ParDo own all that logic.

Copy link
Member

Choose a reason for hiding this comment

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

Yea, I mean getCoderFromTypeDescriptor. Basically we do need at least one (and probably exactly one) public method where you can pass in a context of type-to-coder bindings. And the rest should be directed to use that.

Copy link
Member

Choose a reason for hiding this comment

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

Ken, have you seen enough demand for such a function in user based transforms that warrants visibility vs having a few independent copies?

Copy link
Member

Choose a reason for hiding this comment

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

I don't think it can be implemented outside of the registry.

Copy link
Member

Choose a reason for hiding this comment

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

Maybe if all the uses are just special cases that don't require real coder inference, that could be fine. But this method itself is quite simple so probably specialized versions would add complexity. I'm open to whatever, though.

Copy link
Member

Choose a reason for hiding this comment

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

If you don't believe that is possible, we should change the @deprecated comment to be something like:
@deprecated This method is to change in an unknown backwards incompatible way once support for this functionality is refined.

Similarly for the other CoderRegistry @Internal/@Deprecated methods.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me

* }
* </code></pre>
*/
// CHECKSTYLE.OFF: MissingDeprecated
Copy link
Member

Choose a reason for hiding this comment

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

@deprecated tests which use unbounded PCollections should be in the category {@link UsesUnboundedPCollections}. Beyond that, it is up to the runner and test configuration to decide whether to run in streaming mode.


// CHECKSTYLE.OFF: MissingDeprecated
@Deprecated
// CHECKSTYLE.ON: MissingDeprecated
Copy link
Member

Choose a reason for hiding this comment

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

I actually don't think this should be deprecated.

/**
* Returns if a default value was specified.
*/
// CHECKSTYLE.OFF: MissingDeprecated
Copy link
Member

Choose a reason for hiding this comment

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

@deprecated these methods are all expected to change arbitrarily

But really, @Internal is probably enough.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 70.845% when pulling f1a3e19 on alex-filatov:beam-2306-check-missing-deprecated into 9f904dc on apache:master.

}

/**
* @deprecated use {@link #setTimer(StateNamespace, String, Instant, TimeDomain)}.
Copy link
Member

Choose a reason for hiding this comment

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

Ah, too bad. Thanks for clarifying.


// CHECKSTYLE.OFF: MissingDeprecated
@Deprecated
// CHECKSTYLE.ON: MissingDeprecated
Copy link
Member

Choose a reason for hiding this comment

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

This is another case of the CreatePCollectionView transform being deprecated entirely.

*/
// CHECKSTYLE.OFF: MissingDeprecated
@Deprecated
// CHECKSTYLE.ON: MissingDeprecated
Copy link
Member

Choose a reason for hiding this comment

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

Sounds good to me

*/
// CHECKSTYLE.OFF: MissingDeprecated
@Deprecated
// CHECKSTYLE.ON: MissingDeprecated
Copy link
Member

Choose a reason for hiding this comment

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

See above comment - just deprecated to indicate that it is going to change. So even though it is @Internal (and the javadoc should be loud about this, like in other places) it is helpful for contributors to see their IDEs strikethrough the method.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.1%) to 70.841% when pulling 499bd87 on alex-filatov:beam-2306-check-missing-deprecated into 9f904dc on apache:master.

@alex-filatov
Copy link
Contributor Author

All done. Please take a look.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.008%) to 70.624% when pulling dfe9326 on alex-filatov:beam-2306-check-missing-deprecated into 7fde976 on apache:master.

Copy link
Member

@kennknowles kennknowles left a comment

Choose a reason for hiding this comment

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

LGTM. Nice!

@asfgit asfgit closed this in a6f460f Jul 19, 2017
@jkff
Copy link
Contributor

jkff commented Jul 22, 2017

This PR broke Dataflow runner because it deleted this code:
https://github.com/apache/beam/pull/3531/files#diff-59c03929b0864dc394262c8c6d19880bL240
The comments on that code should have been more clear, like "Do not delete this without running Dataflow ValidatesRunner tests" :)

@alex-filatov
Copy link
Contributor Author

Sorry for this. I couldn't find usage of this code in the repo, so assumed it was safe to delete.

@kennknowles
Copy link
Member

No need to apologize. Your PR was just fine. It is on us to either make it a core part of the API or document why it exists despite being unused. Since it was leftover for compatibility, one way to make it obvious would be with a test in DataflowRunner.

And [partial] rollbacks are painless - don't view it as indicating any fault. A large number of our tests do not run until postcommit (to avoid massive amounts of computation) so it is expected for such things to happen fairly often.

@alex-filatov alex-filatov deleted the beam-2306-check-missing-deprecated branch October 19, 2017 15:28
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