changelog
¶
Fetches and parses mujoco-mojo's CHANGELOG.md into structured version entries, for Dojo's "What's Changed" footer button and for scripts/verify_changelog_by_tag.py's pre-push check - one parser, so the two can't drift apart.
The changelog is read live from GitHub. fetch_and_parse_changelog raises when that fails, and load_changelog is the caller that never leaves Dojo empty-handed: it falls back to the last copy it fetched successfully (saved under ~/.mujoco-mojo), then to the changelog that ships inside the package, and says which one it used.
LAST_SEEN_VERSION_FILE
module-attribute
¶
LAST_SEEN_VERSION_FILE = (
MUJOCO_MOJO_DIR / "last_seen_changelog_version.txt"
)
The latest changelog version the user has explicitly acknowledged (by closing the What's Changed modal on it). Read fresh on every GET /changelog/data request, not cached in memory, so a mark-seen write takes effect immediately - both for a later page load in the same Dojo process and across a full restart of it.
CHANGELOG_CACHE_FILE
module-attribute
¶
CHANGELOG_CACHE_FILE = (
MUJOCO_MOJO_DIR / "changelog_cache.md"
)
The last changelog fetched successfully from GitHub, kept as the raw text so a later parser change still reads it. load_changelog falls back to it, marked as possibly out of date, when GitHub can't be reached.
BUNDLED_CHANGELOG_FILE
module-attribute
¶
BUNDLED_CHANGELOG_FILE = (
DOCS_SOURCE_DIR / "docs" / "changelog.md"
)
The changelog that ships inside the package, as of the installed version. The last resort for a host that has never reached GitHub, so it can't know about any newer release.
ChangelogSource
module-attribute
¶
ChangelogSource = Literal['remote', 'cache', 'bundled']
Where load_changelog's entries came from: GitHub just now, the copy saved from an earlier fetch, or the changelog that ships with the installed package.
-
Reference
mujoco_mojoutilslayersdojorouterschangelogChangelogResponsesource
ChangelogEntry
¶
Bases: BaseModel
One ## Version X.Y.Z (YYYY-MM-DD) section of the changelog.
-
Reference
mujoco_mojoutilslayersdojorouterschangelogChangelogEntryOut
ChangelogUnavailable
¶
Bases: RuntimeError
Raised by fetch_and_parse_changelog, without a network request, while a recent failure is still being waited out. The message is that failure's own.
version_tuple
¶
The leading X.Y.Z as an int triple, for > comparison. A dev-build suffix (e.g. 2.6.11.dev3+g1234abc) is ignored past the prefix; a string with no such prefix degrades to (0, 0, 0) rather than raising, since this never needs to be exact, only ordered.
Source code in src/mujoco_mojo/utils/changelog.py
parse_changelog
¶
parse_changelog(text: str) -> list[ChangelogEntry]
Splits text into one ChangelogEntry per ## Version X.Y.Z (date) heading, newest first (the file's own order). A malformed date (this repo's own CHANGELOG.md has one, a typo'd 5-digit year) does not fail the entry - it becomes date=None, with the version and bullets unaffected.
Source code in src/mujoco_mojo/utils/changelog.py
fetch_and_parse_changelog
¶
fetch_and_parse_changelog(
*, force_refresh: bool = False
) -> list[ChangelogEntry]
Fetches CHANGELOG_URL and parses it, reusing a successful result for _CACHE_TTL_SECONDS.
Synchronous by design, so it and everything it calls stay plain-function testable with no async test infra (this repo has none); call it from an async endpoint via starlette.concurrency.run_in_threadpool.
Raises on any failure - a network error, a timeout, a non-200 response, or a 200 that parses to zero entries (a captive-portal page would otherwise look like an empty changelog instead of a failure). After a failure the next calls raise ChangelogUnavailable for _RETRY_AFTER_SECONDS without touching the network, unless force_refresh is set. A success also saves the text to CHANGELOG_CACHE_FILE for load_changelog's fallback.
Source code in src/mujoco_mojo/utils/changelog.py
load_changelog
¶
The changelog from the best place available, newest entry first: GitHub (fetch_and_parse_changelog), else the copy saved by the last successful fetch, else the changelog that ships in the package. source says which, so a caller can tell the user a copy may be out of date. Returns None only if none of the three has an entry.
A network failure is one warning line, not a traceback, and a failure still being waited out is not logged again. Any other failure (a bad status, a page with no versions) keeps its traceback.
Source code in src/mujoco_mojo/utils/changelog.py
read_last_seen_version
¶
read_last_seen_version() -> str | None
The version last written by write_last_seen_version, or None if the user has never acknowledged one (a first-ever launch of this feature, or a fresh ~/.mujoco-mojo).
Source code in src/mujoco_mojo/utils/changelog.py
write_last_seen_version
¶
write_last_seen_version(version: str) -> None
Persists version as acknowledged, so it (and everything older) stops being flagged is_new and stops triggering the modal's auto-open, on this and every future launch, until a genuinely newer version appears.