From 349444bf7d8f5bd38b8e7f4fae2a418a13f9d9a0 Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Wed, 12 Jun 2024 20:25:22 +0200 Subject: [PATCH 1/7] fix for ci examples not throwing error from some commands --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 84f8a9ccb..6a62a0b71 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -305,6 +305,7 @@ deps = extras = docs changedir = {tox_root}{/}docs commands = + set -Eeuo pipefail python -m ipykernel install --user --name=moscot bash -c "for nb in notebooks/examples/plotting/*.ipynb notebooks/examples/problems/*ipynb notebooks/examples/solvers/*ipynb; do echo Running $nb; jupytext -k moscot --execute $nb; done" From cab0d9ef388609bf07495bd402802ad99a8feecd Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Wed, 12 Jun 2024 20:27:13 +0200 Subject: [PATCH 2/7] more fault tolerant --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 6a62a0b71..720055640 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -305,7 +305,7 @@ deps = extras = docs changedir = {tox_root}{/}docs commands = - set -Eeuo pipefail + set -e python -m ipykernel install --user --name=moscot bash -c "for nb in notebooks/examples/plotting/*.ipynb notebooks/examples/problems/*ipynb notebooks/examples/solvers/*ipynb; do echo Running $nb; jupytext -k moscot --execute $nb; done" From fdb02da1cb3d8c1f5cf03c3cd643b54a0dee661d Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Wed, 12 Jun 2024 20:45:17 +0200 Subject: [PATCH 3/7] make an explicit script --- .run_notebooks.sh | 20 ++++++++++++++++++++ pyproject.toml | 4 +--- 2 files changed, 21 insertions(+), 3 deletions(-) create mode 100644 .run_notebooks.sh diff --git a/.run_notebooks.sh b/.run_notebooks.sh new file mode 100644 index 000000000..2edfc7ced --- /dev/null +++ b/.run_notebooks.sh @@ -0,0 +1,20 @@ +# Initialize a flag to track the success of all commands +all_success=true + +# Loop through all provided notebook paths +for nb in "$@"; do + echo "Running $nb" + # Execute the notebook and handle potential failures + jupytext -k moscot --execute "$nb" || { + echo "Failed to run $nb" + all_success=false + } +done + +# Check if any executions failed +if [ "$all_success" = false ]; then + echo "One or more notebooks failed to execute." + exit 1 +fi + +echo "All notebooks executed successfully." \ No newline at end of file diff --git a/pyproject.toml b/pyproject.toml index 720055640..9e3e8977e 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -303,11 +303,9 @@ deps = nbconvert leidenalg extras = docs -changedir = {tox_root}{/}docs commands = - set -e python -m ipykernel install --user --name=moscot - bash -c "for nb in notebooks/examples/plotting/*.ipynb notebooks/examples/problems/*ipynb notebooks/examples/solvers/*ipynb; do echo Running $nb; jupytext -k moscot --execute $nb; done" + bash {tox_root}/.run_notebooks.sh {tox_root}{/}docs/notebooks/examples/plotting/*.ipynb {tox_root}{/}docs/notebooks/examples/problems/*ipynb {tox_root}{/}docs/notebooks/examples/solvers/*ipynb [testenv:clean-docs] From a58c5f719c519c26a2465a6886426ae703c4d135 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 18:45:58 +0000 Subject: [PATCH 4/7] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .run_notebooks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.run_notebooks.sh b/.run_notebooks.sh index 2edfc7ced..0975a0986 100644 --- a/.run_notebooks.sh +++ b/.run_notebooks.sh @@ -17,4 +17,4 @@ if [ "$all_success" = false ]; then exit 1 fi -echo "All notebooks executed successfully." \ No newline at end of file +echo "All notebooks executed successfully." From d5d541bbb874bb2879fe3da31283dc3b9dc2398c Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Wed, 12 Jun 2024 21:19:28 +0200 Subject: [PATCH 5/7] update script and .toml, also added tutorials --- .run_notebooks.sh | 49 ++++++++++++++++++++++++++++++++++++++++++++--- pyproject.toml | 6 ++++-- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/.run_notebooks.sh b/.run_notebooks.sh index 0975a0986..aae91d521 100644 --- a/.run_notebooks.sh +++ b/.run_notebooks.sh @@ -1,10 +1,53 @@ +#!/bin/bash + +# Check if the base directory is provided as an argument +if [ "$#" -ne 1 ]; then + echo "Usage: $0 " + exit 1 +fi + +# Base directory for notebooks +base_dir=$1 + +# Define notebook directories or patterns +declare -a notebooks=( + # "$base_dir/examples/plotting/*.ipynb" + # "$base_dir/examples/problems/*.ipynb" + # "$base_dir/examples/solvers/*.ipynb" + "$base_dir/tutorials/*.ipynb" +) + +# Initialize an array to hold valid notebook paths +declare -a valid_notebooks + +# Gather all valid notebook files from the patterns +echo "Gathering notebooks..." +for pattern in "${notebooks[@]}"; do + for nb in $pattern; do + if [[ -f "$nb" ]]; then # Check if the file exists + valid_notebooks+=("$nb") # Add to the list of valid notebooks + fi + done +done + +# Check if we have any notebooks to run +if [ ${#valid_notebooks[@]} -eq 0 ]; then + echo "No notebooks found to run." + exit 1 +fi + +# Echo the notebooks that will be run for clarity +echo "Preparing to run the following notebooks:" +for nb in "${valid_notebooks[@]}"; do + echo "$nb" +done + # Initialize a flag to track the success of all commands all_success=true -# Loop through all provided notebook paths -for nb in "$@"; do +# Execute all valid notebooks +for nb in "${valid_notebooks[@]}"; do echo "Running $nb" - # Execute the notebook and handle potential failures jupytext -k moscot --execute "$nb" || { echo "Failed to run $nb" all_success=false diff --git a/pyproject.toml b/pyproject.toml index 9e3e8977e..3d70d9697 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -302,11 +302,13 @@ deps = jupytext nbconvert leidenalg + squidpy + pot extras = docs +changedir = {tox_root}{/}docs commands = python -m ipykernel install --user --name=moscot - bash {tox_root}/.run_notebooks.sh {tox_root}{/}docs/notebooks/examples/plotting/*.ipynb {tox_root}{/}docs/notebooks/examples/problems/*ipynb {tox_root}{/}docs/notebooks/examples/solvers/*ipynb - + bash {tox_root}/.run_notebooks.sh {tox_root}{/}docs/notebooks [testenv:clean-docs] description = Remove the documentation. From 2b3940bb0bb62b50d03a70c95055a0a5d3ea4c13 Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Wed, 12 Jun 2024 21:22:02 +0200 Subject: [PATCH 6/7] fix debug state --- .run_notebooks.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.run_notebooks.sh b/.run_notebooks.sh index aae91d521..591048d5a 100644 --- a/.run_notebooks.sh +++ b/.run_notebooks.sh @@ -11,9 +11,9 @@ base_dir=$1 # Define notebook directories or patterns declare -a notebooks=( - # "$base_dir/examples/plotting/*.ipynb" - # "$base_dir/examples/problems/*.ipynb" - # "$base_dir/examples/solvers/*.ipynb" + "$base_dir/examples/plotting/*.ipynb" + "$base_dir/examples/problems/*.ipynb" + "$base_dir/examples/solvers/*.ipynb" "$base_dir/tutorials/*.ipynb" ) From d54060a83de43d779ac50e0125021f2904513e4d Mon Sep 17 00:00:00 2001 From: selmanozleyen Date: Fri, 14 Jun 2024 10:20:21 +0200 Subject: [PATCH 7/7] remove tutorials --- .run_notebooks.sh | 1 - pyproject.toml | 2 -- 2 files changed, 3 deletions(-) diff --git a/.run_notebooks.sh b/.run_notebooks.sh index 591048d5a..4db60efb9 100644 --- a/.run_notebooks.sh +++ b/.run_notebooks.sh @@ -14,7 +14,6 @@ declare -a notebooks=( "$base_dir/examples/plotting/*.ipynb" "$base_dir/examples/problems/*.ipynb" "$base_dir/examples/solvers/*.ipynb" - "$base_dir/tutorials/*.ipynb" ) # Initialize an array to hold valid notebook paths diff --git a/pyproject.toml b/pyproject.toml index 3d70d9697..2622a31bb 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -302,8 +302,6 @@ deps = jupytext nbconvert leidenalg - squidpy - pot extras = docs changedir = {tox_root}{/}docs commands =