diff --git a/.dockerignore b/.dockerignore index d450ad0f..250db37d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -10,6 +10,7 @@ outputs/ # Git **/.git +!/.git **/.gitmodules **/.dockerignore .github/ diff --git a/dockerfile/cuda11.1.1.dockerfile b/dockerfile/cuda11.1.1.dockerfile index 5d3a037d..91ccfdbd 100644 --- a/dockerfile/cuda11.1.1.dockerfile +++ b/dockerfile/cuda11.1.1.dockerfile @@ -130,6 +130,7 @@ ADD third_party third_party RUN make -C third_party cuda ADD . . -RUN python3 -m pip install .[nvworker] && \ +RUN python3 -m pip install --no-cache-dir .[nvworker] && \ make cppbuild && \ - make postinstall + make postinstall && \ + rm -rf .git diff --git a/dockerfile/rocm5.0.x.dockerfile b/dockerfile/rocm5.0.x.dockerfile index 976b79a1..de791261 100644 --- a/dockerfile/rocm5.0.x.dockerfile +++ b/dockerfile/rocm5.0.x.dockerfile @@ -126,6 +126,8 @@ ADD third_party third_party RUN make -C third_party rocm ADD . . -RUN python3 -m pip install .[amdworker] && \ +RUN python3 -m pip install --upgrade setuptools && \ + python3 -m pip install --no-cache-dir .[amdworker] && \ make cppbuild && \ - make postinstall + make postinstall && \ + rm -rf .git diff --git a/dockerfile/rocm5.1.x.dockerfile b/dockerfile/rocm5.1.x.dockerfile index db6c89b7..8b19c367 100644 --- a/dockerfile/rocm5.1.x.dockerfile +++ b/dockerfile/rocm5.1.x.dockerfile @@ -141,6 +141,7 @@ ADD third_party third_party RUN make ROCBLAS_BRANCH=release/rocm-rel-5.1 -C third_party rocm ADD . . -RUN python3 -m pip install .[amdworker] && \ +RUN python3 -m pip install --no-cache-dir .[amdworker] && \ make cppbuild && \ - make postinstall + make postinstall && \ + rm -rf .git diff --git a/setup.py b/setup.py index ab7b4904..75142d1d 100644 --- a/setup.py +++ b/setup.py @@ -18,9 +18,9 @@ from setuptools import setup, find_packages, Command import superbench try: - pkg_resources.require(['pip>=18']) + pkg_resources.require(['pip>=18', 'setuptools>=45']) except (pkg_resources.VersionConflict, pkg_resources.DistributionNotFound): - print('Try upgrade pip to latest version, for example, python3 -m pip install --upgrade pip') + print('Try upgrade pip/setuptools to latest version, for example, python3 -m pip install --upgrade pip setuptools') raise here = pathlib.Path(__file__).parent.resolve() @@ -48,7 +48,7 @@ class Formatter(Command): def run(self): """Fromat the code using yapf.""" - errno = os.system('python3 -m yapf --in-place --recursive --exclude .git .') + errno = os.system('python3 -m yapf --in-place --recursive --exclude .git --exclude .eggs .') sys.exit(0 if errno == 0 else 1) @@ -76,7 +76,7 @@ class Linter(Command): errno = os.system( ' && '.join( [ - 'python3 -m yapf --diff --recursive --exclude .git .', + 'python3 -m yapf --diff --recursive --exclude .git --exclude .eggs .', 'python3 -m mypy .', 'python3 -m flake8', ] @@ -139,10 +139,19 @@ setup( keywords='benchmark, AI systems', packages=find_packages(exclude=['tests']), python_requires='>=3.6, <4', + use_scm_version={ + 'local_scheme': 'node-and-date', + 'version_scheme': lambda _: superbench.__version__, + 'fallback_version': f'{superbench.__version__}+unknown', + }, + setup_requires=[ + 'setuptools_scm', + ], install_requires=[ 'ansible_base>=2.10.9;os_name=="posix"', 'ansible_runner>=2.0.0rc1', 'colorlog>=6.7.0', + 'importlib_metadata', 'jinja2>=2.10.1', 'joblib>=1.0.1', 'jsonlines>=2.0.0', diff --git a/superbench/cli/_handler.py b/superbench/cli/_handler.py index 22ed82d6..03dba33b 100644 --- a/superbench/cli/_handler.py +++ b/superbench/cli/_handler.py @@ -4,6 +4,7 @@ """SuperBench CLI command handler.""" from pathlib import Path +from importlib_metadata import version, PackageNotFoundError from knack.util import CLIError from omegaconf import OmegaConf @@ -170,12 +171,15 @@ def process_runner_arguments( def version_command_handler(): - """Print the current SuperBench tool version. + """Print the current SuperBench tool version in "{last tag}+g{git hash}.d{date}" format. Returns: str: current SuperBench tool version. """ - return superbench.__version__ + try: + return version('superbench') + except PackageNotFoundError: + return superbench.__version__ def exec_command_handler(config_file=None, config_override=None, output_dir=None): diff --git a/tests/cli/test_sb.py b/tests/cli/test_sb.py index 267f2934..fb975e08 100644 --- a/tests/cli/test_sb.py +++ b/tests/cli/test_sb.py @@ -6,7 +6,7 @@ import io import contextlib from functools import wraps -from knack.testsdk import ScenarioTest, StringCheck, NoneCheck, JMESPathCheck +from knack.testsdk import ScenarioTest, StringContainCheck, NoneCheck, JMESPathCheck from pathlib import Path import superbench @@ -51,7 +51,7 @@ class SuperBenchCLIScenarioTest(ScenarioTest): def test_sb_version(self): """Test sb version.""" - self.cmd('sb version', checks=[StringCheck(superbench.__version__)]) + self.cmd('sb version', checks=[StringContainCheck(superbench.__version__)]) def test_sb_deploy(self): """Test sb deploy."""