mirror of
https://github.com/microsoft/graphrag.git
synced 2025-08-17 21:22:00 +00:00
Notebook tests (#978)
* Fix notebook test runs * Delete old issue template * Add notebook CI action * Print temp directories * Print more env * Move printing up * Use runner_temp * Try using current directory * Try TMP env * Re-write TMP * Wrong yml * Fix echo * Only export if windows * More logging * Move export * Reformat env write * Fix braces * Switch to in-memory execution * Downgrade action perms * Unused import
This commit is contained in:
parent
8a9a2f7574
commit
98cabba38b
69
.github/ISSUE_TEMPLATE.md
vendored
69
.github/ISSUE_TEMPLATE.md
vendored
@ -1,69 +0,0 @@
|
||||
### Description
|
||||
|
||||
<!-- A clear and concise description of the issue or feature request. -->
|
||||
|
||||
### Environment
|
||||
|
||||
- GraphRAG version: <!-- Specify the GraphRAG version (e.g., v0.1.1) -->
|
||||
- Python version: <!-- Specify the Python version (e.g., 3.8) -->
|
||||
- Operating System: <!-- Specify the OS (e.g., Windows 10, Ubuntu 20.04) -->
|
||||
|
||||
### Steps to Reproduce (for bugs)
|
||||
|
||||
<!-- Provide detailed steps to reproduce the issue. Include code snippets, configuration files, or any other relevant information. -->
|
||||
|
||||
1. Step 1
|
||||
2. Step 2
|
||||
3. ...
|
||||
|
||||
### Expected Behavior
|
||||
|
||||
<!-- Describe what you expected to happen. -->
|
||||
|
||||
### Actual Behavior
|
||||
|
||||
<!-- Describe what actually happened. Include any error messages, stack traces, or unexpected behavior. -->
|
||||
|
||||
### Screenshots / Logs (if applicable)
|
||||
|
||||
<!-- If relevant, include screenshots or logs that help illustrate the issue. -->
|
||||
|
||||
### GraphRAG Configuration
|
||||
|
||||
<!-- Include the GraphRAG configuration used for this run. -->
|
||||
|
||||
### Additional Information
|
||||
|
||||
<!-- Include any additional information that might be helpful, such as specific configurations, data samples, or context about the environment. -->
|
||||
|
||||
### Possible Solution (if you have one)
|
||||
|
||||
<!-- If you have suggestions on how to address the issue, provide them here. -->
|
||||
|
||||
### Is this a Bug or Feature Request?
|
||||
|
||||
<!-- Choose one: Bug | Feature Request -->
|
||||
|
||||
### Any related issues?
|
||||
|
||||
<!-- If this is related to another issue, reference it here. -->
|
||||
|
||||
### Any relevant discussions?
|
||||
|
||||
<!-- If there are any discussions or forum threads related to this issue, provide links. -->
|
||||
|
||||
### Checklist
|
||||
|
||||
<!-- Please check the items that you have completed -->
|
||||
|
||||
- [ ] I have searched for similar issues and didn't find any duplicates.
|
||||
- [ ] I have provided a clear and concise description of the issue.
|
||||
- [ ] I have included the necessary environment details.
|
||||
- [ ] I have outlined the steps to reproduce the issue.
|
||||
- [ ] I have included any relevant logs or screenshots.
|
||||
- [ ] I have included the GraphRAG configuration for this run.
|
||||
- [ ] I have indicated whether this is a bug or a feature request.
|
||||
|
||||
### Additional Comments
|
||||
|
||||
<!-- Any additional comments or context that you think would be helpful. -->
|
4
.github/workflows/python-ci.yml
vendored
4
.github/workflows/python-ci.yml
vendored
@ -84,10 +84,6 @@ jobs:
|
||||
poetry run python -m pip install gensim
|
||||
poetry install
|
||||
|
||||
- name: Check Semversioner
|
||||
run: |
|
||||
poetry run semversioner check
|
||||
|
||||
- name: Check
|
||||
run: |
|
||||
poetry run poe check
|
||||
|
70
.github/workflows/python-notebook-tests.yml
vendored
Normal file
70
.github/workflows/python-notebook-tests.yml
vendored
Normal file
@ -0,0 +1,70 @@
|
||||
name: Python Notebook Tests
|
||||
on:
|
||||
push:
|
||||
branches: [main]
|
||||
pull_request:
|
||||
branches: [main]
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
pull-requests: read
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
# Only run the for the latest commit
|
||||
cancel-in-progress: true
|
||||
|
||||
env:
|
||||
POETRY_VERSION: 1.8.3
|
||||
|
||||
jobs:
|
||||
python-ci:
|
||||
strategy:
|
||||
matrix:
|
||||
python-version: ["3.11"]
|
||||
os: [ubuntu-latest, windows-latest]
|
||||
fail-fast: false # Continue running all jobs even if one fails
|
||||
env:
|
||||
DEBUG: 1
|
||||
GRAPHRAG_API_KEY: ${{ secrets.OPENAI_NOTEBOOK_KEY }}
|
||||
GRAPHRAG_LLM_MODEL: ${{ secrets.GRAPHRAG_LLM_MODEL }}
|
||||
GRAPHRAG_EMBEDDING_MODEL: ${{ secrets.GRAPHRAG_EMBEDDING_MODEL }}
|
||||
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
|
||||
- uses: dorny/paths-filter@v3
|
||||
id: changes
|
||||
with:
|
||||
filters: |
|
||||
python:
|
||||
- 'graphrag/**/*'
|
||||
- 'poetry.lock'
|
||||
- 'pyproject.toml'
|
||||
- '**/*.py'
|
||||
- '**/*.toml'
|
||||
- '**/*.ipynb'
|
||||
- '.github/workflows/python*.yml'
|
||||
|
||||
- name: Set up Python ${{ matrix.python-version }}
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Install Poetry
|
||||
uses: abatilo/actions-poetry@v3.0.0
|
||||
with:
|
||||
poetry-version: $POETRY_VERSION
|
||||
|
||||
- name: Install dependencies
|
||||
shell: bash
|
||||
run: |
|
||||
poetry self add setuptools wheel
|
||||
poetry run python -m pip install gensim
|
||||
poetry install
|
||||
|
||||
|
||||
- name: Notebook Test
|
||||
run: |
|
||||
poetry run poe test_notebook
|
@ -125,6 +125,7 @@ _test_all = "coverage run -m pytest ./tests"
|
||||
test_unit = "pytest ./tests/unit"
|
||||
test_integration = "pytest ./tests/integration"
|
||||
test_smoke = "pytest ./tests/smoke"
|
||||
test_notebook = "pytest ./tests/notebook"
|
||||
index = "python -m graphrag.index"
|
||||
query = "python -m graphrag.query"
|
||||
prompt_tune = "python -m graphrag.prompt_tune"
|
||||
|
@ -1,38 +1,33 @@
|
||||
# Copyright (c) 2024 Microsoft Corporation.
|
||||
# Licensed under the MIT License
|
||||
import subprocess
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
import nbformat
|
||||
import pytest
|
||||
|
||||
DOCS_PATH = Path("../../docsite")
|
||||
NOTEBOOKS_PATH = Path("examples_notebooks")
|
||||
|
||||
notebooks_list = list(DOCS_PATH.rglob("*.ipynb"))
|
||||
notebooks_list = list(NOTEBOOKS_PATH.rglob("*.ipynb"))
|
||||
|
||||
|
||||
def _notebook_run(filepath: Path):
|
||||
"""Execute a notebook via nbconvert and collect output.
|
||||
:returns execution errors
|
||||
"""
|
||||
with tempfile.NamedTemporaryFile(suffix=".ipynb") as temp_file:
|
||||
args = [
|
||||
"jupyter",
|
||||
"nbconvert",
|
||||
"--to",
|
||||
"notebook",
|
||||
"--execute",
|
||||
"-y",
|
||||
"--no-prompt",
|
||||
"--output",
|
||||
temp_file.name,
|
||||
filepath.absolute().as_posix(),
|
||||
]
|
||||
subprocess.check_call(args)
|
||||
|
||||
temp_file.seek(0)
|
||||
nb = nbformat.read(temp_file, nbformat.current_nbformat)
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user