nbsync 0.3.0__tar.gz → 0.3.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.3.0 → nbsync-0.3.2}/PKG-INFO +1 -1
- {nbsync-0.3.0 → nbsync-0.3.2}/pyproject.toml +1 -1
- {nbsync-0.3.0 → nbsync-0.3.2}/src/nbsync/notebook.py +17 -3
- {nbsync-0.3.0 → nbsync-0.3.2}/src/nbsync/sync.py +4 -2
- {nbsync-0.3.0 → nbsync-0.3.2}/tests/test_notebook.py +2 -1
- {nbsync-0.3.0 → nbsync-0.3.2}/.devcontainer/devcontainer.json +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/.devcontainer/postCreate.sh +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/.devcontainer/starship.toml +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/.gitattributes +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/.github/workflows/ci.yaml +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/.github/workflows/docs.yaml +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/.github/workflows/publish.yaml +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/.gitignore +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/LICENSE +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/README.md +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/docs/index.md +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/mkdocs.yaml +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/src/nbsync/__init__.py +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/src/nbsync/cell.py +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/src/nbsync/logger.py +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/src/nbsync/markdown.py +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/src/nbsync/py.typed +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/tests/__init__.py +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/tests/conftest.py +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/tests/test_cell.py +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/tests/test_logger.py +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/tests/test_markdown.py +0 -0
- {nbsync-0.3.0 → nbsync-0.3.2}/tests/test_sync.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: nbsync
|
3
|
-
Version: 0.3.
|
3
|
+
Version: 0.3.2
|
4
4
|
Summary: A core library to synchronize Jupyter notebooks and Markdown documents, enabling seamless integration and dynamic content execution
|
5
5
|
Project-URL: Documentation, https://daizutabi.github.io/nbsync/
|
6
6
|
Project-URL: Source, https://github.com/daizutabi/nbsync
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
4
4
|
|
5
5
|
[project]
|
6
6
|
name = "nbsync"
|
7
|
-
version = "0.3.
|
7
|
+
version = "0.3.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" }
|
@@ -1,13 +1,20 @@
|
|
1
1
|
from __future__ import annotations
|
2
2
|
|
3
3
|
import copy
|
4
|
+
import os
|
5
|
+
import time
|
4
6
|
from typing import TYPE_CHECKING
|
5
7
|
|
6
8
|
import nbstore.notebook
|
7
9
|
|
10
|
+
from nbsync import logger
|
11
|
+
|
8
12
|
if TYPE_CHECKING:
|
9
13
|
from nbformat import NotebookNode
|
10
14
|
|
15
|
+
# DeprecationWarning: Jupyter is migrating its paths to use standard platformdirs
|
16
|
+
os.environ.setdefault("JUPYTER_PLATFORM_DIRS", "1")
|
17
|
+
|
11
18
|
|
12
19
|
class Notebook:
|
13
20
|
nb: NotebookNode
|
@@ -34,6 +41,13 @@ class Notebook:
|
|
34
41
|
def equals(self, other: Notebook) -> bool:
|
35
42
|
return nbstore.notebook.equals(self.nb, other.nb)
|
36
43
|
|
37
|
-
def execute(self) ->
|
38
|
-
|
39
|
-
|
44
|
+
def execute(self) -> float:
|
45
|
+
try:
|
46
|
+
start_time = time.perf_counter()
|
47
|
+
nbstore.notebook.execute(self.nb)
|
48
|
+
end_time = time.perf_counter()
|
49
|
+
self.execution_needed = False
|
50
|
+
return end_time - start_time
|
51
|
+
except ModuleNotFoundError as e: # no cov
|
52
|
+
logger.warning(e.msg)
|
53
|
+
return 0
|
@@ -3,6 +3,7 @@ from __future__ import annotations
|
|
3
3
|
import re
|
4
4
|
import textwrap
|
5
5
|
from dataclasses import dataclass, field
|
6
|
+
from pathlib import Path
|
6
7
|
from typing import TYPE_CHECKING
|
7
8
|
|
8
9
|
import nbformat
|
@@ -46,8 +47,9 @@ class Synchronizer:
|
|
46
47
|
continue
|
47
48
|
|
48
49
|
path = ".md" if url == ".md" else self.store.find_path(url)
|
49
|
-
logger.info(f"Executing notebook: {path}")
|
50
|
-
notebook.execute()
|
50
|
+
logger.info(f"Executing notebook: {path}...")
|
51
|
+
if elapsed := notebook.execute():
|
52
|
+
logger.info(f"{Path(path).name!r} executed in {elapsed} seconds")
|
51
53
|
|
52
54
|
def convert(self, text: str) -> Iterator[str | Cell]:
|
53
55
|
elems = list(self.parse(text))
|
@@ -44,6 +44,7 @@ def test_execute():
|
|
44
44
|
nb = nbformat.v4.new_notebook()
|
45
45
|
notebook = Notebook(nb)
|
46
46
|
notebook.add_cell("id", "print(1+1)")
|
47
|
-
notebook.execute()
|
47
|
+
x = notebook.execute()
|
48
|
+
assert x > 0
|
48
49
|
assert nbstore.notebook.get_stream(notebook.nb, "id") == "2\n"
|
49
50
|
assert notebook.execution_needed is False
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|