nbsync 0.4.0__tar.gz → 0.4.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {nbsync-0.4.0 → nbsync-0.4.2}/PKG-INFO +1 -1
- {nbsync-0.4.0 → nbsync-0.4.2}/pyproject.toml +1 -1
- {nbsync-0.4.0 → nbsync-0.4.2}/src/nbsync/notebook.py +5 -11
- {nbsync-0.4.0 → nbsync-0.4.2}/src/nbsync/sync.py +20 -7
- {nbsync-0.4.0 → nbsync-0.4.2}/LICENSE +0 -0
- {nbsync-0.4.0 → nbsync-0.4.2}/README.md +0 -0
- {nbsync-0.4.0 → nbsync-0.4.2}/src/nbsync/__init__.py +0 -0
- {nbsync-0.4.0 → nbsync-0.4.2}/src/nbsync/cell.py +0 -0
- {nbsync-0.4.0 → nbsync-0.4.2}/src/nbsync/logger.py +0 -0
- {nbsync-0.4.0 → nbsync-0.4.2}/src/nbsync/markdown.py +0 -0
- {nbsync-0.4.0 → nbsync-0.4.2}/src/nbsync/py.typed +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.3
|
|
2
2
|
Name: nbsync
|
|
3
|
-
Version: 0.4.
|
|
3
|
+
Version: 0.4.2
|
|
4
4
|
Summary: A core library to synchronize Jupyter notebooks and Markdown documents, enabling seamless integration and dynamic content execution
|
|
5
5
|
Keywords: jupyter,notebook,documentation,markdown,python,visualization,dynamic-execution,real-time-sync
|
|
6
6
|
Author: daizutabi
|
|
@@ -4,7 +4,7 @@ build-backend = "uv_build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "nbsync"
|
|
7
|
-
version = "0.4.
|
|
7
|
+
version = "0.4.2"
|
|
8
8
|
description = "A core library to synchronize Jupyter notebooks and Markdown documents, enabling seamless integration and dynamic content execution"
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = { file = "LICENSE" }
|
|
@@ -7,8 +7,6 @@ from typing import TYPE_CHECKING
|
|
|
7
7
|
|
|
8
8
|
import nbstore.notebook
|
|
9
9
|
|
|
10
|
-
from nbsync import logger
|
|
11
|
-
|
|
12
10
|
if TYPE_CHECKING:
|
|
13
11
|
from nbformat import NotebookNode
|
|
14
12
|
|
|
@@ -42,12 +40,8 @@ class Notebook:
|
|
|
42
40
|
return nbstore.notebook.equals(self.nb, other.nb)
|
|
43
41
|
|
|
44
42
|
def execute(self) -> float:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
return end_time - start_time
|
|
51
|
-
except ModuleNotFoundError as e: # no cov
|
|
52
|
-
logger.warning(e.msg)
|
|
53
|
-
return 0
|
|
43
|
+
start_time = time.perf_counter()
|
|
44
|
+
nbstore.notebook.execute(self.nb)
|
|
45
|
+
end_time = time.perf_counter()
|
|
46
|
+
self.execution_needed = False
|
|
47
|
+
return end_time - start_time
|
|
@@ -41,19 +41,32 @@ class Synchronizer:
|
|
|
41
41
|
if url not in self.notebooks or not self.notebooks[url].equals(notebook):
|
|
42
42
|
self.notebooks[url] = notebook
|
|
43
43
|
|
|
44
|
-
def execute(self) -> None:
|
|
44
|
+
def execute(self, src_uri: str | None = None) -> None:
|
|
45
45
|
for url, notebook in self.notebooks.items():
|
|
46
46
|
if not notebook.execution_needed:
|
|
47
47
|
continue
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
if url == ".md":
|
|
50
|
+
path = src_uri or ".md"
|
|
51
|
+
else:
|
|
52
|
+
path = str(self.store.find_path(url).relative_to(Path.cwd()))
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
try:
|
|
55
|
+
elapsed = notebook.execute()
|
|
56
|
+
except Exception as e: # noqa: BLE001
|
|
57
|
+
if src_uri and src_uri != path:
|
|
58
|
+
msg = f"Error reading page {src_uri!r}: "
|
|
59
|
+
else:
|
|
60
|
+
msg = ""
|
|
61
|
+
msg = f"{msg}Error executing notebook {path!r}: {e}"
|
|
62
|
+
logger.error(msg)
|
|
63
|
+
raise SystemExit(1) from None
|
|
64
|
+
else:
|
|
65
|
+
logger.info(f"{path!r} executed in {elapsed:.2f} seconds")
|
|
66
|
+
|
|
67
|
+
def convert(self, text: str, src_uri: str | None = None) -> Iterator[str | Cell]:
|
|
55
68
|
elems = list(self.parse(text))
|
|
56
|
-
self.execute()
|
|
69
|
+
self.execute(src_uri)
|
|
57
70
|
|
|
58
71
|
for elem in elems:
|
|
59
72
|
if isinstance(elem, str):
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|