mirror of
https://github.com/microsoft/graphrag.git
synced 2025-07-03 15:10:17 +00:00

* Added graphrag_import_neo4j_cypher Notebook * changed to procedure for setting embedding property to save disk space * Reformat and cleanup * semver * Poetry lock update * Update AAIS docs * Rename contrib folder * Merge from main * Revert "Merge from main" This reverts commit a399dde97b689a5b5c62dc2e9c2290cb2503b3a4. * Fix ruff check * Add readme and fix tests * Fix community reports --------- Co-authored-by: Michael Hunger <github@jexp.de>
49 lines
1.1 KiB
Python
49 lines
1.1 KiB
Python
# Copyright (c) 2024 Microsoft Corporation.
|
|
# Licensed under the MIT License
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
import nbformat
|
|
import pytest
|
|
|
|
NOTEBOOKS_PATH = Path("examples_notebooks")
|
|
EXCLUDED_PATH = NOTEBOOKS_PATH / "community_contrib"
|
|
|
|
notebooks_list = [
|
|
notebook
|
|
for notebook in NOTEBOOKS_PATH.rglob("*.ipynb")
|
|
if EXCLUDED_PATH not in notebook.parents
|
|
]
|
|
|
|
|
|
def _notebook_run(filepath: Path):
|
|
"""Execute a notebook via nbconvert and collect output.
|
|
:returns execution errors
|
|
"""
|
|
args = [
|
|
"jupyter",
|
|
"nbconvert",
|
|
"--to",
|
|
"notebook",
|
|
"--execute",
|
|
"-y",
|
|
"--no-prompt",
|
|
"--stdout",
|
|
filepath.absolute().as_posix(),
|
|
]
|
|
notebook = subprocess.check_output(args)
|
|
nb = nbformat.reads(notebook, nbformat.current_nbformat)
|
|
|
|
return [
|
|
output
|
|
for cell in nb.cells
|
|
if "outputs" in cell
|
|
for output in cell["outputs"]
|
|
if output.output_type == "error"
|
|
]
|
|
|
|
|
|
@pytest.mark.parametrize("notebook_path", notebooks_list)
|
|
def test_notebook(notebook_path: Path):
|
|
assert _notebook_run(notebook_path) == []
|