MCPcopy Create free account
hub / github.com/microsoft/BitNet / run_command

Function run_command

utils/e2e_benchmark.py:8–23  ·  view source on GitHub ↗

Run a system command and ensure it succeeds.

(command, shell=False, log_step=None)

Source from the content-addressed store, hash-verified

6import subprocess
7
8def run_command(command, shell=False, log_step=None):
9 """Run a system command and ensure it succeeds."""
10 if log_step:
11 log_file = os.path.join(args.log_dir, log_step + ".log")
12 with open(log_file, "w") as f:
13 try:
14 subprocess.run(command, shell=shell, check=True, stdout=f, stderr=f)
15 except subprocess.CalledProcessError as e:
16 logging.error(f"Error occurred while running command: {e}, check details in {log_file}")
17 sys.exit(1)
18 else:
19 try:
20 subprocess.run(command, shell=shell, check=True)
21 except subprocess.CalledProcessError as e:
22 logging.error(f"Error occurred while running command: {e}")
23 sys.exit(1)
24
25def run_benchmark():
26 build_dir = os.path.join(os.path.dirname(os.path.dirname(os.path.abspath(__file__))), "build")

Callers 1

run_benchmarkFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected