A reactive notebook for Python — run reproducible experiments, query with SQL, execute as a script, deploy as an app, and version with git. Stored as pure Python. All in a modern, AI-native editor.
Python artificial-intelligencedagdata-sciencedata-visualizationdataflowdeveloper-toolsmachine-learningnotebookspipelinepythonreactivesqlweb-app
fix: split up ipynb convert function (#438)
Myles Scolnickf1e763e6c4d9
diff --git a/marimo/_cli/cli.py b/marimo/_cli/cli.pyindex 19f6855b42..eb9add89e5 100644--- a/marimo/_cli/cli.py+++ b/marimo/_cli/cli.py@@ -397,7 +397,7 @@ def convert(ipynb: str) -> None:you may need to fix errors like multiple definition errors or cycleerrors."""- print(ipynb_to_marimo.convert(ipynb))+ print(ipynb_to_marimo.convert_from_path(ipynb))@main.command()diff --git a/marimo/_cli/ipynb_to_marimo.py b/marimo/_cli/ipynb_to_marimo.pyindex 6da1ff366a..65c35d34c1 100644--- a/marimo/_cli/ipynb_to_marimo.py+++ b/marimo/_cli/ipynb_to_marimo.py@@ -3,13 +3,14 @@ from __future__ import annotationsimport jsonimport urllib.request+from typing import Anyfrom marimo._ast import codegenfrom marimo._ast.cell import CellConfigfrom marimo._cli.file_path import get_github_src_url, is_github_src-def convert(ipynb_path: str) -> str:+def convert_from_path(ipynb_path: str) -> str:if is_github_src(ipynb_path, ext=".ipynb"):notebook = json.loads(urllib.request.urlopen(get_github_src_url(ipynb_path))@@ -19,6 +20,11 @@ def convert(ipynb_path: str) -> str:else:with open(ipynb_path, "r") as f:notebook = json.loads(f.read())++ return convert(notebook)+++def convert(notebook: dict[str, Any]) -> str:sources = []has_markdown = Falsefor cell in notebook["cells"]:diff --git a/marimo/_cli/test_ipynb_to_marimo.py b/marimo/_cli/test_ipynb_to_marimo.pyindex e5d0ea06b5..4091470c0d 100644--- a/marimo/_cli/test_ipynb_to_marimo.py+++ b/marimo/_cli/test_ipynb_to_marimo.py@@ -7,13 +7,13 @@ import textwrapfrom collections.abc import Sequencefrom marimo._ast import codegen-from marimo._cli.ipynb_to_marimo import convert+from marimo._cli.ipynb_to_marimo import convert_from_pathDIR_PATH = os.path.dirname(os.path.realpath(__file__))def get_codes(ipynb_name: str) -> tuple[Sequence[str], Sequence[str]]:- contents = convert(+ contents = convert_from_path(DIR_PATH + f"/../_test_utils/ipynb_data/{ipynb_name}.ipynb.txt")