From 345979b9f04801354e1b70fde1b6fdfaaa7344a3 Mon Sep 17 00:00:00 2001 From: vsyrgkanis Date: Sun, 21 Jul 2024 23:30:34 -0700 Subject: [PATCH] Testing stripping --- .github/workflows/strip-python-notebooks.yml | 20 +++++++++++++----- PM1/python-linear-model-overfitting.ipynb | 22 +++++++++++++++++--- PM1/r-linear-model-overfitting.irnb | 4 +++- 3 files changed, 37 insertions(+), 9 deletions(-) diff --git a/.github/workflows/strip-python-notebooks.yml b/.github/workflows/strip-python-notebooks.yml index cc9c63cb..b50100ef 100644 --- a/.github/workflows/strip-python-notebooks.yml +++ b/.github/workflows/strip-python-notebooks.yml @@ -1,14 +1,14 @@ -name: Strip Python Jupyter Notebooks from Outputs +name: Strip Python and R Notebooks from Outputs on: push: concurrency: - group: strip-python-notebooks-${{ github.ref }} + group: strip-notebooks-${{ github.ref }} cancel-in-progress: true jobs: - strip-python-notebooks: + strip-notebooks: runs-on: ubuntu-latest steps: @@ -43,6 +43,16 @@ jobs: nbstripout "$notebook" fi done + for notebook in "$dir"/*.irnb; do + # Check if there are any .irnb files + if [ -e "$notebook" ]; then + echo "Stripping output from notebook: $notebook" + ipynb_notebook="${notebook%.irnb}.ipynb" + mv "$notebook" "$ipynb_notebook" + nbstripout "$ipynb_notebook" + mv "$ipynb_notebook" "$notebook" + fi + done else echo "Directory $dir does not exist." fi @@ -56,7 +66,7 @@ jobs: # Check if directory exists if [ -d "$dir" ]; then echo "Processing directory: $dir" - if git diff --quiet "$dir"/*.ipynb; then + if git diff --quiet "$dir"/*.ipynb "$dir"/*.irnb; then echo "changed=true" >> $GITHUB_OUTPUT break 1 fi @@ -75,7 +85,7 @@ jobs: # Check if directory exists if [ -d "$dir" ]; then echo "Adding changed files from directory: $dir" - git add "$dir"/*.ipynb + git add "$dir"/*.ipynb "$dir"/*.irnb else echo "Directory $dir does not exist." fi diff --git a/PM1/python-linear-model-overfitting.ipynb b/PM1/python-linear-model-overfitting.ipynb index 424560c0..050258b2 100644 --- a/PM1/python-linear-model-overfitting.ipynb +++ b/PM1/python-linear-model-overfitting.ipynb @@ -21,7 +21,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 5, "metadata": { "id": "YTaOmenI7TfT" }, @@ -44,7 +44,7 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 6, "metadata": { "id": "C57WYtYM7OL0", "papermill": { @@ -56,7 +56,23 @@ }, "tags": [] }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "p/n is: 1.0\n", + "R^2 is 1.0\n", + "Adjusted R^2 is nan\n", + "p/n is: 0.5\n", + "R^2 is 0.5232392347513539\n", + "Adjusted R^2 is 0.04647846950270784\n", + "p/n is: 0.05\n", + "R^2 is 0.05610356497156044\n", + "Adjusted R^2 is 0.006424805233221531\n" + ] + } + ], "source": [ "regression_stats(1000, 1000)\n", "regression_stats(1000, 500)\n", diff --git a/PM1/r-linear-model-overfitting.irnb b/PM1/r-linear-model-overfitting.irnb index 60d7aafc..5385e5f8 100644 --- a/PM1/r-linear-model-overfitting.irnb +++ b/PM1/r-linear-model-overfitting.irnb @@ -65,7 +65,9 @@ "languageId": "r" } }, - "outputs": [], + "outputs": [ + "text": ["asdfas\n"] + ], "source": [ "\n", "set.seed(123)\n",