From 9f4105e3ef78cefdf1dda3582b676b47ddc1a048 Mon Sep 17 00:00:00 2001 From: yumoqing Date: Thu, 11 Jun 2026 22:05:00 +0800 Subject: [PATCH] fix: remove hardcoded Sage paths from load_path.py, use relative paths instead --- scripts/load_path.py | 45 ++++++++++++++++++-------------------------- 1 file changed, 18 insertions(+), 27 deletions(-) diff --git a/scripts/load_path.py b/scripts/load_path.py index 1ccea1c..7e5662d 100644 --- a/scripts/load_path.py +++ b/scripts/load_path.py @@ -1,27 +1,8 @@ #!/usr/bin/env python3 """Pipeline bridge module RBAC permission registration""" -import os, sys, subprocess - -# Find Sage root -SAGE_ROOT = None -for candidate in [os.path.expanduser("~/repos/sage"), os.path.expanduser("~/sage")]: - if os.path.isdir(os.path.join(candidate, "wwwroot")): - SAGE_ROOT = candidate - break - -if not SAGE_ROOT: - print("ERROR: Sage root not found") - sys.exit(1) +import subprocess MOD = "pipeline" -SET_PERM = os.path.join(SAGE_ROOT, "set_role_perm.py") -PY = os.path.join(SAGE_ROOT, "py3", "bin", "python") - -def set_perm(role, path): - cmd = [PY, SET_PERM, role, path] - r = subprocess.run(cmd, capture_output=True, text=True) - if r.returncode != 0: - print(f" WARN: {path} -> {r.stderr.strip()}") # Public resources (no auth needed) PATHS_ANY = [ @@ -31,7 +12,8 @@ PATHS_ANY = [ # Authenticated endpoints PATHS_LOGINED = [ - f"/{MOD}", + f"/{MOD}/", + f"/{MOD}/index.ui", f"/{MOD}/api/pipeline_list.dspy", f"/{MOD}/api/pipeline_detail.dspy", f"/{MOD}/api/pipeline_submit.dspy", @@ -39,9 +21,18 @@ PATHS_LOGINED = [ f"/{MOD}/api/pipeline_node.dspy", ] -print(f"Registering RBAC permissions for {MOD}...") -for p in PATHS_ANY: - set_perm("any", p) -for p in PATHS_LOGINED: - set_perm("logined", p) -print("Done.") + +def register_paths(): + for path in PATHS_ANY: + subprocess.run(["py3/bin/python", "set_role_perm.py", "any", path]) + print(f" any: {path}") + + for path in PATHS_LOGINED: + subprocess.run(["py3/bin/python", "set_role_perm.py", "logined", path]) + print(f" logined: {path}") + + +if __name__ == "__main__": + print(f"=== {MOD} RBAC registration ===") + register_paths() + print("Done.")