Spaces:
Sleeping
Sleeping
File size: 1,210 Bytes
72b7e81 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
import os
import subprocess
# Must have:
# - giskard
# - giskard_cicd
# How to know the other deps?
def prepare_venv(model_id, deps):
python_executable = "python"
venv_base = f"tmp/venvs/{model_id}"
pip_executable = os.path.join(venv_base, "bin", "pip")
# Check pyver
subprocess.run([python_executable, "--version"])
# Create venv
subprocess.run([python_executable, "-m", "venv", venv_base, "--clear"])
# Output requirements.txt
requirement_file = os.path.join(venv_base, "requirements.txt")
with open(requirement_file, "w") as f:
f.writelines(deps)
# Install deps
subprocess.run([pip_executable, "install", "-r", requirement_file])
# Need a file to run model, dataset to get the results back
# Need to run `giskard_scanner ...` in the environment
def run_venv(ver, port):
python_ver = list(str(v) for v in ver)
python_executable = "python" + (".".join(python_ver[:2]))
print(f"{python_executable} started: {time.time()}")
venv_base = "giskard-home/venvs/" + python_executable + "/123456789"
executable = os.path.join(venv_base, "bin", "python")
# Run
subprocess.Popen([executable, "giskard_venv_boostrap.py", str(port)])
|