Run a system command and ensure it succeeds.
(command, shell=False, log_step=None)
| 90 | return os.path.basename(os.path.normpath(args.model_dir)) |
| 91 | |
| 92 | def run_command(command, shell=False, log_step=None): |
| 93 | """Run a system command and ensure it succeeds.""" |
| 94 | if log_step: |
| 95 | log_file = os.path.join(args.log_dir, log_step + ".log") |
| 96 | with open(log_file, "w") as f: |
| 97 | try: |
| 98 | subprocess.run(command, shell=shell, check=True, stdout=f, stderr=f) |
| 99 | except subprocess.CalledProcessError as e: |
| 100 | logging.error(f"Error occurred while running command: {e}, check details in {log_file}") |
| 101 | sys.exit(1) |
| 102 | else: |
| 103 | try: |
| 104 | subprocess.run(command, shell=shell, check=True) |
| 105 | except subprocess.CalledProcessError as e: |
| 106 | logging.error(f"Error occurred while running command: {e}") |
| 107 | sys.exit(1) |
| 108 | |
| 109 | def prepare_model(): |
| 110 | _, arch = system_info() |
no outgoing calls
no test coverage detected