Skip to content

Add retire warning to legacy code #863

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

Merged
merged 9 commits into from
Jul 14, 2020

Conversation

zhangguanheng66
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Jul 1, 2020

Codecov Report

Merging #863 into master will increase coverage by 0.08%.
The diff coverage is 93.75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #863      +/-   ##
==========================================
+ Coverage   77.35%   77.43%   +0.08%     
==========================================
  Files          43       43              
  Lines        3029     3045      +16     
==========================================
+ Hits         2343     2358      +15     
- Misses        686      687       +1     
Impacted Files Coverage Δ
torchtext/data/example.py 85.71% <83.33%> (-0.21%) ⬇️
torchtext/data/batch.py 71.42% <100.00%> (+1.05%) ⬆️
torchtext/data/field.py 92.83% <100.00%> (+0.14%) ⬆️
torchtext/data/iterator.py 62.66% <100.00%> (+0.50%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e568526...8ed6148. Read the comment docs.

@@ -19,6 +20,7 @@ class Batch(object):

def __init__(self, data=None, dataset=None, device=None):
"""Create a Batch from a list of examples."""
warnings.warn('Batch class will retire in 0.8.0 release', RuntimeWarning)
Copy link
Contributor

Choose a reason for hiding this comment

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

According to this comment, PyTorch's convention for deprecation is UserWarning.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks

Copy link
Contributor

@mthrok mthrok left a comment

Choose a reason for hiding this comment

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

FYI: torchaudio has depricated decorator which can be used for both function and a class.

@@ -9,6 +10,7 @@ class Example(object):
"""
@classmethod
def fromJSON(cls, data, fields):
warnings.warn('Example class will retire in 0.8.0 release', RuntimeWarning)
Copy link
Contributor

Choose a reason for hiding this comment

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

For all of these warnings, the user could ask themselves many questions. Is there any context that should be given? What is the user to do instead? Should the user file an issue if they can't do what they want?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We have an issue to explain this change. I might add this to the warning message. And in 0.7.0 release note, I will introduce this again.

Copy link
Contributor

Choose a reason for hiding this comment

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

Would adding the link in the message be a good idea? btw can you share the link here in the comment? :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

Based on offline discussion: Please use a standard message for all. The message needs to say: (1) users are recommended to move to the new interface by doing abc, but (2) they can keep using the same functionality without the warning by doing xyz.

@@ -19,6 +20,7 @@ class Batch(object):

def __init__(self, data=None, dataset=None, device=None):
"""Create a Batch from a list of examples."""
warnings.warn('Batch class will retire in 0.8.0 release and stay in torchtext.legacy. See 0.7.0 release note for the replacement.', UserWarning)
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add the link to the release notes?

Copy link
Contributor Author

@zhangguanheng66 zhangguanheng66 Jul 8, 2020

Choose a reason for hiding this comment

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

For now, we don't have a link. And I'm thinking if it's proper to add a link in warning message.

If we put URL on message, there is a high chance that certain user codebase outlive the URL itself, so I do not think adding URL is a good idea. It's better to have a self-complete message. IIRC the discussion, those code will be moved to torchtext.legacy module, right? Can we just say "Use torchtext.legacy"?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a good question, but I'm also not a fan of mentioning the release notes alone :)

@@ -9,6 +10,7 @@ class Example(object):
"""
@classmethod
def fromJSON(cls, data, fields):
warnings.warn('Example class will retire in 0.8.0 release and stay in torchtext.legacy. See 0.7.0 release note for the replacement.', UserWarning)
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd change the phrasing of this a bit.

"Example class will retire in 0.8.0 release and stay in torchtext.legacy. See 0.7.0 release note for the replacement"

to

"Example class will be retired in the 0.8.0 release and moved to torchtext.legacy. Please see 0.7.0 release notes for further information."

Copy link
Contributor

Choose a reason for hiding this comment

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

Did we settle on UserWarning? cc @gchanan

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With some offline discussions, UserWarning is proper, though pytorch started to use FutureWarning.

@@ -9,6 +10,7 @@ class Example(object):
"""
@classmethod
def fromJSON(cls, data, fields):
warnings.warn('Example class will be retired in the 0.8.0 release and moved to torchtext.legacy. Please see 0.7.0 release note for further information.', UserWarning)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: It's "notes" not "note".

@zhangguanheng66 zhangguanheng66 merged commit 07abf6d into pytorch:master Jul 14, 2020
@zhangguanheng66 zhangguanheng66 deleted the legacy_warning branch July 16, 2020 17:53
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.

4 participants