diff options
Diffstat (limited to 'scripts/python_version.py')
-rw-r--r-- | scripts/python_version.py | 37 |
1 files changed, 13 insertions, 24 deletions
diff --git a/scripts/python_version.py b/scripts/python_version.py index 6c8f25c..0a6b518 100644 --- a/scripts/python_version.py +++ b/scripts/python_version.py @@ -23,32 +23,21 @@ class Version: is_main: bool -_ALL_VERSIONS = None -_MAIN_VERSION = None - - -def get_all_versions() -> tuple[list[Version], Version]: - """ - Get a list of all available versions for this evaluation. - - Returns a tuple of all versions, and the main version. - """ - # Return a cached result - global _ALL_VERSIONS, _MAIN_VERSION - if _ALL_VERSIONS is not None: - return _ALL_VERSIONS, _MAIN_VERSION - - versions = [] - main_version: Version | None = None - +ALL_VERSIONS: list[Version] = [] +"""A list of all versions available for eval.""" +MAIN_VERSION: Version = None +"""The default eval version, and the version used by the server.""" +VERSION_DISPLAY_NAMES: list[str] = [] +"""The display names for all available eval versions.""" + +if MAIN_VERSION is None: + # Set the constants' values the first time the file is imported for version_json in json.loads(VERSIONS_FILE.read_text("utf-8")): version = Version(**version_json) if version.is_main: - main_version = version - versions.append(version) + MAIN_VERSION = version + ALL_VERSIONS.append(version) + VERSION_DISPLAY_NAMES.append(version.display_name) - if main_version is None: + if MAIN_VERSION is None: raise Exception("Exactly one version must be configured as the main version.") - - _ALL_VERSIONS, _MAIN_VERSION = versions, main_version - return versions, main_version |