Skip to content

Commit

Permalink
docs: efficient rebuild (langchain-ai#28195)
Browse files Browse the repository at this point in the history
if you run `make build start` in one tab, then start editing files, you
can efficient rebuild notebooks with `make generate-files md-sync
render`
  • Loading branch information
efriis authored Nov 18, 2024
1 parent 018f410 commit cbeb860
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ install-py-deps:

generate-files:
mkdir -p $(INTERMEDIATE_DIR)
cp -r $(SOURCE_DIR)/* $(INTERMEDIATE_DIR)
cp -rp $(SOURCE_DIR)/* $(INTERMEDIATE_DIR)

$(PYTHON) scripts/tool_feat_table.py $(INTERMEDIATE_DIR)

Expand Down
13 changes: 12 additions & 1 deletion docs/scripts/notebook_convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,18 @@ def _convert_notebook(
source_paths_stripped = [p.strip() for p in source_path_strs]
source_paths = [intermediate_docs_dir / p for p in source_paths_stripped if p]
else:
source_paths = intermediate_docs_dir.glob("**/*.ipynb")
original_paths = list(intermediate_docs_dir.glob("**/*.ipynb"))
# exclude files that exist in output directory and are newer
relative_paths = [p.relative_to(intermediate_docs_dir) for p in original_paths]
out_paths = [
output_docs_dir / p.parent / (p.stem + ".md") for p in relative_paths
]
source_paths = [
p
for p, o in zip(original_paths, out_paths)
if not o.exists() or o.stat().st_mtime < p.stat().st_mtime
]
print(f"rebuilding {len(source_paths)}/{len(relative_paths)} notebooks")

with multiprocessing.Pool() as pool:
pool.map(
Expand Down

0 comments on commit cbeb860

Please sign in to comment.