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

Make WeightEnum and Weights public + cleanups #7100

Merged
merged 9 commits into from Feb 2, 2023

Conversation

NicolasHug
Copy link
Member

@NicolasHug NicolasHug commented Jan 17, 2023

Towards #7094

@NicolasHug
Copy link
Member Author

@adamjstewart we're making the WeightsEnum class public - do you need the Weights class to be public as well? A past comment ( following up on #7107 (comment)) makes me think that you might not need it, but we're happy to expose it if yes.

@adamjstewart
Copy link
Contributor

Yes, we would like Weights to be public too. Otherwise, other libraries can't add their own Weights.

Another issue I noticed during our multi-weight API refactor was that the registration mechanism isn't public so all of the builtin torchvision.models.get_* functions don't work. We basically had to write our own: https://github.com/microsoft/torchgeo/blob/main/torchgeo/models/api.py

@NicolasHug NicolasHug marked this pull request as ready for review January 25, 2023 10:12
@NicolasHug NicolasHug changed the title WIP Make WeightEnum public + cleanups Make WeightEnum public + cleanups Jan 25, 2023
@NicolasHug
Copy link
Member Author

Thanks for the feedback - @pmeier I think this is ready for review - LMK if you think we should add tests. I'd rather leave the docs for another PR one we get more feedback from @adamjstewart , but happy to hear your thoughts.

Another issue I noticed during our multi-weight API refactor was that the registration mechanism isn't public so all of the builtin torchvision.models.get_* functions don't work. We basically had to write our own: https://github.com/microsoft/torchgeo/blob/main/torchgeo/models/api.py

I'll comment on #6365

@pmeier pmeier self-requested a review January 30, 2023 11:19
Copy link
Collaborator

@pmeier pmeier left a comment

Choose a reason for hiding this comment

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

Thanks Nicolas!

Comment on lines 19 to 20
# We're making Weights and WeightsEnum public for packages like torchgeo who are
# interested in using them https://github.com/pytorch/vision/issues/7094
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure if that is required as a code comment? I mean we don't explain for all the other things as well. Aren't we just taking them as part of the public API now?

Copy link
Member Author

Choose a reason for hiding this comment

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

They're sort of special in the sense that they're more developer tools intended to be used by downstream libraries, rather than your typical transform / model which are made for end users.
I don't think we have ever made any developer tool public yet, and I added the comment to indicate that this is not done by mistake. I won't fight to keep it though :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good point, I didn't consider that. Maybe change the wording to something like "These are public ..."? My initial understanding was that this was meant as a comment for the reviewer or the PR not someone arbitrary looking at the code.

Copy link
Member Author

Choose a reason for hiding this comment

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

I updated the comment, hopefully the intent is clear now!

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, I like the wording better now.


# We're making Weights and WeightsEnum public for packages like torchgeo who are
# interested in using them https://github.com/pytorch/vision/issues/7094
# TODO: we could / should document them publicly as well?
Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes. Maybe even in this PR?

Copy link
Member Author

Choose a reason for hiding this comment

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

Following up on my comment above about the fact that these are the first developer-facing tools, do you have thoughts on where / how we should document them?
I typically think it shouldn't be part of the already quite dense models doc page.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah, you are right. With our new maintainer guide, downstream libraries are safe in the sense that we put them under our BC policy. My only concern is discoverability. If we leave it as is, people that want something like this maybe don't know that it is there? Or do we expect them to look into our implementation anyway? cc @adamjstewart

Copy link
Member Author

@NicolasHug NicolasHug Feb 1, 2023

Choose a reason for hiding this comment

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

Since it's a first, I'm tempted to leave them undocumented for now and see how it goes. Developers who need those would check the code IMO (or not, rightfully assuming that they're public since they can be imported from torchvision.models).

Copy link
Contributor

Choose a reason for hiding this comment

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

From a TorchGeo perspective, we're fine with having to read the source code to figure out how to use the weights. But our docs try to link to the base class docs, so if the base class isn't documented we have to add an ignore. So long term, it would be cool if it was documented, but not a hard requirement.

@NicolasHug NicolasHug changed the title Make WeightEnum public + cleanups Make WeightEnum and Weights public + cleanups Feb 2, 2023
@NicolasHug NicolasHug merged commit 135a0f9 into pytorch:main Feb 2, 2023
@github-actions
Copy link

github-actions bot commented Feb 2, 2023

Hey @NicolasHug!

You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py

facebook-github-bot pushed a commit that referenced this pull request Feb 9, 2023
Reviewed By: vmoens

Differential Revision: D43116103

fbshipit-source-id: 8283b5f1a94dd934f9f7c87e6ec5492733ed910a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants