File tree Expand file tree Collapse file tree 5 files changed +86
-93
lines changed Expand file tree Collapse file tree 5 files changed +86
-93
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 8484 poetry run python -m pip install gensim
8585 poetry install
8686
87- - name : Check Semversioner
88- run : |
89- poetry run semversioner check
90-
9187 - name : Check
9288 run : |
9389 poetry run poe check
Original file line number Diff line number Diff line change 1+ name : Python Notebook Tests
2+ on :
3+ push :
4+ branches : [main]
5+ pull_request :
6+ branches : [main]
7+
8+ permissions :
9+ contents : read
10+ pull-requests : read
11+
12+ concurrency :
13+ group : ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
14+ # Only run the for the latest commit
15+ cancel-in-progress : true
16+
17+ env :
18+ POETRY_VERSION : 1.8.3
19+
20+ jobs :
21+ python-ci :
22+ strategy :
23+ matrix :
24+ python-version : ["3.11"]
25+ os : [ubuntu-latest, windows-latest]
26+ fail-fast : false # Continue running all jobs even if one fails
27+ env :
28+ DEBUG : 1
29+ GRAPHRAG_API_KEY : ${{ secrets.OPENAI_NOTEBOOK_KEY }}
30+ GRAPHRAG_LLM_MODEL : ${{ secrets.GRAPHRAG_LLM_MODEL }}
31+ GRAPHRAG_EMBEDDING_MODEL : ${{ secrets.GRAPHRAG_EMBEDDING_MODEL }}
32+
33+ runs-on : ${{ matrix.os }}
34+ steps :
35+ - uses : actions/checkout@v4
36+
37+ - uses : dorny/paths-filter@v3
38+ id : changes
39+ with :
40+ filters : |
41+ python:
42+ - 'graphrag/**/*'
43+ - 'poetry.lock'
44+ - 'pyproject.toml'
45+ - '**/*.py'
46+ - '**/*.toml'
47+ - '**/*.ipynb'
48+ - '.github/workflows/python*.yml'
49+
50+ - name : Set up Python ${{ matrix.python-version }}
51+ uses : actions/setup-python@v5
52+ with :
53+ python-version : ${{ matrix.python-version }}
54+
55+ - name : Install Poetry
56+ uses : abatilo/actions-poetry@v3.0.0
57+ with :
58+ poetry-version : $POETRY_VERSION
59+
60+ - name : Install dependencies
61+ shell : bash
62+ run : |
63+ poetry self add setuptools wheel
64+ poetry run python -m pip install gensim
65+ poetry install
66+
67+
68+ - name : Notebook Test
69+ run : |
70+ poetry run poe test_notebook
Original file line number Diff line number Diff line change @@ -125,6 +125,7 @@ _test_all = "coverage run -m pytest ./tests"
125125test_unit = " pytest ./tests/unit"
126126test_integration = " pytest ./tests/integration"
127127test_smoke = " pytest ./tests/smoke"
128+ test_notebook = " pytest ./tests/notebook"
128129index = " python -m graphrag.index"
129130query = " python -m graphrag.query"
130131prompt_tune = " python -m graphrag.prompt_tune"
Original file line number Diff line number Diff line change 11# Copyright (c) 2024 Microsoft Corporation.
22# Licensed under the MIT License
33import subprocess
4- import tempfile
54from pathlib import Path
65
76import nbformat
87import pytest
98
10- DOCS_PATH = Path ("../../docsite " )
9+ NOTEBOOKS_PATH = Path ("examples_notebooks " )
1110
12- notebooks_list = list (DOCS_PATH .rglob ("*.ipynb" ))
11+ notebooks_list = list (NOTEBOOKS_PATH .rglob ("*.ipynb" ))
1312
1413
1514def _notebook_run (filepath : Path ):
1615 """Execute a notebook via nbconvert and collect output.
1716 :returns execution errors
1817 """
19- with tempfile .NamedTemporaryFile (suffix = ".ipynb" ) as temp_file :
20- args = [
21- "jupyter" ,
22- "nbconvert" ,
23- "--to" ,
24- "notebook" ,
25- "--execute" ,
26- "-y" ,
27- "--no-prompt" ,
28- "--output" ,
29- temp_file .name ,
30- filepath .absolute ().as_posix (),
31- ]
32- subprocess .check_call (args )
33-
34- temp_file .seek (0 )
35- nb = nbformat .read (temp_file , nbformat .current_nbformat )
18+ args = [
19+ "jupyter" ,
20+ "nbconvert" ,
21+ "--to" ,
22+ "notebook" ,
23+ "--execute" ,
24+ "-y" ,
25+ "--no-prompt" ,
26+ "--stdout" ,
27+ filepath .absolute ().as_posix (),
28+ ]
29+ notebook = subprocess .check_output (args )
30+ nb = nbformat .reads (notebook , nbformat .current_nbformat )
3631
3732 return [
3833 output
You can’t perform that action at this time.
0 commit comments