nbsync 0.3.1__py3-none-any.whl → 0.3.2__py3-none-any.whl

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/notebook.py CHANGED
@@ -1,6 +1,8 @@
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
@@ -10,6 +12,9 @@ from nbsync import logger
10
12
  if TYPE_CHECKING:
11
13
  from nbformat import NotebookNode
12
14
 
15
+ # DeprecationWarning: Jupyter is migrating its paths to use standard platformdirs
16
+ os.environ.setdefault("JUPYTER_PLATFORM_DIRS", "1")
17
+
13
18
 
14
19
  class Notebook:
15
20
  nb: NotebookNode
@@ -36,10 +41,13 @@ class Notebook:
36
41
  def equals(self, other: Notebook) -> bool:
37
42
  return nbstore.notebook.equals(self.nb, other.nb)
38
43
 
39
- def execute(self) -> None:
44
+ def execute(self) -> float:
40
45
  try:
46
+ start_time = time.perf_counter()
41
47
  nbstore.notebook.execute(self.nb)
48
+ end_time = time.perf_counter()
42
49
  self.execution_needed = False
43
-
50
+ return end_time - start_time
44
51
  except ModuleNotFoundError as e: # no cov
45
52
  logger.warning(e.msg)
53
+ return 0
nbsync/sync.py CHANGED
@@ -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))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nbsync
3
- Version: 0.3.1
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
@@ -2,10 +2,10 @@ nbsync/__init__.py,sha256=3NuWx9D0LcBnXjEKrC-uypNDOz8rLWXI7mIjdN9xSeE,126
2
2
  nbsync/cell.py,sha256=C7VqQO3mxZ7Nj4ufywTnaqZAegT7zqA6iN2WV6X5X5c,3786
3
3
  nbsync/logger.py,sha256=snNRqi9xESj4B-Z9GQffCBlgqeVujvuXuBveWAebIWM,736
4
4
  nbsync/markdown.py,sha256=xcPhQKWpFDyVQ_xtZCpFrnR0QED_hYs4PAyaT7dF3t4,3830
5
- nbsync/notebook.py,sha256=UncedeEzU-hYa8eZ_NQKjjOcaAiCxb3oIgwGB1mTKas,1143
5
+ nbsync/notebook.py,sha256=4F3V1KDHfJnIR5ZSb1xWdN9JGiC6mWUVimXXK1BFsbc,1450
6
6
  nbsync/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
- nbsync/sync.py,sha256=ZzMPeshh6BCPI6bqCEOrx-SFr7GCajL8F1QxdbOArd0,3864
8
- nbsync-0.3.1.dist-info/METADATA,sha256=rcM781_X3a9OKa6juL5aK0W3PEcU_1miAaUx-c48Eys,6552
9
- nbsync-0.3.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
- nbsync-0.3.1.dist-info/licenses/LICENSE,sha256=wy1pqn52upuo_qYwY-epWmspwE-3UWJso0xodciGXYc,1062
11
- nbsync-0.3.1.dist-info/RECORD,,
7
+ nbsync/sync.py,sha256=jI32mYA3hr_69-cejqH9B0JxYLFAMpuDDNYbpjJFazE,3989
8
+ nbsync-0.3.2.dist-info/METADATA,sha256=eeNhOG9xc0vS-69AtPEq13C2dCVBVDdWtSMl85qiJd8,6552
9
+ nbsync-0.3.2.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
10
+ nbsync-0.3.2.dist-info/licenses/LICENSE,sha256=wy1pqn52upuo_qYwY-epWmspwE-3UWJso0xodciGXYc,1062
11
+ nbsync-0.3.2.dist-info/RECORD,,
File without changes