This repository has been archived on 2023-02-07. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-my-data/mydata_benchmarks/versions.py
Sybren A. Stüvel 46f6351797 Do version checking of the Benchmark Client
- The result JSON now includes the benchmark client version, and as a
  result the schema version has been bumped to 1. This version is not
  checked yet on the server, so it's at the moment purely cosmetic.
- Latest version of the Benchmark Client is configured in
  LATEST_CLIENT_VERSIONS['BENCHMARK']. This allows us to have different
  clients with different latest versions.
- An empty string as 'latest version' disables the version check altogether.
  This allows us to push to the production servers before we release the
  client version that actually includes the version information.
2018-08-16 12:30:29 +02:00

34 lines
1.0 KiB
Python

"""Checks for version information in the samples.
Requires the latest versions of clients to be configured in the
settings['LATEST_CLIENT_VERSIONS'] dict.
"""
import functools
import logging
import typing
from django.conf import settings
import packaging.version
log = logging.getLogger(__name__)
@functools.lru_cache(maxsize=1)
def latest_benchmark_client() -> packaging.version.Version:
"""Parse Benchmark Client version from Django settings"""
latest: str = settings.LATEST_CLIENT_VERSIONS['BENCHMARK']
parsed = packaging.version.parse(latest)
if isinstance(parsed, packaging.version.LegacyVersion):
log.error("Malformed LATEST_CLIENT_VERSIONS['BENCHMARK'] setting: %r", latest)
else:
log.info('Configured latest version of the Benchmark Client is %s', parsed)
return parsed
def is_benchmark_client_outdated(client_version: typing.Optional[str]) -> bool:
if not client_version:
return True
parsed_ver = packaging.version.parse(client_version)
return parsed_ver < latest_benchmark_client()