Unverified Commit 57114294 authored by Yifan Xiong's avatar Yifan Xiong Committed by GitHub
Browse files

CLI - Integration with Executor and Runner (#26)

* CLI integration with Executor and Runner
parent 7f6deabb
...@@ -160,8 +160,6 @@ def run(self): ...@@ -160,8 +160,6 @@ def run(self):
entry_points={ entry_points={
'console_scripts': [ 'console_scripts': [
'sb = superbench.cli.sb:main', 'sb = superbench.cli.sb:main',
'sb-exec = superbench.cli.sb_exec:main',
'sb-run = superbench.cli.sb_run:main',
], ],
}, },
cmdclass={ cmdclass={
......
...@@ -3,13 +3,14 @@ ...@@ -3,13 +3,14 @@
"""SuperBench CLI command handler.""" """SuperBench CLI command handler."""
import os
from pathlib import Path from pathlib import Path
from knack.util import CLIError from knack.util import CLIError
from omegaconf import OmegaConf from omegaconf import OmegaConf
import superbench import superbench
from superbench.runner import SuperBenchRunner
from superbench.executor import SuperBenchExecutor
from superbench.common.utils import create_output_dir, get_sb_config from superbench.common.utils import create_output_dir, get_sb_config
...@@ -78,12 +79,12 @@ def deploy_command_handler( ...@@ -78,12 +79,12 @@ def deploy_command_handler(
def exec_command_handler( def exec_command_handler(
docker_image, docker_username=None, docker_password=None, config_file=None, config_override=None docker_image=None, docker_username=None, docker_password=None, config_file=None, config_override=None
): ):
"""Run the SuperBench benchmarks locally. """Run the SuperBench benchmarks locally.
Args: Args:
docker_image (str): Docker image URI. docker_image (str, optional): Docker image URI.
docker_username (str, optional): Docker registry username if authentication is needed. Defaults to None. docker_username (str, optional): Docker registry username if authentication is needed. Defaults to None.
docker_password (str, optional): Docker registry password if authentication is needed. Defaults to None. docker_password (str, optional): Docker registry password if authentication is needed. Defaults to None.
config_file (str, optional): Path to SuperBench config file. Defaults to None. config_file (str, optional): Path to SuperBench config file. Defaults to None.
...@@ -110,7 +111,8 @@ def exec_command_handler( ...@@ -110,7 +111,8 @@ def exec_command_handler(
# Create output directory # Create output directory
output_dir = create_output_dir() output_dir = create_output_dir()
os.system('sb-exec {}'.format(output_dir)) executor = SuperBenchExecutor(sb_config, docker_config, output_dir)
executor.exec()
def run_command_handler( def run_command_handler(
...@@ -170,4 +172,5 @@ def run_command_handler( ...@@ -170,4 +172,5 @@ def run_command_handler(
# Create output directory # Create output directory
output_dir = create_output_dir() output_dir = create_output_dir()
os.system('sb-run {}'.format(output_dir)) runner = SuperBenchRunner(sb_config, docker_config, ansible_config, output_dir)
runner.run()
#!/usr/bin/env python3
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""SuperBench sb exec command."""
def main():
"""The main entrypoint for sb-exec."""
# executor = SuperBenchExecutor(config)
# executor.exec()
if __name__ == '__main__':
main()
#!/usr/bin/env python3
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
"""SuperBench sb run command."""
def main():
"""The main entrypoint for sb-run."""
# runner = SuperBenchRunner(config)
# runner.run()
if __name__ == '__main__':
main()
...@@ -123,7 +123,7 @@ def exec(self): ...@@ -123,7 +123,7 @@ def exec(self):
context = BenchmarkRegistry.create_benchmark_context( context = BenchmarkRegistry.create_benchmark_context(
model, model,
platform=self.__get_platform(), platform=self.__get_platform(),
framework=Framework(framework.lower()).name, framework=Framework(framework.lower()),
parameters=self.__get_arguments(benchmark_config.parameters) parameters=self.__get_arguments(benchmark_config.parameters)
) )
self.__exec_benchmark(context, log_suffix) self.__exec_benchmark(context, log_suffix)
...@@ -133,7 +133,7 @@ def exec(self): ...@@ -133,7 +133,7 @@ def exec(self):
context = BenchmarkRegistry.create_benchmark_context( context = BenchmarkRegistry.create_benchmark_context(
benchmark_name, benchmark_name,
platform=self.__get_platform(), platform=self.__get_platform(),
framework=Framework(framework.lower()).name, framework=Framework(framework.lower()),
parameters=self.__get_arguments(benchmark_config.parameters) parameters=self.__get_arguments(benchmark_config.parameters)
) )
self.__exec_benchmark(context, log_suffix) self.__exec_benchmark(context, log_suffix)
...@@ -63,13 +63,7 @@ def test_sb_deploy_no_docker_image(self): ...@@ -63,13 +63,7 @@ def test_sb_deploy_no_docker_image(self):
def test_sb_exec(self): def test_sb_exec(self):
"""Test sb exec.""" """Test sb exec."""
self.cmd('sb exec --docker-image test:cuda11.1', checks=[NoneCheck()]) self.cmd('sb exec --config-override superbench.enable=["none"]', checks=[NoneCheck()])
@capture_system_exit
def test_sb_exec_no_docker_image(self):
"""Test sb exec, no --docker-image argument, should fail."""
self.cmd('sb exec', expect_failure=True)
self.assertIn('sb exec: error: the following arguments are required: --docker-image', self.stderr)
def test_sb_run(self): def test_sb_run(self):
"""Test sb run.""" """Test sb run."""
......
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