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:
@@ -34,6 +34,11 @@ echo $PORT > .jupyter-port
|
|||||||
|
|
||||||
source .venv/bin/activate 2>/dev/null || true
|
source .venv/bin/activate 2>/dev/null || true
|
||||||
|
|
||||||
|
# IPython startup: cargar .ipython/ local (FN_REGISTRY_ROOT, helpers, sys.path)
|
||||||
|
if [ -d "$(pwd)/.ipython" ]; then
|
||||||
|
export IPYTHONDIR="$(pwd)/.ipython"
|
||||||
|
fi
|
||||||
|
|
||||||
if ! python -c "import jupyter_collaboration" 2>/dev/null; then
|
if ! python -c "import jupyter_collaboration" 2>/dev/null; then
|
||||||
echo "ERROR: jupyter-collaboration no esta instalado"
|
echo "ERROR: jupyter-collaboration no esta instalado"
|
||||||
echo "Instala con: uv add jupyter-collaboration"
|
echo "Instala con: uv add jupyter-collaboration"
|
||||||
|
|||||||
@@ -33,7 +33,24 @@ import sqlite3
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
# ── FN_REGISTRY_ROOT ────────────────────────────────────────
|
# ── 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)
|
os.environ["FN_REGISTRY_ROOT"] = str(FN_REGISTRY_ROOT)
|
||||||
|
|
||||||
# ── sys.path: importar funciones Python del registry ────────
|
# ── sys.path: importar funciones Python del registry ────────
|
||||||
|
|||||||
Reference in New Issue
Block a user