Spaces:
Sleeping
Sleeping
submodule debugging
Browse files- src/app.py +19 -16
src/app.py
CHANGED
|
@@ -26,35 +26,38 @@ _LSP_PATH = _BASE / "lsp"
|
|
| 26 |
|
| 27 |
|
| 28 |
def _init_submodule() -> None:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
prompts_exist = (_LSP_PATH / "src" / "prompts").exists()
|
| 30 |
if not prompts_exist:
|
| 31 |
token = os.getenv("GH_TOKEN", "")
|
| 32 |
if not token:
|
| 33 |
-
raise RuntimeError(
|
| 34 |
-
"lsp submodule not initialised and GH_TOKEN secret is not set. "
|
| 35 |
-
"Add GH_TOKEN to Space Secrets (ehejin GitHub PAT with repo scope)."
|
| 36 |
-
)
|
| 37 |
-
# Rewrite HTTPS URLs to include credentials so git can clone the private repo
|
| 38 |
subprocess.run(
|
| 39 |
-
[
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
"https://github.com/",
|
| 43 |
-
],
|
| 44 |
check=True,
|
| 45 |
)
|
| 46 |
-
subprocess.run(
|
| 47 |
["git", "submodule", "update", "--init", "--recursive"],
|
| 48 |
cwd=str(_BASE),
|
| 49 |
-
|
| 50 |
)
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
|
|
|
| 55 |
lsp_src = str(_LSP_PATH / "src")
|
| 56 |
if lsp_src not in sys.path:
|
| 57 |
sys.path.insert(0, lsp_src)
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
|
| 59 |
|
| 60 |
_init_submodule()
|
|
|
|
| 26 |
|
| 27 |
|
| 28 |
def _init_submodule() -> None:
|
| 29 |
+
print(f"[SUBMODULE] lsp path: {_LSP_PATH}")
|
| 30 |
+
print(f"[SUBMODULE] prompts exists: {(_LSP_PATH / 'src' / 'prompts').exists()}")
|
| 31 |
+
print(f"[SUBMODULE] GH_TOKEN set: {bool(os.getenv('GH_TOKEN', ''))}")
|
| 32 |
+
|
| 33 |
prompts_exist = (_LSP_PATH / "src" / "prompts").exists()
|
| 34 |
if not prompts_exist:
|
| 35 |
token = os.getenv("GH_TOKEN", "")
|
| 36 |
if not token:
|
| 37 |
+
raise RuntimeError("lsp submodule not initialised and GH_TOKEN is not set.")
|
|
|
|
|
|
|
|
|
|
|
|
|
| 38 |
subprocess.run(
|
| 39 |
+
["git", "config", "--global",
|
| 40 |
+
f"url.https://ehejin:{token}@github.com/.insteadOf",
|
| 41 |
+
"https://github.com/"],
|
|
|
|
|
|
|
| 42 |
check=True,
|
| 43 |
)
|
| 44 |
+
result = subprocess.run(
|
| 45 |
["git", "submodule", "update", "--init", "--recursive"],
|
| 46 |
cwd=str(_BASE),
|
| 47 |
+
capture_output=True, text=True,
|
| 48 |
)
|
| 49 |
+
print(f"[SUBMODULE] fetch stdout: {result.stdout}")
|
| 50 |
+
print(f"[SUBMODULE] fetch stderr: {result.stderr}")
|
| 51 |
+
print(f"[SUBMODULE] fetch returncode: {result.returncode}")
|
| 52 |
+
print(f"[SUBMODULE] prompts exists after fetch: {(_LSP_PATH / 'src' / 'prompts').exists()}")
|
| 53 |
+
|
| 54 |
lsp_src = str(_LSP_PATH / "src")
|
| 55 |
if lsp_src not in sys.path:
|
| 56 |
sys.path.insert(0, lsp_src)
|
| 57 |
+
if str(_BASE) not in sys.path:
|
| 58 |
+
sys.path.insert(0, str(_BASE))
|
| 59 |
+
|
| 60 |
+
print(f"[SUBMODULE] sys.path includes lsp/src: {lsp_src in sys.path}")
|
| 61 |
|
| 62 |
|
| 63 |
_init_submodule()
|