-
Notifications
You must be signed in to change notification settings - Fork 246
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
API management and documentation mechanisms #1701
Conversation
b668f1c
to
e686418
Compare
I had to experiment on my fork to properly debug the Github actions. The end result on Github pages would look like this: (It used to be that this page contained only the schema, and now it has been extended to API docs. The schema is still there at https://vshampor.github.io/nncf/schema) The page contains only the description of entities that were decorated with For demo of auto PR labeling, see: NB: automatic PR labeling basically works by comparing API reference HTML content between develop and the state in a given PR. |
I think we should also include
|
Done |
@@ -0,0 +1 @@ | |||
{% extends "python/data.rst" %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These and other .rst files control the layout of the documentation and are copy-and-pasted from defaults, for future adjustments if necessary.
@@ -0,0 +1,114 @@ | |||
import importlib |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file controls the documentation build process that is executed during sphinx-build
.
|
||
|
||
with mock(['torch', 'torchvision', 'onnx', 'onnxruntime', 'openvino', 'tensorflow', 'tensorflow_addons']): | ||
api_fqns = collect_api_entities() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This code allows to collect API entities without having to install all backends at once.
It looks great really, thanks @vshampor . I have three major comments:
I think some follow up issues and PRs should be merged to address the last two issues. |
Sure, will do this in a follow-up PR along with docstring formatting adjustments.
Basically everything that can be written in a docstring will be rendered, so there should be no problem to add config snippets and even code snippets via doctest later.
I'll see if I can add another wrapper function to do this via code, maybe in this PR even. |
@@ -26,6 +27,7 @@ | |||
from nncf.parameters import TargetDevice | |||
|
|||
|
|||
@api(canonical_alias="nncf.quantize") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@AlexKoff88 check this out - in this way it can be specified that the canonical import name should be "nncf.quantize", and the docs will be generated with the canonical import name in mind. Note that this also requires that the symbol itself is imported in corresponding __init__.py
file (in this case, nncf/__init__.py
), otherwise the doc build will fail and the doc build check will be red. I regenerated the page at https://vshampor.github.io/nncf/index.html so that you can see the effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I cannot find quantize() in the latest version of the API build, only quantize_with_accuracy_control().
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed - make sure to reload the page with Ctrl-Shift-R so that you don't get a cached version.
One of the reasons was that had a function quantize
exposed in __init__.py
in the same subpackage that also contained the module called quantize.py
. This meant that the quantize.py
file was effectively impossible to import from, apart from the exposed quantize
and quantize_with_accuracy_control
functions, and this broke down the doc search mechanism, and is anyway considered to be bad practice (since the imported name shadows the subpackage name). Had to rename the quantize.py
to quantize_fns.py
, if you have suggestions for a better name, please post them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vshampor I would recommend to rename quantize.py
-> quantize_model.py
because torch has already quantize_functions.py
https://github.com/openvinotoolkit/nncf/blob/develop/nncf/torch/quantization/quantize_functions.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please, rebase PR.
9cb5ecf
to
6956f04
Compare
Changes
Added a decorator for marking entities as API and a set of Github actions to check whether a PR changes API (if so, then the PR will be automatically labeled as such) and to generate and push API documentation automatically to Github pages using Sphinx, AutoAPI (by readthedocs) and custom API name collection code.
Reason for changes
Both devs and users will finally have an understanding of what is considered API and what is not, and have an opportunity to browse API documentation without having to look into source code.
Related tickets
99696
Tests
N/A