-
Notifications
You must be signed in to change notification settings - Fork 7.2k
Add torchvision maintainers guide #7109
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
Changes from 7 commits
c3b5123
9ac0619
d387e4a
db37892
65184cb
96c85be
2770306
8136386
9ef4694
c8c0500
a733e90
45b30e3
44086be
ca70dd1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,75 @@ | ||
| ## Torchvision maintainers guide | ||
|
|
||
| This document aims at documenting user-facing policies / principles used when | ||
| developing and maintaining torchvision. Other maintainer info (e.g. release | ||
| process) can be found in the internal wiki. | ||
|
|
||
| ### What is public and what is private? | ||
|
|
||
| For the Python API, torchvision largely follows the [torch core | ||
|
||
| policy](https://github.com/pytorch/pytorch/wiki/Public-API-definition-and-documentation) | ||
| which is consistent with other major packages (numpy, scikit-learn etc.). | ||
NicolasHug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| We recognize that his policy is somewhat imperfect for some edge cases, and that | ||
| it's difficult to come up with an accurate technical definition. In broad terms, | ||
| which are usually well understood by user, the policy is that: | ||
|
|
||
| - modules that can be accessed without leading underscore are public | ||
| - objects in a public file that don't have a leading underscore are public | ||
| - objects that start with a leading underscore are private unless they're | ||
| exposed / aliased as public in a public `__init__.py` file | ||
|
||
| - class attributes are public iff they have no leading underscore | ||
|
|
||
| The public API has backward-compatible (BC) guarantees defined in our | ||
| deprecation policy (see below). The private API has not BC guarantees. | ||
|
|
||
| For C++, code is private. If a change breaks fbcode, fix fbcode or revert the | ||
| change. We should be careful about models running in prod and relying on | ||
NicolasHug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| torchvision ops. | ||
NicolasHug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| The `test` folder is not importable and is **private.** Even meta-internal | ||
| projects should *not* rely on it (it has happned in the past and is now | ||
NicolasHug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| programmatically impossible.) | ||
NicolasHug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| The training references do not have BC guarantees. Breaking changes are | ||
| possible, but we should make sure that the tutorials are still running properly, | ||
| and that their intended narrative is preserved (by e.g. checking outputs, | ||
| etc.). | ||
|
|
||
| The rest of the folders (build, android, ios) are private and have no BC | ||
NicolasHug marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| guarantees. | ||
|
|
||
| ### Deprecation policy. | ||
|
|
||
| Because they're disruptive, **deprecations should only be used sparingly**. | ||
|
|
||
| We largely follow the [torch core | ||
| policy](https://github.com/pytorch/pytorch/wiki/PyTorch's-Python-Frontend-Backward-and-Forward-Compatibility-Policy): | ||
| breaking changes require a deprecation period of at least 2 versions. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I would assume that this document is not intended to users. However this part and other part about C++ being private, it worth exposing to the users.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree... Perhaps changing the title from |
||
|
|
||
| Deprecations should clearly indicate their deadline in the docs and warning | ||
| messages. Avoid not committing to a deadline, or keeping deprecated APIs for too | ||
| long: it gives no incentive for users to update their code, sends conflicting | ||
| messages ("why was this API removed while this other one is still around?"), and | ||
| accumulates debt in the project. | ||
|
|
||
| ### Should this attribute be public? Should this function be private? | ||
|
|
||
| When designing an API it’s not always obvious what should be exposed as public, | ||
| and what should be kept as a private implementation detail. The following | ||
| guidelines can be useful: | ||
|
|
||
| * Functional consistency throughout the library is a top priority, for users and | ||
| developers’ sake. In doubt and unless it’s clearly wrong, expose what other | ||
| similar classes expose. | ||
| * Think really hard about the users and their use-cases, and try to expose what | ||
| they would need to address those use-cases. Aggressively keep everything else | ||
| private. Remember that the “private -> public” direction is way smoother than | ||
| the “public -> private” one: in doubt, keep it private. | ||
| * When thinking about use-cases, the general API motto applies: make what’s | ||
| simple and common easy, and make what’s complex possible (80% / 20% rule). | ||
| There might be a ~1% left that’s not addressed: that’s OK. Also, **make what’s | ||
| wrong very hard**, if not impossible. | ||
|
|
||
| As a good practice, always create new files and even classes with a leading | ||
| underscore in their name. This way, everything is private by default and the | ||
| only public surface is explicitly present in an `__init__.py` file. | ||
Uh oh!
There was an error while loading. Please reload this page.