Skip to content

Commit

Permalink
replace deprecated utils.exec_getout calls
Browse files Browse the repository at this point in the history
  • Loading branch information
PhilippvK committed Jul 22, 2024
1 parent 8482fae commit f798540
Show file tree
Hide file tree
Showing 15 changed files with 25 additions and 25 deletions.
2 changes: 1 addition & 1 deletion mlonmcu/flow/tflm/backend/tflmc.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def generate(self) -> Tuple[dict, dict]:
args.append(str(self.model))
args.append(str(Path(tmpdirname) / f"{self.prefix}.cc"))
args.append(f"{self.prefix}_")
out = utils.exec_getout(tflmc_exe, *args, live=self.print_outputs)
out = utils.execute(tflmc_exe, *args, live=self.print_outputs)
files = [f for f in os.listdir(tmpdirname) if os.path.isfile(os.path.join(tmpdirname, f))]
# TODO: ensure that main file is processed first
for filename in files:
Expand Down
2 changes: 1 addition & 1 deletion mlonmcu/flow/tvm/backend/backend.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def invoke_tvmc(self, command, *args, cwd=None):
)
if self.use_tlcpack:
pre = ["tvmc"]
return utils.exec_getout(*pre, command, *args, live=self.print_outputs, env=env, cwd=cwd)
return utils.execute(*pre, command, *args, live=self.print_outputs, env=env, cwd=cwd)
else:
if self.tvmc_custom_script is None:
pre = ["-m", "tvm.driver.tvmc"]
Expand Down
2 changes: 1 addition & 1 deletion mlonmcu/flow/tvm/backend/tvmcg.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def generate(self) -> Tuple[dict, dict]:
args.append(params_bin_file)
args.append(out_file)
args.append(str(max_workspace_size))
out = utils.exec_getout(tvmcg_exe, *args, live=self.print_outputs)
out = utils.execute(tvmcg_exe, *args, live=self.print_outputs)
codegen_src = open(out_file, "r").read()
artifact = Artifact("staticrt.c", content=codegen_src, fmt=ArtifactFormat.SOURCE)
workspace_size_artifact = Artifact(
Expand Down
6 changes: 3 additions & 3 deletions mlonmcu/models/frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ def generate(self, model) -> Tuple[dict, dict]:

def get_num_layers(file):
tflite_pack_args = [path, "--count-layers", "--noop"]
out = utils.exec_getout(self.pack_script, *tflite_pack_args)
out = utils.execute(self.pack_script, *tflite_pack_args)
matches = re.compile(r"Found\s(\d+)\slayers.").findall(out)
assert len(matches) == 1
num = int(matches[0])
Expand All @@ -476,7 +476,7 @@ def gen_layer_files(file, dest):
out_name = f"layer{i}"
out_file = Path(dest) / out_name
tflite_pack_args = [path, "-k", str(i), "--out", out_file]
utils.exec_getout(self.pack_script, *tflite_pack_args)
utils.execute(self.pack_script, *tflite_pack_args)
assert out_file.is_file()
results.append(out_file)
return results
Expand Down Expand Up @@ -702,7 +702,7 @@ def produce_artifacts(self, model):
with open(in_file, "wb") as handle:
handle.write(tflite_data)
out_file = Path(tmpdirname) / "out.tflm"
utils.exec_getout(packer_exe, in_file, out_file)
utils.execute(packer_exe, in_file, out_file)
with open(out_file, "rb") as handle:
packed_data = handle.read()

Expand Down
2 changes: 1 addition & 1 deletion mlonmcu/platform/espidf/espidf.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def invoke_idf_exe(self, *args, **kwargs):
# + f" > /dev/null && {self.idf_exe} "
+ " ".join([str(arg) for arg in args])
)
out = utils.exec_getout(
out = utils.execute(
cmd, shell=True, env=env, **kwargs, executable="/bin/bash"
) # TODO: using shell=True is insecure but right now we can not avoid it?
return out
Expand Down
2 changes: 1 addition & 1 deletion mlonmcu/platform/zephyr/zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def invoke_west(self, *args, **kwargs):
env["ZEPHYR_BASE"] = str(self.zephyr_install_dir / "zephyr")
env["ZEPHYR_SDK_INSTALL_DIR"] = str(self.zephyr_sdk_dir)
cmd = ". " + str(self.zephyr_venv_dir / "bin" / "activate") + " && west " + " ".join([str(arg) for arg in args])
out = utils.exec_getout(
out = utils.execute(
cmd, shell=True, env=env, **kwargs, executable="/bin/bash"
) # TODO: using shell=True is insecure but right now we can not avoid it?
return out
Expand Down
4 changes: 2 additions & 2 deletions mlonmcu/setup/tasks/ara.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ def clone_ara(context: MlonMcuContext, params=None, rebuild=False, verbose=False
if rebuild or not utils.is_populated(araSrcDir):
araRepo = context.environment.repos["ara"]
utils.clone_wrapper(araRepo, araSrcDir, refresh=rebuild)
utils.exec_getout("make", "apply-patches", cwd=araSrcDir / "hardware")
utils.exec_getout("make", "bender", cwd=araSrcDir / "hardware")
utils.execute("make", "apply-patches", cwd=araSrcDir / "hardware")
utils.execute("make", "bender", cwd=araSrcDir / "hardware")
context.cache["ara.src_dir", flags] = araSrcDir
2 changes: 1 addition & 1 deletion mlonmcu/setup/tasks/corstone300.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def install_corstone300(
fvpArchive = fvpFileName + ".tgz"
utils.download_and_extract(fvpUrl, fvpArchive, fvpInstallDir, progress=verbose)
fvpScript = fvpInstallDir / "FVP_Corstone_SSE-300.sh"
utils.exec_getout(
utils.execute(
fvpScript,
"--i-agree-to-the-contained-eula",
"--no-interactive",
Expand Down
2 changes: 1 addition & 1 deletion mlonmcu/setup/tasks/pulp.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def install_pulp_gcc(
pulpGccArgs.append("--with-arch=rv32imc")
pulpGccArgs.append("--with-cmodel=medlow")
pulpGccArgs.append("--enable-multilib")
utils.exec_getout(
utils.execute(
str(pulpGccSrcDir / "configure"),
*pulpGccArgs,
cwd=pulpGccBuildDir,
Expand Down
2 changes: 1 addition & 1 deletion mlonmcu/setup/tasks/riscv_gcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

def check_multilibs(riscvInstallDir, gccName, live=False, vext=False, pext=False):
gccExe = Path(riscvInstallDir) / "bin" / f"{gccName}-gcc"
out = utils.exec_getout(gccExe, "--print-multi-lib", live=live)
out = utils.execute(gccExe, "--print-multi-lib", live=live)
multilibs = []
if vext and pext:
default_multilib = "rv32gcpv/ilp32d" if "32" in gccName else "rv64gcpv/lp64d" # TODO: improve this
Expand Down
4 changes: 2 additions & 2 deletions mlonmcu/setup/tasks/spike.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def build_spike_pk(
spikepkArgs.append("--host=" + gccName)
env = os.environ.copy()
env["PATH"] = str(Path(riscv_gcc) / "bin") + ":" + env["PATH"]
utils.exec_getout(
utils.execute(
str(spikepkSrcDir / "configure"),
*spikepkArgs,
cwd=spikepkBuildDir,
Expand Down Expand Up @@ -199,7 +199,7 @@ def build_spike(
# spikeArgs.append("--prefix=" + str(context.cache["riscv_gcc.install_dir"]))
spikeArgs.append("--prefix=" + str(spikeInstallDir))
spikeArgs.append("--enable-misaligned")
utils.exec_getout(
utils.execute(
str(Path(spikeSrcDir) / "configure"),
*spikeArgs,
cwd=spikeBuildDir,
Expand Down
2 changes: 1 addition & 1 deletion mlonmcu/setup/tasks/tf.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,5 +133,5 @@ def install_tflite_pack(
installDir = context.environment.paths["deps"].path / "install" / name
if rebuild or not utils.is_populated(installDir):
installScript = srcDir / "install.sh"
utils.exec_getout(installScript, installDir, live=verbose)
utils.execute(installScript, installDir, live=verbose)
context.cache["tflite_pack.exe"] = installDir / "run.sh"
6 changes: 3 additions & 3 deletions mlonmcu/setup/tasks/verilator.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,14 @@ def build_verilator(
if rebuild or not utils.is_populated(verilatorBuildDir):
env = os.environ.copy()
env["VERILATOR_ROOT"] = ""
utils.exec_getout(
utils.execute(
"autoconf",
env=env,
cwd=verilatorSrcDir,
live=verbose,
)
env = os.environ.copy()
utils.exec_getout(
utils.execute(
str(verilatorSrcDir / "configure"),
f"--prefix={verilatorInstallDir}",
env=env,
Expand Down Expand Up @@ -136,7 +136,7 @@ def install_verilator(
else:
if rebuild or not utils.is_populated(verilatorInstallDir):
env = os.environ.copy()
utils.exec_getout(
utils.execute(
"make",
"install",
env=env,
Expand Down
2 changes: 1 addition & 1 deletion mlonmcu/setup/tasks/vicuna.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def clone_vicuna(
# utils.mkdirs(vicunaBuildDir)
# vicunaArgs = []
# vicunaArgs.append("--prefix=" + str(vicunaInstallDir))
# utils.exec_getout(
# utils.execute(
# str(vicunaSrcDir / "configure"),
# *vicunaArgs,
# cwd=vicunaBuildDir,
Expand Down
10 changes: 5 additions & 5 deletions mlonmcu/setup/tasks/zephyr.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,21 @@ def install_zephyr(
zephyrVenvScript = zephyrVenvDir / "bin" / "activate"
if not utils.is_populated(zephyrVenvDir):
venv.create(zephyrVenvDir)
utils.exec_getout(f". {zephyrVenvScript} && pip install west", shell=True, live=verbose)
utils.execute(f". {zephyrVenvScript} && pip install west", shell=True, live=verbose)
zephyrRepo = context.environment.repos["zephyr"]
zephyrUrl = zephyrRepo.url
if not utils.is_populated(zephyrInstallDir / "zephyr"):
zephyrVersion = zephyrRepo.ref
utils.exec_getout(
utils.execute(
f". {zephyrVenvScript} && west init -m {zephyrUrl} --mr {zephyrVersion} {zephyrInstallDir}",
shell=True,
live=verbose,
)
extra = zephyrInstallDir / "zephyr" / "scripts" / "requirements.txt"
utils.exec_getout(f". {zephyrVenvScript} && pip install -r {extra}", shell=True, live=verbose)
utils.execute(f". {zephyrVenvScript} && pip install -r {extra}", shell=True, live=verbose)
env = os.environ.copy()
env["ZEPHYR_BASE"] = str(zephyrInstallDir / "zephyr")
utils.exec_getout(f". {zephyrVenvScript} && west update", shell=True, live=verbose, env=env)
utils.execute(f". {zephyrVenvScript} && west update", shell=True, live=verbose, env=env)
if "zephyr.sdk_version" in user_vars:
sdkVersion = user_vars["zephyr.sdk_version"]
else:
Expand All @@ -101,7 +101,7 @@ def install_zephyr(
utils.download_and_extract(sdkUrl, sdkArchive, zephyrSdkDir, progress=verbose)
sdkScript = zephyrSdkDir / "setup.sh"
# TODO: allow to limit installed toolchains
utils.exec_getout(sdkScript, "-t", "all", "-h", live=verbose)
utils.execute(sdkScript, "-t", "all", "-h", live=verbose)
# Apply patch to fix esp32c3 support
patchFile = Path(
pkg_resources.resource_filename(
Expand Down

0 comments on commit f798540

Please sign in to comment.