Skip to content

Commit 039c97b

Browse files
authored
Updating quick-tour notebooks (#411)
## Problem I want to update notebooks in the `docs/quick-tour` directory to stop using the deprecated `pinecone-client` ## Solution Replace `pinecone-client` with `pinecone`. Update usage. Verify the notebooks run.
1 parent 5caec55 commit 039c97b

File tree

6 files changed

+4038
-4529
lines changed

6 files changed

+4038
-4529
lines changed

.github/actions/run-notebook/convert-notebook.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,17 @@
7272
for cell in nb.cells:
7373
if cell.cell_type == "code":
7474
if "pip" not in cell.source:
75-
executable_cells.append(cell)
75+
# Remove any lines that start with "!" or "%"
76+
# These are "magic" commands such as "%matplotlib inline" that
77+
# are not executable outside of a notebook environment.
78+
executable = "\n".join([line for line in cell.source.split("\n") if not line.strip().startswith("!") and not line.strip().startswith("%")])
79+
executable_cells.append(executable)
7680

7781
# Save executable cells to a notebook.py file
7882
script_path = os.path.join(temp_dir, 'notebook.py')
7983
with open(script_path, 'w', encoding="utf-8") as f:
8084
for cell in executable_cells:
81-
f.write(cell.source + '\n')
85+
f.write(cell + '\n')
8286

8387
print(f"Script saved to {script_path}")
8488

0 commit comments

Comments
 (0)