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

Skip the warning in gpytorch.lazy.__getattr__ if name starts with _ #2423

Merged
merged 1 commit into from
Oct 26, 2023

Conversation

saitcakmak
Copy link
Collaborator

The current setup leads to the unittest self.assertWarns... to wrongly trigger a warning when entering _AssertWarnsContext (calls getattr on all modules: /~https://github.com/python/cpython/blob/main/Lib/unittest/case.py#L292-L294). Filtering out based on name starting with _ eliminates the needless warning and keeps the correct behavior.

saitcakmak added a commit to saitcakmak/botorch that referenced this pull request Oct 17, 2023
Summary:
Updates some code & tests that lead to deprecation & other warnings.

See also cornellius-gp/gpytorch#2423

Differential Revision: D50384526
@esantorella
Copy link
Collaborator

Hm, this seems like a very roundabout way of preventing this warning from being raised in an _AssertWarnsContext. Could the check be changed from if not name.startswith("_") to if name != "__warningregistry__"? Failing that, it would be good to have a comment explaining why the underscore check exists.

Or maybe the warning should be somewhere else? Perhaps in deprecated_lazy_tensor or deprecated_lazy_tensor.__init__, so it's only raised when a LazyTensor is actually instantiated?

saitcakmak added a commit to saitcakmak/botorch that referenced this pull request Oct 17, 2023
Summary:

Updates some code & tests that lead to deprecation & other warnings.

See also cornellius-gp/gpytorch#2423

Reviewed By: esantorella

Differential Revision: D50384526
@saitcakmak
Copy link
Collaborator Author

I left this check intentionally general since there may be other uses of getattr that we are not aware of, leading to the same warning elsewhere.

Or maybe the warning should be somewhere else? Perhaps in deprecated_lazy_tensor or deprecated_lazy_tensor.init, so it's only raised when a LazyTensor is actually instantiated?

Yeah, that could work. It is a bit of a trade-off between raising the warning at import vs instantiation time. Assuming interactive development: import time warning says "don't use this thing" before you start using it; instantiation time warning says "go back and change this to the correct class", which is a bit more work.

These have been deprecated for over a year by now, so the right move might be to reap them altogether.

saitcakmak added a commit to saitcakmak/botorch that referenced this pull request Oct 17, 2023
Summary:

Updates some code & tests that lead to deprecation & other warnings.

See also cornellius-gp/gpytorch#2423

Reviewed By: esantorella

Differential Revision: D50384526
saitcakmak added a commit to saitcakmak/botorch that referenced this pull request Oct 18, 2023
Summary:

Updates some code & tests that lead to deprecation & other warnings.

See also cornellius-gp/gpytorch#2423

Reviewed By: esantorella

Differential Revision: D50384526
saitcakmak added a commit to saitcakmak/botorch that referenced this pull request Oct 18, 2023
Summary:

Updates some code & tests that lead to deprecation & other warnings.

See also cornellius-gp/gpytorch#2423

Reviewed By: esantorella

Differential Revision: D50384526
saitcakmak added a commit to saitcakmak/botorch that referenced this pull request Oct 18, 2023
Summary:

Updates some code & tests that lead to deprecation & other warnings.

See also cornellius-gp/gpytorch#2423

Reviewed By: esantorella

Differential Revision: D50384526
facebook-github-bot pushed a commit to pytorch/botorch that referenced this pull request Oct 18, 2023
Summary:
Pull Request resolved: #2049

Updates some code & tests that lead to deprecation & other warnings.

See also cornellius-gp/gpytorch#2423

Reviewed By: esantorella

Differential Revision: D50384526

fbshipit-source-id: ad40950c0e92996df3c0bf7ad4db79001e04cebf
@Balandat
Copy link
Collaborator

These have been deprecated for over a year by now, so the right move might be to reap them altogether.

It'd be nice to get rid of the lazies and this special handling - cc @gpleiss

@saitcakmak
Copy link
Collaborator Author

Should we land this and follow up with full deprecation later?

@gpleiss
Copy link
Member

gpleiss commented Oct 26, 2023

Oops sorry for the slow reply. I think it makes sense to land this, and then we can go with full deprecation later.

In general, we should do a deprecation sweep and actually get rid of all of the things marked as deprecated. I think everything marked has deprecated has been deprecated for over a year at least.

@gpleiss gpleiss merged commit b491ad6 into master Oct 26, 2023
@gpleiss gpleiss deleted the saitcakmak-patch-1 branch October 26, 2023 22:30
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