Unverified Commit f175abc3 authored by Taylor Robie's avatar Taylor Robie Committed by GitHub
Browse files

Move version check to a function (#5601)

* move version check to a function

* delint

* tweak pip check

* delint
parent d7676c1c
...@@ -86,19 +86,22 @@ def unparse_line(parsed_line): # type: (ParsedLine) -> str ...@@ -86,19 +86,22 @@ def unparse_line(parsed_line): # type: (ParsedLine) -> str
def get_mlperf_log(): def get_mlperf_log():
"""Shielded import of mlperf_log module.""" """Shielded import of mlperf_log module."""
try: try:
import pkg_resources
import mlperf_compliance import mlperf_compliance
version = pkg_resources.get_distribution("mlperf_compliance") def test_mlperf_log_pip_version():
version = tuple(int(i) for i in version.version.split(".")) """Check that mlperf_compliance is up to date."""
if version < _MIN_VERSION: import pkg_resources
tf.logging.warning( version = pkg_resources.get_distribution("mlperf_compliance")
"mlperf_compliance is version {}, must be at least version {}".format( version = tuple(int(i) for i in version.version.split("."))
".".join([str(i) for i in version]), if version < _MIN_VERSION:
".".join([str(i) for i in _MIN_VERSION]))) tf.logging.warning(
raise ImportError "mlperf_compliance is version {}, must be >= {}".format(
".".join([str(i) for i in version]),
mlperf_log = mlperf_compliance.mlperf_log ".".join([str(i) for i in _MIN_VERSION])))
raise ImportError
return mlperf_compliance.mlperf_log
mlperf_log = test_mlperf_log_pip_version()
except ImportError: except ImportError:
mlperf_log = None mlperf_log = None
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment