From ee246e4ef14f617738550a7d79b566171f8f1867 Mon Sep 17 00:00:00 2001 From: Benjamin Zaitlen Date: Sat, 4 May 2024 10:22:36 -0700 Subject: [PATCH] add run script and list additional packages needed --- run.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 run.py diff --git a/run.py b/run.py new file mode 100644 index 00000000..98fc784c --- /dev/null +++ b/run.py @@ -0,0 +1,27 @@ +# python -m pip install opencv-python textblob +import os +import subprocess + +def find_notebooks(directory): + notebooks = [] + for root, dirs, files in os.walk(directory): + dirs[:] = [d for d in dirs if d != "R"] # Ignore directories named "R" + if "solution" in root: + for file in files: + if file.endswith(".ipynb"): + notebooks.append(os.path.join(root, file)) + return notebooks + + +def execute_notebooks(notebooks): + for notebook in notebooks: + try: + subprocess.run(["jupyter", "execute", notebook], check=True) + print(f"Executed notebook: {notebook}") + except subprocess.CalledProcessError as e: + print(f"Error executing notebook {notebook}: {e}") + +if __name__ == "__main__": + start_directory = "." # Replace with the path to the directory you want to search + notebooks = find_notebooks(start_directory) + execute_notebooks(notebooks)