Skip to content

Commit 52dc832

Browse files
Release v0.4.3
1 parent bd907b6 commit 52dc832

File tree

2 files changed

+39
-1
lines changed

2 files changed

+39
-1
lines changed

src/sdialog/util.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636

3737
logger = logging.getLogger(__name__)
3838

39-
__version__ = "0.4.2"
39+
__version__ = "0.4.3"
4040

4141

4242
def _get_dynamic_version() -> str:

tutorials/clean_tqdm_bars.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import os
2+
import json
3+
import sys
4+
5+
6+
def clean_tqdm_bars_in_notebook(file_path):
7+
with open(file_path, 'r', encoding='utf-8') as f:
8+
notebook = json.load(f)
9+
10+
modified = False
11+
for cell in notebook.get('cells', []):
12+
if cell.get('cell_type') == 'code':
13+
original_outputs = cell.get('outputs', [])
14+
cleaned_outputs = [
15+
output for output in original_outputs
16+
if "data" not in output or 'application/vnd.jupyter.widget-view+json' not in output['data']
17+
]
18+
if len(cleaned_outputs) != len(original_outputs):
19+
cell['outputs'] = cleaned_outputs
20+
modified = True
21+
22+
if modified:
23+
with open(file_path, 'w', encoding='utf-8') as f:
24+
json.dump(notebook, f, indent=1)
25+
print(f"Cleaned tqdm bars in: {file_path}")
26+
else:
27+
print(f"No tqdm bars found in: {file_path}")
28+
29+
30+
if __name__ == "__main__":
31+
if len(sys.argv) != 2:
32+
print("Usage: python clean_tqdm_bars.py <path_to_folder_with_notebooks>")
33+
sys.exit(1)
34+
35+
notebook_folder = sys.argv[1]
36+
for filename in os.listdir(notebook_folder):
37+
if filename.endswith(".ipynb"):
38+
clean_tqdm_bars_in_notebook(os.path.join(notebook_folder, filename))

0 commit comments

Comments
 (0)