diff --git a/.github/workflows/JupyterTest.yml b/.github/workflows/JupyterTest.yml index 34bc73f..ed9c715 100644 --- a/.github/workflows/JupyterTest.yml +++ b/.github/workflows/JupyterTest.yml @@ -10,8 +10,11 @@ on: jobs: build: - runs-on: windows-latest - + runs-on: ubuntu-latest + strategy: + matrix: + python-version: ["3.9", "3.10", "3.11", "3.12"] + steps: - name: Checkout repository uses: actions/checkout@v3 @@ -19,33 +22,38 @@ jobs: - name: Set up Python uses: actions/setup-python@v3 with: - python-version: '3.8' + python-version: ${{ matrix.python-version }} - name: Create data directory if it doesn't exist run: | - mkdir -p data + mkdir -p UnitTest/data - name: Cache data id: cache-data uses: actions/cache@v3 with: path: ./data - key: ${{ runner.os }}-data-${{ hashFiles('testfile.txt') }} + key: ${{ runner.os }}-data-${{ github.run_number }}-${{ hashFiles('testfile.txt') }} restore-keys: | - ${{ runner.os }}-data-2 + ${{ runner.os }}-data-${{ github.run_number }}- - - name: Install dependencies - run: | - pip install jupyter nbconvert tqdm + - name: Set PIPX_HOME to a path without spaces + run: | + export PIPX_HOME=$HOME/.local/pipx + mkdir -p $PIPX_HOME + pip install pipx + pipx install jupyter + pipx runpip jupyter install numpy matplotlib ducc0 healpy - - name: Convert notebook to script + - name: Run notebook directly run: | - jupyter nbconvert --to script UnitTest/NotebookToTest.ipynb + export PIPX_HOME=$HOME/.local/pipx + pipx run jupyter execute UnitTest/NotebookToTest.ipynb - - name: Print converted script + - name: Convert notebook to script to see logs run: | - cat UnitTest/NotebookToTest.py - + jupyter nbconvert --to script UnitTest/NotebookToTest.ipynb + - name: Run converted script run: | python UnitTest/NotebookToTest.py diff --git a/UnitTest/NotebookToTest.ipynb b/UnitTest/NotebookToTest.ipynb index 64c47ec..0325d00 100644 --- a/UnitTest/NotebookToTest.ipynb +++ b/UnitTest/NotebookToTest.ipynb @@ -26,7 +26,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 1, "id": "2292a595", "metadata": {}, "outputs": [ @@ -40,6 +40,7 @@ ], "source": [ "import os\n", + "import numpy\n", "print(os.getcwd())" ] }, @@ -48,21 +49,32 @@ "execution_count": 2, "id": "90bb750c", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "'import urllib.request\\nfrom tqdm import tqdm\\n# Define a progress bar function\\nclass DownloadProgressBar(tqdm):\\n def update_to(self, b=1, bsize=1, tsize=None):\\n if tsize is not None:\\n self.total = tsize\\n self.update(b * bsize - self.n)'" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ - "import urllib.request\n", + "'''import urllib.request\n", "from tqdm import tqdm\n", "# Define a progress bar function\n", "class DownloadProgressBar(tqdm):\n", " def update_to(self, b=1, bsize=1, tsize=None):\n", " if tsize is not None:\n", " self.total = tsize\n", - " self.update(b * bsize - self.n)" + " self.update(b * bsize - self.n)'''" ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 4, "id": "747c02f6", "metadata": {}, "outputs": [ @@ -70,14 +82,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "Could not find cached data\n" - ] - }, - { - "name": "stderr", - "output_type": "stream", - "text": [ - "testfile.txt: 16.4kB [00:00, 35.8kB/s] \n" + "Data is already cached.\n" ] } ], @@ -86,26 +91,18 @@ "if not os.path.exists(data_path):\n", " print(\"Could not find cached data - downloading ...............\")\n", " url = \"https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf\"\n", - " with DownloadProgressBar(unit='B', unit_scale=True, miniters=1, desc=data_path) as t:\n", - " urllib.request.urlretrieve(url, data_path, reporthook=t.update_to)\n", + " #with DownloadProgressBar(unit='B', unit_scale=True, miniters=1, desc=data_path) as t:\n", + " urllib.request.urlretrieve(url, data_path, reporthook=t.update_to)\n", "else:\n", " print(\"Data is already cached.\")" ] }, { "cell_type": "code", - "execution_count": 3, + "execution_count": null, "id": "94ac107d", "metadata": {}, - "outputs": [ - { - "name": "stderr", - "output_type": "stream", - "text": [ - "catalog.fits: 57.3kB [00:01, 53.2kB/s] \n" - ] - } - ], + "outputs": [], "source": [] }, {