Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

documentation: allow marimo notebooks as documentation #2787

Merged
merged 11 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci-notebooks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ jobs:
run: |
# mlir_interoperation.ipynb is dependent on MLIR, and is tested in the MLIR-enabled workflow.
pytest -W error --nbval -vv docs --ignore=docs/mlir_interoperation.ipynb
- name: Test marimo notebooks
run: |
make tests-marimo
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ repos:
rev: 24.2.0
hooks:
- id: black
exclude: "/(__pycache__|.asv|venv|build|tests/filecheck)/|versioneer.py$|xdsl/_version.py$"
exclude: "/(__pycache__|.asv|venv|build|tests/filecheck)/|versioneer.py$|xdsl/_version.py$|docs/marimo"
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ TESTS_COVERAGE_FILE = ${COVERAGE_FILE}.tests
.ONESHELL:

# these targets don't produce files:
.PHONY: ${VENV_DIR}/ venv clean filecheck pytest pytest-nb tests-toy tests rerun-notebooks precommit-install precommit black pyright
.PHONY: ${VENV_DIR}/ venv clean filecheck pytest pytest-nb tests-toy tests rerun-notebooks precommit-install precommit black pyright tests-marimo
.PHONY: coverage coverage-tests coverage-filecheck-tests coverage-report-html coverage-report-md

# set up the venv with all dependencies for development
Expand Down Expand Up @@ -51,8 +51,15 @@ pytest-toy:

tests-toy: filecheck-toy pytest-toy

tests-marimo:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be marked PHONY?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

defo

@for file in docs/marimo/*.py; do \
echo "Running $$file"; \
python3 "$$file" || exit 1; \
done
@echo "All marimo tests passed successfully."

# run all tests
tests: pytest tests-toy filecheck pytest-nb pyright
tests: pytest tests-toy filecheck pytest-nb tests-marimo pyright
@echo All tests done.

# re-generate the output from all jupyter notebooks in the docs directory
Expand Down
27 changes: 27 additions & 0 deletions docs/marimo/IR_Chapter_1_Attributes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import marimo

__generated_with = "0.6.10"
app = marimo.App()


@app.cell
def __():
import marimo as mo
return mo,


@app.cell
def __(mo):
from xdsl.dialects.builtin import IntAttr

mo.md(f"""
# IR Chapter 1: Attributes

In xDSL, Attributes carry information known at compile time.
For example, `{IntAttr.__name__}` is an attribute representing an integer.
""")
return IntAttr,


if __name__ == "__main__":
app.run()
3 changes: 3 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ dev = [
"nbval<0.12",
"filecheck<0.0.25",
"lit<19.0.0",
"marimo==0.6.10",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that this is a new dev dependency

"pre-commit==3.7.1",
"ruff==0.4.10",
"asv<0.7",
Expand Down Expand Up @@ -81,6 +82,7 @@ typeCheckingMode = "strict"
"xdsl/interpreters/onnx.py",
]
"ignore" = [
"docs/marimo",
"tests/filecheck/frontend/dialects/builtin.py",
"tests/filecheck/frontend/dialects/invalid.py",
"tests/filecheck/frontend/dialects/arith.py",
Expand Down Expand Up @@ -136,6 +138,7 @@ exclude = """
/(__pycache__|.asv|venv|build|tests/filecheck)/
|versioneer.py$
|xdsl/_version.py$
|docs/marimo
"""

[tool.pytest.ini_options]
Expand Down
Loading