Skip to content

Commit

Permalink
Notebook lint (#135)
Browse files Browse the repository at this point in the history
* add colab and download links to notebooks

* strip unnecessary output from cells

this removes output from cells not marked `keep_output`

* use find and awk
  • Loading branch information
bjchambers authored Feb 7, 2025
1 parent 4416bb0 commit 71893fd
Show file tree
Hide file tree
Showing 7 changed files with 83 additions and 324 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ jobs:
# Runs this as long as setup succeeds.
if: ${{ !cancelled() && steps.setup.conclusion == 'success' }}

- name: Run `nbstripout-check`
run: uv run poe nbstripout-check
# Runs this as long as setup succeeds.
if: ${{ !cancelled() && steps.setup.conclusion == 'success' }}

tests-and-type-check:
runs-on: ubuntu-latest
strategy:
Expand Down
355 changes: 31 additions & 324 deletions docs/examples/lazy-graph-rag.ipynb

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions docs/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
}
.green {
color: #228B22;
}
.colab {
color: #F9AB00;
}
1 change: 1 addition & 0 deletions mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ plugins:
- search
- blog
- mkdocs-jupyter:
include_source: True
remove_tag_config:
remove_input_tags: ["hide_code"]
remove_cell_tags: ["hide_cell"]
Expand Down
20 changes: 20 additions & 0 deletions overrides/main.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<!-- See https://squidfunk.github.io/mkdocs-material/customization/#overriding-blocks -->

{% extends "base.html" %}

{% block content %}
{% if page.nb_url %}
<a href="{{ page.nb_url }}" title="Download Notebook" class="md-content__button md-icon">
<span class="twemoji">
{% include ".icons/material/download.svg" %}
</span>
</a>
<a href="https://colab.research.google.com/github/datastax/graph-rag/blob/main/docs/{{ page.file.src_uri}}" title="Open in Colab" class="md-content__button md-icon">
<span class="twemoji colab">
{% include ".icons/simple/googlecolab.svg" %}
</span>
</a>
{% endif %}

{{ super() }}
{% endblock content %}
9 changes: 9 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ dev = [
"pytest-cov>=4.0.0",
"pytest-asyncio>=0.25.2",
"poethepoet>=0.32.1",
"nbstripout>=0.8.1",
]

docs = [
Expand Down Expand Up @@ -136,6 +137,14 @@ sequence = [
{cmd = "uvx ${DEPTRY} src tests", cwd = "packages/graph-rag-example-helpers"},
]

[tool.poe.tasks.nbstripout]
help = "Runs `nbstripout` to remove output"
shell = "find . -name '*.ipynb' | awk 'system(\"git check-ignore --quiet \" $0)' | xargs nbstripout"

[tool.poe.tasks.nbstripout-check]
help = "Runs `nbstripout` to remove output"
shell = "find . -name '*.ipynb' | awk 'system(\"git check-ignore --quiet \" $0)' | xargs nbstripout --verify"

[tool.poe.tasks.lint]
help = "Runs all formatting, lints, and checks (fixing where possible)"
sequence = [ "lock-fix", "fmt-fix", "lint-fix", "type-check", "dep-check"]
Expand Down
14 changes: 14 additions & 0 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 71893fd

Please sign in to comment.