diff --git a/changes/11787.doc.md b/changes/11787.doc.md new file mode 100644 index 00000000000..b29644e3cac --- /dev/null +++ b/changes/11787.doc.md @@ -0,0 +1 @@ +Update the advertised API version in the docs to `v9.20250722` and source it from `ai.backend.client.config.API_VERSION` via a Sphinx substitution so it stays in sync automatically. diff --git a/docs/conf.py b/docs/conf.py index eae7e05fc39..2b8701e23d9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -13,6 +13,7 @@ # All configuration values have a default; values that are commented out # serve to show the default. +import ast import os import sys from pathlib import Path @@ -74,6 +75,33 @@ # The short X.Y version. version = ".".join(release.split(".")[:2]) +# Expose the current Backend.AI client API version as the |api_version| +# substitution so docs do not hard-code the string. Source of truth: +# `src/ai/backend/client/config.py` (`API_VERSION`). We parse the literal +# out of the file directly instead of importing the package, so the docs +# build does not need aiohttp / the full client runtime installed. +def _read_api_version() -> str: + config_path = root_path / "src/ai/backend/client/config.py" + source = config_path.read_text(encoding="utf-8") + for node in ast.parse(source, filename=str(config_path)).body: + if ( + isinstance(node, ast.Assign) + and len(node.targets) == 1 + and isinstance(node.targets[0], ast.Name) + and node.targets[0].id == "API_VERSION" + and isinstance(node.value, ast.Tuple) + and len(node.value.elts) == 2 + ): + major, rev = (ast.literal_eval(e) for e in node.value.elts) + return f"v{major}.{rev}" + raise RuntimeError("API_VERSION not found in src/ai/backend/client/config.py") + + +api_version = _read_api_version() +rst_prolog = f""" +.. |api_version| replace:: {api_version} +""" + # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. # diff --git a/docs/index.rst b/docs/index.rst index 82b3ad2d4b6..0a1c7eecd3a 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -1,7 +1,7 @@ Backend.AI Documentation ======================== -**Latest API version: v6.20220615** +**Latest API version:** |api_version| Backend.AI is an enterprise-grade development and service backend for a wide range of AI-powered applications. Its core technology is tailored for operating high density computing clusters including GPUs and heterogeneous accelerators. diff --git a/docs/install/install-from-package/install-manager.rst b/docs/install/install-from-package/install-manager.rst index 29ae833b8c7..f2e107cf60f 100644 --- a/docs/install/install-from-package/install-manager.rst +++ b/docs/install/install-from-package/install-manager.rst @@ -260,7 +260,7 @@ can be configured from ``manager.toml``: .. code-block:: console $ curl bai-m1:8081 - {"version": "v6.20220615", "manager": "22.09.6"} + {"version": "v9.20250722", "manager": "26.4.8"} Press ``Ctrl-C`` to stop the service. diff --git a/docs/locales/ko/LC_MESSAGES/index.po b/docs/locales/ko/LC_MESSAGES/index.po index c148c7f09e7..8a50be60ef2 100644 --- a/docs/locales/ko/LC_MESSAGES/index.po +++ b/docs/locales/ko/LC_MESSAGES/index.po @@ -24,9 +24,8 @@ msgid "Backend.AI Documentation" msgstr "Backend.AI 레퍼런스 문서" #: ../../index.rst:4 46ce303188ef4054a0d1690f4f5adb03 -#, fuzzy -msgid "**Latest API version: v6.20220615**" -msgstr "**최근 API 버전: v5.20191215**" +msgid "**Latest API version:** |api_version|" +msgstr "**최근 API 버전:** |api_version|" #: ../../index.rst:6 b8e94703b6e741c2bb5b33d76b5949ba msgid "" diff --git a/src/ai/backend/client/config.py b/src/ai/backend/client/config.py index 78e9485c1a4..dfb3c74cd97 100644 --- a/src/ai/backend/client/config.py +++ b/src/ai/backend/client/config.py @@ -28,6 +28,10 @@ class Undefined(enum.Enum): _config = None _undefined = Undefined.token +# NOTE: `docs/conf.py` parses this `API_VERSION` literal with `ast` to expose +# the `|api_version|` Sphinx substitution. Keep this as a plain `Assign` of a +# 2-tuple `(int, str)` — changing the form (annotated assignment, different +# arity, etc.) requires updating `docs/conf.py:_read_api_version()`. API_VERSION = (9, "20250722") MIN_API_VERSION = (7, "20230615")