Skip to content

Commit

Permalink
update script
Browse files Browse the repository at this point in the history
  • Loading branch information
vbarda committed Sep 12, 2024
1 parent 8781caa commit d8309da
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions docs/_scripts/prepare_notebooks_for_ci.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
"""Preprocess notebooks for CI. Currently removes pip install cells."""

import os
import json
import logging
import os

logger = logging.getLogger(__name__)
NOTEBOOK_DIRS = ("docs/docs/how-tos",)


def remove_install_cells(notebook_path: str) -> None:
with open(notebook_path, "r") as file:
notebook = json.load(file)

indices_to_delete = []
for index, cell in enumerate(notebook["cells"]):
if cell["cell_type"] == "code":
if any("pip install" in line for line in cell["source"]):
notebook["cells"].pop(index)
break # Exit the loop after removing the cell
indices_to_delete.append(index)

for index in reversed(indices_to_delete):
notebook["cells"].pop(index)

with open(notebook_path, "w") as file:
json.dump(notebook, file, indent=2)
Expand Down

0 comments on commit d8309da

Please sign in to comment.