From 1fac85d1cd3b0104641a8ddce6f1b5e41c9bc8ea Mon Sep 17 00:00:00 2001 From: Vasily Shamporov Date: Tue, 11 Apr 2023 17:35:46 +0200 Subject: [PATCH] Add GH workflows for doc builds and API checks --- .github/{ => action_configs}/labeler.yml | 0 .github/workflows/api_changes_check.yml | 38 +++++++++++++++++++ .github/workflows/build_and_publish_doc.yml | 41 +++++++++++++++++++++ .github/workflows/build_html_doc.yml | 21 +++++++++++ .github/workflows/build_schema_page.yml | 25 ++++++------- .github/workflows/labeler.yml | 4 +- .github/workflows/python-publish.yml | 2 +- docs/api/source/index.rst | 4 +- nncf/onnx/engine.py | 2 - nncf/openvino/engine.py | 2 - 10 files changed, 116 insertions(+), 23 deletions(-) rename .github/{ => action_configs}/labeler.yml (100%) create mode 100644 .github/workflows/api_changes_check.yml create mode 100644 .github/workflows/build_and_publish_doc.yml create mode 100644 .github/workflows/build_html_doc.yml diff --git a/.github/labeler.yml b/.github/action_configs/labeler.yml similarity index 100% rename from .github/labeler.yml rename to .github/action_configs/labeler.yml diff --git a/.github/workflows/api_changes_check.yml b/.github/workflows/api_changes_check.yml new file mode 100644 index 00000000000..49d0b360fa8 --- /dev/null +++ b/.github/workflows/api_changes_check.yml @@ -0,0 +1,38 @@ +name: API changes check +on: + pull_request_target: + 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 + find . -name "*.html" -exec diff -qrBZ {} $GITHUB_WORKSPACE/previous_doc_state/$API_DOC_HTML_ROOT_RELATIVE_PATH/{} \; + - uses: actions-ecosystem/action-add-labels@v1 + if: ${{ steps.diff.outputs }} != "" + with: + labels: API diff --git a/.github/workflows/build_and_publish_doc.yml b/.github/workflows/build_and_publish_doc.yml new file mode 100644 index 00000000000..7500a1b604c --- /dev/null +++ b/.github/workflows/build_and_publish_doc.yml @@ -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 }} diff --git a/.github/workflows/build_html_doc.yml b/.github/workflows/build_html_doc.yml new file mode 100644 index 00000000000..d07119ec631 --- /dev/null +++ b/.github/workflows/build_html_doc.yml @@ -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 diff --git a/.github/workflows/build_schema_page.yml b/.github/workflows/build_schema_page.yml index 395a6ea98c9..b1368792941 100644 --- a/.github/workflows/build_schema_page.yml +++ b/.github/workflows/build_schema_page.yml @@ -1,31 +1,28 @@ name: Config schema HTML build on: - push: + pull_request_target: 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 diff --git a/.github/workflows/labeler.yml b/.github/workflows/labeler.yml index 1b64d7304d2..c3eb8808fbd 100644 --- a/.github/workflows/labeler.yml +++ b/.github/workflows/labeler.yml @@ -2,7 +2,7 @@ name: "Pull Request Labeler" on: [pull_request_target] jobs: - triage: + set-label: permissions: contents: read pull-requests: write @@ -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 diff --git a/.github/workflows/python-publish.yml b/.github/workflows/python-publish.yml index b9882c135c1..94053830522 100644 --- a/.github/workflows/python-publish.yml +++ b/.github/workflows/python-publish.yml @@ -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: diff --git a/docs/api/source/index.rst b/docs/api/source/index.rst index 37951ac42d5..4d5159f8282 100644 --- a/docs/api/source/index.rst +++ b/docs/api/source/index.rst @@ -1,4 +1,4 @@ -NNCF doc testing! +NNCF documentation ================================ .. toctree:: @@ -6,5 +6,5 @@ NNCF doc testing! :maxdepth: 3 API Reference - JSON configuration file schema<./schema.html#http://> + JSON configuration file schema<./schema#http://> diff --git a/nncf/onnx/engine.py b/nncf/onnx/engine.py index 02549f043f6..9e76d8bc3fa 100644 --- a/nncf/onnx/engine.py +++ b/nncf/onnx/engine.py @@ -16,10 +16,8 @@ import numpy as np import onnxruntime as rt -from nncf.common.api_marker import api from nncf.common.engine import Engine -@api() class ONNXEngine(Engine): """ Engine for ONNX backend using ONNXRuntime to infer the model. diff --git a/nncf/openvino/engine.py b/nncf/openvino/engine.py index 3e03ec8b78e..ec94a18c123 100644 --- a/nncf/openvino/engine.py +++ b/nncf/openvino/engine.py @@ -22,7 +22,6 @@ import openvino.runtime as ov from nncf.api.compression import TModel -from nncf.common.api_marker import api from nncf.data import Dataset from nncf.data.dataset import DataProvider @@ -117,7 +116,6 @@ def calc_per_sample_metrics(compiled_model: ov.CompiledModel, # TODO(andrey-churkin): This class should be refactored. We will be able to do that when # we will have POT code in NNCF. -@api() class OVEngine(pot.IEEngine): """ Implementation of the engine for OpenVINO backend.