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

Non-API change #8

Closed
wants to merge 19 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
45 changes: 45 additions & 0 deletions .github/workflows/api_changes_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: API changes check
on:
pull_request:
branches:
- develop

env:
API_DOC_HTML_ROOT_RELATIVE_PATH: autoapi

concurrency:
group: ci-${{ github.head_ref }}-${{ github.workflow }}
cancel-in-progress: true

jobs:
call-build-api-doc:
uses: ./.github/workflows/build_html_doc.yml
compare-api-doc-with-develop:
needs: call-build-api-doc
runs-on: ubuntu-latest
steps:
- name: Download built HTML doc as artifact from previous step
uses: alehechka/download-tartifact@v2
with:
name: html_doc_artifact
- name: Checkout latest doc_pages branch tip
uses: actions/checkout@v3
with:
ref: doc_pages
path: previous_doc_state
- name: Get changed file names in API doc path
id: diff
run: |
cd html_build/html/$API_DOC_HTML_ROOT_RELATIVE_PATH
CHANGED_FILES=$(find . -name "*.html" -exec diff -qrBZ {} $GITHUB_WORKSPACE/previous_doc_state/$API_DOC_HTML_ROOT_RELATIVE_PATH/{} \;)
echo ${CHANGED_FILES}
CHANGED_FILES=$(echo $CHANGED_FILES | tr '\n' ' ')
echo "changed_files=${CHANGED_FILES}" >> $GITHUB_OUTPUT
- uses: actions-ecosystem/action-remove-labels@v1
if: ${{ !contains(steps.diff.outputs.changed_files, 'differ') }}
with:
labels: API
- uses: actions-ecosystem/action-add-labels@v1
if: ${{ contains(steps.diff.outputs.changed_files, 'differ') }}
with:
labels: API
41 changes: 41 additions & 0 deletions .github/workflows/build_and_publish_doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Build complete docs and publish to GH Pages
on:
push:
branches:
- develop

env:
GH_PAGES_BRANCH: doc_pages

concurrency:
group: ci-${{ github.head_ref }}-${{ github.workflow }}
cancel-in-progress: true

permissions:
contents: write
jobs:
call-build-html-doc:
uses: ./.github/workflows/build_html_doc.yml
call-build-schema-page:
uses: ./.github/workflows/build_schema_page.yml
publish:
needs: [call-build-html-doc, call-build-schema-page]
runs-on: ubuntu-latest
steps:
- name: Checkout main repo # the github-pages-deploy-action seems to require this step
uses: actions/checkout@v3
- name: Download HTML doc build artifact
uses: alehechka/download-tartifact@v2
with:
name: html_doc_artifact
- name: Download schema doc build artifact
uses: alehechka/download-tartifact@v2
with:
name: schema_doc_artifact
path: html_build/html
- name: Publish built docs on Github Pages branch ${{ env.GH_PAGES_BRANCH }}
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: html_build/html
token: ${{ secrets.PUSH_TO_GH_PAGES_BRANCH }}
branch: ${{ env.GH_PAGES_BRANCH }}
21 changes: 21 additions & 0 deletions .github/workflows/build_html_doc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: HTML documentation build
on:
workflow_call:
jobs:
build-html:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Install NNCF and doc requirements
run: |
pip install -e .
pip install -r docs/api/requirements.txt
- name: Build API docs
run: |
sphinx-build -M html docs/api/source html_build
- name: Upload built HTMLs as job artifact
uses: alehechka/upload-tartifact@v2
with:
name: html_doc_artifact
path: html_build/html
28 changes: 10 additions & 18 deletions .github/workflows/build_schema_page.yml
Original file line number Diff line number Diff line change
@@ -1,31 +1,23 @@
name: Config schema HTML build
on:
push:
branches:
- develop
- test_for_doc_build_trigger
paths:
- nncf/config/**
permissions:
contents: write
workflow_call:
jobs:
build-and-deploy:
concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
build-config-schema-html:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install and Build # This example project is built using npm and outputs the result to the 'build' folder. Replace with the commands required to build your project, or remove this step entirely if your site is pre-built.
- name: Install and Build
run: |
pip install json-schema-for-humans
pip install -e .
python -c 'import jstyleson; from nncf.config import NNCFConfig; jstyleson.dump(NNCFConfig.schema(), open("./schema.json", "w"), indent=2)'
mkdir schema_html_build
generate-schema-doc --deprecated-from-description schema.json schema_html_build/index.html
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
mkdir schema
generate-schema-doc --deprecated-from-description schema.json schema/index.html

- name: Upload result as artifact
uses: alehechka/upload-tartifact@v2
with:
folder: schema_html_build # The folder the action should deploy.
token: ${{ secrets.PUSH_TO_GH_PAGES_BRANCH }}
branch: doc_pages
name: schema_doc_artifact
path: schema
4 changes: 2 additions & 2 deletions .github/workflows/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: "Pull Request Labeler"
on: [pull_request_target]

jobs:
triage:
set-label:
permissions:
contents: read
pull-requests: write
Expand All @@ -11,5 +11,5 @@ jobs:
- uses: actions/labeler@v4
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
configuration-path: '.github/labeler.yml'
configuration-path: '.github/action_configs/labeler.yml'
sync-labels: true
2 changes: 1 addition & 1 deletion .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# This workflow will upload a Python Package using Twine when a release is created
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions#publishing-to-package-registries

name: Upload Python Package
name: Publish release Python package to PyPI

on:
release:
Expand Down
20 changes: 20 additions & 0 deletions docs/api/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line, and also
# from the environment for the first two.
SPHINXOPTS ?=
SPHINXBUILD ?= sphinx-build
SOURCEDIR = source
BUILDDIR = build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
3 changes: 3 additions & 0 deletions docs/api/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Sphinx==6.1.3
sphinx-autoapi==2.1.0
sphinx-book-theme==1.0.1
13 changes: 13 additions & 0 deletions docs/api/source/_autoapi_templates/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
NNCF API Reference
=============

.. toctree::
:titlesonly:

{% for page in pages %}
{% if page.top_level_object and page.display %}
{{ page.include_path }}
{% endif %}
{% endfor %}


1 change: 1 addition & 0 deletions docs/api/source/_autoapi_templates/python/attribute.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends "python/data.rst" %}
58 changes: 58 additions & 0 deletions docs/api/source/_autoapi_templates/python/class.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{% if obj.display %}
.. py:{{ obj.type }}:: {{ obj.short_name }}{% if obj.args %}({{ obj.args }}){% endif %}
{% for (args, return_annotation) in obj.overloads %}
{{ " " * (obj.type | length) }} {{ obj.short_name }}{% if args %}({{ args }}){% endif %}
{% endfor %}


{% if obj.bases %}
{% if "show-inheritance" in autoapi_options %}
Bases: {% for base in obj.bases %}{{ base|link_objs }}{% if not loop.last %}, {% endif %}{% endfor %}
{% endif %}


{% if "show-inheritance-diagram" in autoapi_options and obj.bases != ["object"] %}
.. autoapi-inheritance-diagram:: {{ obj.obj["full_name"] }}
:parts: 1
{% if "private-members" in autoapi_options %}
:private-bases:
{% endif %}

{% endif %}
{% endif %}
{% if obj.docstring %}
{{ obj.docstring|indent(3) }}
{% endif %}
{% if "inherited-members" in autoapi_options %}
{% set visible_classes = obj.classes|selectattr("display")|list %}
{% else %}
{% set visible_classes = obj.classes|rejectattr("inherited")|selectattr("display")|list %}
{% endif %}
{% for klass in visible_classes %}
{{ klass.render()|indent(3) }}
{% endfor %}
{% if "inherited-members" in autoapi_options %}
{% set visible_properties = obj.properties|selectattr("display")|list %}
{% else %}
{% set visible_properties = obj.properties|rejectattr("inherited")|selectattr("display")|list %}
{% endif %}
{% for property in visible_properties %}
{{ property.render()|indent(3) }}
{% endfor %}
{% if "inherited-members" in autoapi_options %}
{% set visible_attributes = obj.attributes|selectattr("display")|list %}
{% else %}
{% set visible_attributes = obj.attributes|rejectattr("inherited")|selectattr("display")|list %}
{% endif %}
{% for attribute in visible_attributes %}
{{ attribute.render()|indent(3) }}
{% endfor %}
{% if "inherited-members" in autoapi_options %}
{% set visible_methods = obj.methods|selectattr("display")|list %}
{% else %}
{% set visible_methods = obj.methods|rejectattr("inherited")|selectattr("display")|list %}
{% endif %}
{% for method in visible_methods %}
{{ method.render()|indent(3) }}
{% endfor %}
{% endif %}
37 changes: 37 additions & 0 deletions docs/api/source/_autoapi_templates/python/data.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{% if obj.display %}
.. py:{{ obj.type }}:: {{ obj.name }}
{%- if obj.annotation is not none %}

:type: {%- if obj.annotation %} {{ obj.annotation }}{%- endif %}

{%- endif %}

{%- if obj.value is not none %}

:value: {% if obj.value is string and obj.value.splitlines()|count > 1 -%}
Multiline-String

.. raw:: html

<details><summary>Show Value</summary>

.. code-block:: python

"""{{ obj.value|indent(width=8,blank=true) }}"""

.. raw:: html

</details>

{%- else -%}
{%- if obj.value is string -%}
{{ "%r" % obj.value|string|truncate(100) }}
{%- else -%}
{{ obj.value|string|truncate(100) }}
{%- endif -%}
{%- endif %}
{%- endif %}


{{ obj.docstring|indent(3) }}
{% endif %}
1 change: 1 addition & 0 deletions docs/api/source/_autoapi_templates/python/exception.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{% extends "python/class.rst" %}
15 changes: 15 additions & 0 deletions docs/api/source/_autoapi_templates/python/function.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{% if obj.display %}
.. py:function:: {{ obj.short_name }}({{ obj.args }}){% if obj.return_annotation is not none %} -> {{ obj.return_annotation }}{% endif %}

{% for (args, return_annotation) in obj.overloads %}
{{ obj.short_name }}({{ args }}){% if return_annotation is not none %} -> {{ return_annotation }}{% endif %}

{% endfor %}
{% for property in obj.properties %}
:{{ property }}:
{% endfor %}

{% if obj.docstring %}
{{ obj.docstring|indent(3) }}
{% endif %}
{% endif %}
19 changes: 19 additions & 0 deletions docs/api/source/_autoapi_templates/python/method.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{%- if obj.display %}
.. py:method:: {{ obj.short_name }}({{ obj.args }}){% if obj.return_annotation is not none %} -> {{ obj.return_annotation }}{% endif %}

{% for (args, return_annotation) in obj.overloads %}
{{ obj.short_name }}({{ args }}){% if return_annotation is not none %} -> {{ return_annotation }}{% endif %}

{% endfor %}
{% if obj.properties %}
{% for property in obj.properties %}
:{{ property }}:
{% endfor %}

{% else %}

{% endif %}
{% if obj.docstring %}
{{ obj.docstring|indent(3) }}
{% endif %}
{% endif %}
Loading