Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a notebook test script. #187

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
better filters
  • Loading branch information
MarkDaoust committed May 31, 2024
commit 6187a08eeb1fd23be194cd7438af3bc17e180246
28 changes: 21 additions & 7 deletions tools/run_notebooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
flags.DEFINE_bool("debug", False, "Print the notebook execution log")
flags.DEFINE_bool("save_output", False, "save the output back to the notebook file.")
flags.DEFINE_integer("timeout", 600, "Timeout in seconds for a cell's execution.")
flags.DEFINE_list('skip', None, "list of path patterns to skip")

FLAGS = flags.FLAGS

SKIP_EXECUTE = [re.compile("pip .*install"),
SKIP_EXECUTE = [re.compile("pip .*install .*google\.(ai\.generativelanguage|generativeai)"),
re.compile("userdata\.get"),
re.compile("google.colab.*?userdata"),]
re.compile("google.colab.*?userdata"),
re.compile("list(_tuned)?_models")]


class DiscardStatusMessagesFilter(logging.Filter):
Expand Down Expand Up @@ -302,10 +304,12 @@ def main(argv):

if notebooks:
if len(notebooks) == 1:
print(notebooks[0])
test_notebook(processor, notebooks[0])
print(' Okay!')
return
nb = pathlib.Path(notebooks[0])
if nb.is_file():
print(nb)
test_notebook(processor, nb)
print(' Okay!')
return

else:
notebooks = [os.getcwd()]
Expand All @@ -320,7 +324,17 @@ def expand_dirs(paths):


notebooks = expand_dirs(notebooks)
notebooks = (nb for nb in notebooks if ".ipynb_checkpoints" not in nb.parts)
skip = [".ipynb_checkpoints"]
if FLAGS.skip:
skip.extend(FLAGS.skip)

def filter(paths):
for path in paths:
if any(s in str(path) for s in skip):
continue
yield path

notebooks = filter(notebooks)
notebooks = list(notebooks)

good_file = pathlib.Path('good.txt')
Expand Down