-
Notifications
You must be signed in to change notification settings - Fork 753
uvx marimo convert for a first notebook #75
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
Open
tschm
wants to merge
13
commits into
intro-stat-learning:main
Choose a base branch
from
tschm:patch-5
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
683f99e
Create .gitkeep in marimo folder
tschm 5fc9de1
a first notebook for marimo
tschm 28d3317
a first notebook
tschm 4a67183
.gitkeep no longer needed
tschm 799bc26
Add GitHub Actions workflow to test Marimo notebooks
tschm 61b7a14
Update rhiza_marimo.yml
tschm 53002af
Remove unused Git authentication step from Marimo workflow
tschm 2433704
script header for uv run with dependencies and requirements
tschm 0a429f2
script header for uv run with dependencies and requirements
tschm 360e1ea
Install ISLP library
tschm 8cd0096
Install ISLP library
tschm 5bf79e5
Remove unused imports and streamline function arguments in Ch03-linre…
tschm 29a7f7e
Remove unused dependencies and reorder imports in Ch03-linreg-lab.py
tschm File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,100 @@ | ||
| # This file is part of the jebel-quant/rhiza repository | ||
| # (https://github.com/jebel-quant/rhiza). | ||
| # | ||
| # Workflow: Marimo Notebooks | ||
| # | ||
| # Purpose: This workflow discovers and executes all Marimo notebooks in the | ||
| # repository. It builds a dynamic matrix to run each notebook in | ||
| # parallel to surface errors early and keep notebooks reproducible. | ||
| # | ||
| # Trigger: This workflow runs on every push and on pull requests to main/master | ||
| # branches (including from forks) | ||
| # | ||
| # Components: | ||
| # - 🔎 Discover notebooks in book/marimo | ||
| # - 🧪 Run each notebook in parallel using a matrix strategy | ||
| # - ✅ Fail-fast disabled to report all failing notebooks | ||
|
|
||
| name: "(RHIZA) MARIMO" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| on: | ||
| push | ||
|
|
||
| jobs: | ||
| # Build a matrix of notebooks to test | ||
| list-notebooks: | ||
| runs-on: ubuntu-latest | ||
| outputs: | ||
| notebook-list: ${{ steps.notebooks.outputs.matrix }} | ||
| steps: | ||
| # Check out the repository code | ||
| - uses: actions/checkout@v6.0.2 | ||
|
|
||
| # Find all Python files in the marimo folder and create a matrix for parallel execution | ||
| - name: Find notebooks and build matrix | ||
| id: notebooks | ||
| run: | | ||
| # Extract MARIMO_FOLDER from the project configuration (via Makefile) | ||
| # shellcheck disable=SC2016 # Single quotes intentional - Make syntax, not shell expansion | ||
| NOTEBOOK_DIR=$(make -s -f Makefile -f - <<< 'print: ; @echo $(or $(MARIMO_FOLDER),marimo)' print) | ||
|
|
||
| echo "Searching notebooks in: $NOTEBOOK_DIR" | ||
| # Check if directory exists | ||
| if [ ! -d "$NOTEBOOK_DIR" ]; then | ||
| echo "Directory $NOTEBOOK_DIR does not exist. Setting empty matrix." | ||
| echo "matrix=[]" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Find notebooks and handle empty results | ||
| if [ -z "$(find "$NOTEBOOK_DIR" -maxdepth 1 -name "*.py" 2>/dev/null)" ]; then | ||
| echo "No notebooks found in $NOTEBOOK_DIR. Setting empty matrix." | ||
| echo "matrix=[]" >> "$GITHUB_OUTPUT" | ||
| else | ||
| notebooks=$(find "$NOTEBOOK_DIR" -maxdepth 1 -name "*.py" -print0 | xargs -0 -n1 echo | jq -R -s -c 'split("\n")[:-1]') | ||
| echo "matrix=$notebooks" >> "$GITHUB_OUTPUT" | ||
| fi | ||
| shell: bash | ||
|
|
||
| # Create one job per notebook using the matrix strategy for parallel execution | ||
| test-notebooks: | ||
| if: needs.list-notebooks.outputs.notebook-list != '[]' | ||
| runs-on: ubuntu-latest | ||
| needs: list-notebooks | ||
| strategy: | ||
| matrix: | ||
| notebook: ${{ fromJson(needs.list-notebooks.outputs.notebook-list) }} | ||
| # Don't fail the entire workflow if one notebook fails | ||
| fail-fast: false | ||
| name: Run notebook ${{ matrix.notebook }} | ||
| steps: | ||
| # Check out the repository code | ||
| - uses: actions/checkout@v6.0.2 | ||
| with: | ||
| lfs: true | ||
|
|
||
| # Install uv/uvx | ||
| - name: Install uv | ||
| uses: astral-sh/setup-uv@v7.2.1 | ||
| with: | ||
| version: "0.9.28" | ||
|
|
||
| # Execute the notebook with the appropriate runner based on its content | ||
| - name: Run notebook | ||
| env: | ||
| UV_EXTRA_INDEX_URL: ${{ secrets.UV_EXTRA_INDEX_URL }} | ||
| run: | | ||
| uvx uv run "${{ matrix.notebook }}" | ||
| # uvx → creates a fresh ephemeral environment | ||
| # uv run → runs the notebook as a script in that ephemeral env | ||
| # No project packages are pre-installed | ||
| # ✅ This forces the notebook to explicitly handle dependencies (e.g., uv install ., or pip install inside the script). | ||
| # ✅ It’s a true integration smoke test. | ||
| # Benefits of this pattern | ||
| # Confirms the notebook can bootstrap itself in a fresh environment | ||
| # Catches missing uv install or pip steps early | ||
| # Ensures CI/other users can run the notebook without manual setup | ||
| shell: bash | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still think it's overkill to do this on push -- manual trigger seems more reasonable. Any change to the lab source should be tested prior to pushing. Maybe on creating a tag?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Creating a tag should be very restricted. Only you should have that power. Given a few students work with your notebooks, you may want to expose 'make test' and something smart during ci/cd, e.g. testing only notebooks that have been changed.