Spaces:
Running
Running
Install dependencies from requirements.txt.
Browse files
lynxkite-core/src/lynxkite/core/ops.py
CHANGED
|
@@ -7,6 +7,7 @@ import functools
|
|
| 7 |
import importlib
|
| 8 |
import inspect
|
| 9 |
import pathlib
|
|
|
|
| 10 |
import traceback
|
| 11 |
import joblib
|
| 12 |
import types
|
|
@@ -348,10 +349,22 @@ def load_user_scripts(workspace: str):
|
|
| 348 |
run_user_script(f)
|
| 349 |
except Exception:
|
| 350 |
traceback.print_exc()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
if p == cwd:
|
| 352 |
break
|
| 353 |
|
| 354 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 355 |
def run_user_script(script_path: pathlib.Path):
|
| 356 |
print(f"Running {script_path}...")
|
| 357 |
spec = importlib.util.spec_from_file_location(script_path.stem, str(script_path))
|
|
|
|
| 7 |
import importlib
|
| 8 |
import inspect
|
| 9 |
import pathlib
|
| 10 |
+
import subprocess
|
| 11 |
import traceback
|
| 12 |
import joblib
|
| 13 |
import types
|
|
|
|
| 349 |
run_user_script(f)
|
| 350 |
except Exception:
|
| 351 |
traceback.print_exc()
|
| 352 |
+
req = p / "requirements.txt"
|
| 353 |
+
if req.exists():
|
| 354 |
+
try:
|
| 355 |
+
install_requirements(req)
|
| 356 |
+
except Exception:
|
| 357 |
+
traceback.print_exc()
|
| 358 |
if p == cwd:
|
| 359 |
break
|
| 360 |
|
| 361 |
|
| 362 |
+
def install_requirements(req: pathlib.Path):
|
| 363 |
+
cmd = ["uv", "pip", "install", "-r", str(req)]
|
| 364 |
+
print(f"Running {' '.join(cmd)}")
|
| 365 |
+
subprocess.check_call(cmd)
|
| 366 |
+
|
| 367 |
+
|
| 368 |
def run_user_script(script_path: pathlib.Path):
|
| 369 |
print(f"Running {script_path}...")
|
| 370 |
spec = importlib.util.spec_from_file_location(script_path.stem, str(script_path))
|