fix: mejoras en jupyter launcher y kernel startup
write_jupyter_launcher ahora exporta IPYTHONDIR al directorio local .ipython/ para que el kernel cargue el startup correcto cuando se ejecuta desde projects/. write_jupyter_registry_kernel usa descubrimiento inteligente de FN_REGISTRY_ROOT: prioriza env var, luego path hardcoded, luego sube desde CWD buscando registry.db. Esto permite que analyses dentro de projects/ encuentren el registry automaticamente.
This commit is contained in:
@@ -33,7 +33,24 @@ import sqlite3
|
||||
from pathlib import Path
|
||||
|
||||
# ── FN_REGISTRY_ROOT ────────────────────────────────────────
|
||||
FN_REGISTRY_ROOT = Path("${registry_root}")
|
||||
# Prioridad: env var > path hardcoded > descubrimiento automatico
|
||||
def _discover_registry_root():
|
||||
if os.environ.get("FN_REGISTRY_ROOT"):
|
||||
return Path(os.environ["FN_REGISTRY_ROOT"]).resolve()
|
||||
hardcoded = Path("${registry_root}")
|
||||
if (hardcoded / "registry.db").exists():
|
||||
return hardcoded
|
||||
# Subir desde CWD hasta encontrar registry.db
|
||||
p = Path.cwd()
|
||||
for _ in range(10):
|
||||
if (p / "registry.db").exists():
|
||||
return p
|
||||
if p.parent == p:
|
||||
break
|
||||
p = p.parent
|
||||
return hardcoded
|
||||
|
||||
FN_REGISTRY_ROOT = _discover_registry_root()
|
||||
os.environ["FN_REGISTRY_ROOT"] = str(FN_REGISTRY_ROOT)
|
||||
|
||||
# ── sys.path: importar funciones Python del registry ────────
|
||||
|
||||
Reference in New Issue
Block a user