From 834f876cf68005c4be261cdb660ecf0c65f3a4f7 Mon Sep 17 00:00:00 2001 From: Philip Meier Date: Thu, 18 May 2023 12:09:37 +0200 Subject: [PATCH 1/4] fix version wrangling in docs --- docs/source/conf.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 6d748f5b717..c1226a96c9f 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -92,17 +92,16 @@ # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the # built documents. -# -# The short X.Y version. -version = "main (" + torchvision.__version__ + " )" -# The full version, including alpha/beta/rc tags. -release = "main" +# version: The short X.Y version. +# release: The full version, including alpha/beta/rc tags. VERSION = os.environ.get("VERSION", None) if VERSION: # Turn 1.11.0aHASH into 1.11 (major.minor only) - version = ".".join(version.split(".")[:2]) + version = release = ".".join(torchvision.__version__.split(".")[:2]) html_title = " ".join((project, version, "documentation")) - release = version +else: + version = f"main ({torchvision.__version__})" + release = "main" # The language for content autogenerated by Sphinx. Refer to documentation From 6c44279f6717f5a1f16f8915f14561ff1bbd903a Mon Sep 17 00:00:00 2001 From: Philip Meier Date: Thu, 18 May 2023 12:25:51 +0200 Subject: [PATCH 2/4] fix doc workflow --- .github/workflows/docs.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index d5aec182a70..1bb87fe59d7 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -43,6 +43,14 @@ jobs: pip install --progress-bar=off -r requirements.txt echo '::endgroup::' + if [[ ${{ github.ref_type }} == tag || (${{ github.ref_type }} == branch && ${{ github.ref_name }} == release/*) ]]; then + echo '::group::Enable version wrangling' + # This environment variable just has to exist and must not be empty. The actual value is arbitrary. + # See docs/source/conf.py for details + export VERSION=1 + echo '::endgroup::' + fi + # The runner does not have sufficient memory to run with as many processes as there are # cores (`-j auto`). Thus, we limit to a single process (`-j 1`) here. sed -i -e 's/-j auto/-j 1/' Makefile From 1546a559767af4aac8dfef7daa70c019853acc6d Mon Sep 17 00:00:00 2001 From: Philip Meier Date: Thu, 18 May 2023 15:26:28 +0200 Subject: [PATCH 3/4] make env var name more expressive --- .github/workflows/docs.yml | 4 ++-- docs/source/conf.py | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 1bb87fe59d7..510ba6607fa 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -44,10 +44,10 @@ jobs: echo '::endgroup::' if [[ ${{ github.ref_type }} == tag || (${{ github.ref_type }} == branch && ${{ github.ref_name }} == release/*) ]]; then - echo '::group::Enable version wrangling' + echo '::group::Enable version string sanitization' # This environment variable just has to exist and must not be empty. The actual value is arbitrary. # See docs/source/conf.py for details - export VERSION=1 + export TORCHVISION_SANITIZE_VERSION_STR_IN_DOCS=1 echo '::endgroup::' fi diff --git a/docs/source/conf.py b/docs/source/conf.py index c1226a96c9f..4bb75fe6eeb 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -94,8 +94,7 @@ # built documents. # version: The short X.Y version. # release: The full version, including alpha/beta/rc tags. -VERSION = os.environ.get("VERSION", None) -if VERSION: +if os.environ.get("TORCHVISION_SANITIZE_VERSION_STR_IN_DOCS", None): # Turn 1.11.0aHASH into 1.11 (major.minor only) version = release = ".".join(torchvision.__version__.split(".")[:2]) html_title = " ".join((project, version, "documentation")) From 22d52f80c8b22d5511410bd4ec5861f387a5e87f Mon Sep 17 00:00:00 2001 From: Philip Meier Date: Thu, 18 May 2023 15:48:58 +0200 Subject: [PATCH 4/4] fix condition --- .github/workflows/docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 510ba6607fa..f4cc76db05e 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -43,7 +43,7 @@ jobs: pip install --progress-bar=off -r requirements.txt echo '::endgroup::' - if [[ ${{ github.ref_type }} == tag || (${{ github.ref_type }} == branch && ${{ github.ref_name }} == release/*) ]]; then + if [[ ${{ github.event_name }} == push && (${{ github.ref_type }} == tag || (${{ github.ref_type }} == branch && ${{ github.ref_name }} == release/*)) ]]; then echo '::group::Enable version string sanitization' # This environment variable just has to exist and must not be empty. The actual value is arbitrary. # See docs/source/conf.py for details