212875ed0d
- .claude/agents/fn-orquestador/SKILL.md - .claude/commands/fn_claude.md - .claude/rules/INDEX.md - .claude/rules/cpp_apps.md - .claude/rules/ids_naming.md - CHANGELOG.md - apps/dag_engine/README.md - apps/dag_engine/api.go - apps/dag_engine/dags_migrated/example.yaml - apps/dag_engine/dags_migrated/example_lineage_tracking.yaml - ... Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3.9 KiB
3.9 KiB
name, kind, lang, domain, version, purity, signature, description, tags, uses_functions, uses_types, returns, returns_optional, error_type, imports, params, output, tested, tests, test_file_path, file_path
| name | kind | lang | domain | version | purity | signature | description | tags | uses_functions | uses_types | returns | returns_optional | error_type | imports | params | output | tested | tests | test_file_path | file_path | |||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| jupyter_read | function | py | notebook | 1.0.0 | impure | def jupyter_read_cells(notebook_path: str, server_url: str = 'http://localhost:8888', token: str = '', cell_index: int | None = None) -> list[dict] | Lee celdas de un notebook Jupyter abierto via el protocolo de colaboracion en tiempo real (CRDT/Y.js). Devuelve el estado actual incluyendo cambios no guardados. Expone tambien jupyter_notebook_info() para metadata rapida. |
|
false | error_go_core |
|
|
Lista de dicts con info de celdas (index, type, source, outputs) o dict con metadata del notebook | false | python/functions/notebook/jupyter_read.py |
Funciones exportadas
jupyter_read_cells
def jupyter_read_cells(
notebook_path: str,
server_url: str = "http://localhost:8888",
token: str = "",
cell_index: int | None = None,
) -> list[dict]
Lee todas las celdas o una especifica de un notebook Jupyter en vivo. Retorna lista de dicts:
{"index": 0, "type": "code", "source": "import pandas as pd", "outputs": ["..."]}
- Para celdas markdown y raw, el campo
outputsno se incluye. - Para code cells, los outputs se convierten a texto legible:
stream-> texto planodisplay_data/execute_result->text/plain, o[HTML Output],[Image Output (PNG)]error-> traceback limpio (sin codigos ANSI)
jupyter_notebook_info
def jupyter_notebook_info(
notebook_path: str,
server_url: str = "http://localhost:8888",
token: str = "",
) -> dict
Retorna metadata del notebook:
{
"notebook_path": "notebooks/analysis.ipynb",
"server_url": "http://localhost:8888",
"total_cells": 12,
"cell_counts": {"code": 9, "markdown": 3}
}
Ejemplo
from notebook.jupyter_read import jupyter_read_cells, jupyter_notebook_info
# Leer todas las celdas
cells = jupyter_read_cells(
"notebooks/analysis.ipynb",
server_url="http://localhost:8888",
token="mi-token",
)
for cell in cells:
print(f"[{cell['index']}] {cell['type']}: {cell['source'][:60]}")
# Leer solo la celda 3
cell = jupyter_read_cells("notebooks/analysis.ipynb", token="mi-token", cell_index=3)
# Solo metadata
info = jupyter_notebook_info("notebooks/analysis.ipynb", token="mi-token")
print(f"Total celdas: {info['total_cells']}")
CLI
# Ver todas las celdas (formato legible)
python jupyter_read.py notebooks/analysis.ipynb --token MI_TOKEN
# Ver solo la celda 5
python jupyter_read.py notebooks/analysis.ipynb --token MI_TOKEN --cell 5
# Solo metadata
python jupyter_read.py notebooks/analysis.ipynb --token MI_TOKEN --info
# Salida JSON (todas las celdas)
python jupyter_read.py notebooks/analysis.ipynb --token MI_TOKEN --json
# Servidor remoto
python jupyter_read.py notebooks/analysis.ipynb --server http://mi-servidor:8888 --token MI_TOKEN
Notas
- Usa
NbModelClientdejupyter_nbmodel_clientcon protocolo CRDT/Y.js. - Las funciones internas son
async; las publicas envuelven conasyncio.run()para ser sincronas. - Lee el estado en memoria del servidor, no el archivo
.ipynben disco — captura cambios no guardados. notebook_pathdebe ser relativo a la raiz del servidor Jupyter, no al sistema de archivos local.- Para servidores sin token, usar
token=""(default). - El CLI muestra preview de hasta 8 lineas de source y 4 lineas por output en modo legible.