This commit is contained in:
Erick Friis
2024-05-22 13:01:17 -07:00
parent 80ea48fae1
commit 5491993f8a
4 changed files with 19 additions and 13 deletions

View File

@@ -3,7 +3,8 @@ import os
import re
import sys
from pathlib import Path
from typing import Iterable, Tuple
from typing import Iterable, Tuple, List
import tqdm
import nbformat
from nbconvert.exporters import MarkdownExporter
@@ -133,19 +134,24 @@ if __name__ == "__main__":
output_docs_dir = Path(sys.argv[2])
source_paths_arg = os.environ.get("SOURCE_PATHS")
source_paths: Iterable[Path]
source_paths: List[Path]
if source_paths_arg:
source_path_strs = re.split(r"\s+", source_paths_arg)
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")
source_paths = list(intermediate_docs_dir.glob("**/*.ipynb"))
with multiprocessing.Pool() as pool:
pool.map(
_process_path,
(
(notebook_path, intermediate_docs_dir, output_docs_dir)
for notebook_path in source_paths
),
list(
tqdm.tqdm(
pool.imap(
_process_path,
(
(notebook_path, intermediate_docs_dir, output_docs_dir)
for notebook_path in source_paths
),
),
total=len(source_paths),
)
)