Skip to content

Commit

Permalink
Merge pull request #15 from ShoggothAI/jupyter_notebooks_docs
Browse files Browse the repository at this point in the history
fix jupiter notebooks integration tests
  • Loading branch information
BespalovSergey authored May 8, 2024
2 parents 1a569f5 + 6121ac3 commit e277fb4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions tests/run_integration_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import difflib
import json
from copy import copy
from functools import partial

from dotenv import load_dotenv
import nbformat
Expand Down Expand Up @@ -110,6 +111,15 @@ def read_golden_data(golden_dir: str, test_name: str, extension: str = "json"):
return json.load(fd)


def run_ipynb(ipynb_path: str):
"""Run jupiter notebook execution"""
with open(ipynb_path) as f:
nb = nbformat.read(f, as_version=4)

ep = ExecutePreprocessor()
ep.preprocess(nb)


def build_ipynb_integration_tests() -> dict:
"""Build and return dict of ipynb integration tests functions"""
test_functions = {}
Expand All @@ -118,14 +128,7 @@ def build_ipynb_integration_tests() -> dict:
logging.info("Ipynb test notebook {} not found".format(test_name))
continue

def test_function():
with open(nb_path) as f:
nb = nbformat.read(f, as_version=4)

ep = ExecutePreprocessor()
ep.preprocess(nb)

test_functions[test_name] = test_function
test_functions[test_name] = partial(run_ipynb, nb_path)

return test_functions

Expand Down

0 comments on commit e277fb4

Please sign in to comment.