From 1ee8e3899b5b57ee5c1cd7b6fee6cdd2368ffad5 Mon Sep 17 00:00:00 2001 From: Gonzalo Vidal <35148159+Gonza10V@users.noreply.github.com> Date: Fri, 16 Jan 2026 23:01:13 -0700 Subject: [PATCH] Run opentrons simulate in temp dir --- src/buildcompiler/robotutils.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/buildcompiler/robotutils.py b/src/buildcompiler/robotutils.py index cab7543..5b91cf9 100644 --- a/src/buildcompiler/robotutils.py +++ b/src/buildcompiler/robotutils.py @@ -1,6 +1,5 @@ import sbol2 import json -import os import shutil import subprocess import tempfile @@ -131,11 +130,15 @@ def run_opentrons_script_with_json_to_zip( # Run inside temp dir so relative-path outputs land in tmpdir (and get zipped) - # Run script (which has opentrons script hardcoded) using JSON file - log = subprocess.run(["opentrons_simulate", opentrons_script_path, json_file_path], capture_output=True).stdout + # Run script (which has opentrons script hardcoded) using JSON file + log = subprocess.run( + ["opentrons_simulate", str(tmp_script), str(tmp_json)], + capture_output=True, + cwd=tmpdir, + ).stdout # Save log to a file in the temporary directory - with open(os.path.join(tmpdir, "build_log.txt"), "wb") as log_file: + with open(tmpdir / "build_log.txt", "wb") as log_file: log_file.write(log) # Always include logs in the zip