Spaces:
Sleeping
Sleeping
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)]) | |