From 38e7677e433a6840fe576e50b13ae36ca3924ee9 Mon Sep 17 00:00:00 2001 From: Paolo Bonetti Date: Wed, 9 Oct 2024 16:16:57 +0200 Subject: [PATCH] fixing tests? --- .github/workflows/main.yml | 8 +- notebooks/first_test.ipynb | 164 +++++++++++++++++++++++++--- shearwater/processes/wps_cyclone.py | 6 +- 3 files changed, 153 insertions(+), 25 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0b8b031..fe96110 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.9", "3.10", "3.11"] + python-version: ["3.11"] steps: - name: Checkout repository and submodules uses: actions/checkout@v2 @@ -17,7 +17,7 @@ jobs: submodules: recursive - name: Install packages run: | - sudo apt-get -y install pandoc + sudo apt-get -y install pandoc metview - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: @@ -32,8 +32,8 @@ jobs: run: make test - name: Lint with flake8 ⚙️ run: make lint - if: matrix.python-version == 3.9 + if: matrix.python-version == 3.11 - name: Build docs 🏗️ run: make docs - if: matrix.python-version == 3.9 + if: matrix.python-version == 3.11 diff --git a/notebooks/first_test.ipynb b/notebooks/first_test.ipynb index 2d0900d..1501e12 100644 --- a/notebooks/first_test.ipynb +++ b/notebooks/first_test.ipynb @@ -10,7 +10,7 @@ "name": "stderr", "output_type": "stream", "text": [ - "2024-10-09 11:54:51.577203: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n", + "2024-10-09 15:31:06.243530: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.\n", "To enable the following instructions: SSE4.1 SSE4.2 AVX AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.\n" ] } @@ -64,29 +64,157 @@ "name": "stdout", "output_type": "stream", "text": [ - "\n" + "1\n", + "2\n", + "3\n", + "4\n", + "5\n", + "6\n", + "7\n", + "8\n", + "9\n", + "10\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/fb83d6d6-8642-11ef-a4d8-080038c050cd/tcactivity_48_17_20220110_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/fb83d6d6-8642-11ef-a4d8-080038c050cd/tcactivity_48_17_20220110_lag0_Sindian.1.png'\n", + ")\n", + "11\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/ffc3a302-8642-11ef-a0b8-080038c050cd/tcactivity_48_17_20220111_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/ffc3a302-8642-11ef-a0b8-080038c050cd/tcactivity_48_17_20220111_lag0_Sindian.1.png'\n", + ")\n", + "12\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/03fc9e92-8643-11ef-b827-080038c050cd/tcactivity_48_17_20220112_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/03fc9e92-8643-11ef-b827-080038c050cd/tcactivity_48_17_20220112_lag0_Sindian.1.png'\n", + ")\n", + "13\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/086ee818-8643-11ef-b346-080038c050cd/tcactivity_48_17_20220113_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/086ee818-8643-11ef-b346-080038c050cd/tcactivity_48_17_20220113_lag0_Sindian.1.png'\n", + ")\n", + "14\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/0cebfd68-8643-11ef-9b64-080038c050cd/tcactivity_48_17_20220114_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/0cebfd68-8643-11ef-9b64-080038c050cd/tcactivity_48_17_20220114_lag0_Sindian.1.png'\n", + ")\n", + "15\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/11572d82-8643-11ef-b903-080038c050cd/tcactivity_48_17_20220115_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/11572d82-8643-11ef-b903-080038c050cd/tcactivity_48_17_20220115_lag0_Sindian.1.png'\n", + ")\n", + "16\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/15b228f0-8643-11ef-aca6-080038c050cd/tcactivity_48_17_20220116_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/15b228f0-8643-11ef-aca6-080038c050cd/tcactivity_48_17_20220116_lag0_Sindian.1.png'\n", + ")\n", + "17\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/1a1d0d24-8643-11ef-8eb5-080038c050cd/tcactivity_48_17_20220117_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/1a1d0d24-8643-11ef-8eb5-080038c050cd/tcactivity_48_17_20220117_lag0_Sindian.1.png'\n", + ")\n", + "18\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/1e73d948-8643-11ef-9f86-080038c050cd/tcactivity_48_17_20220118_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/1e73d948-8643-11ef-9f86-080038c050cd/tcactivity_48_17_20220118_lag0_Sindian.1.png'\n", + ")\n", + "19\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/22c023b2-8643-11ef-8a42-080038c050cd/tcactivity_48_17_20220119_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/22c023b2-8643-11ef-8a42-080038c050cd/tcactivity_48_17_20220119_lag0_Sindian.1.png'\n", + ")\n", + "20\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/27506478-8643-11ef-b0e5-080038c050cd/tcactivity_48_17_20220120_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/27506478-8643-11ef-b0e5-080038c050cd/tcactivity_48_17_20220120_lag0_Sindian.1.png'\n", + ")\n", + "21\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/2ba0bfbe-8643-11ef-88e1-080038c050cd/tcactivity_48_17_20220121_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/2ba0bfbe-8643-11ef-88e1-080038c050cd/tcactivity_48_17_20220121_lag0_Sindian.1.png'\n", + ")\n", + "22\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/2ff22792-8643-11ef-9947-080038c050cd/tcactivity_48_17_20220122_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/2ff22792-8643-11ef-9947-080038c050cd/tcactivity_48_17_20220122_lag0_Sindian.1.png'\n", + ")\n", + "23\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/345a6380-8643-11ef-88de-080038c050cd/tcactivity_48_17_20220123_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/345a6380-8643-11ef-88de-080038c050cd/tcactivity_48_17_20220123_lag0_Sindian.1.png'\n", + ")\n", + "24\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/38a8d9bc-8643-11ef-bf44-080038c050cd/tcactivity_48_17_20220124_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/38a8d9bc-8643-11ef-bf44-080038c050cd/tcactivity_48_17_20220124_lag0_Sindian.1.png'\n", + ")\n", + "25\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/3cf6da00-8643-11ef-a8fd-080038c050cd/tcactivity_48_17_20220125_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/3cf6da00-8643-11ef-a8fd-080038c050cd/tcactivity_48_17_20220125_lag0_Sindian.1.png'\n", + ")\n", + "26\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/414032e6-8643-11ef-9229-080038c050cd/tcactivity_48_17_20220126_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/414032e6-8643-11ef-9229-080038c050cd/tcactivity_48_17_20220126_lag0_Sindian.1.png'\n", + ")\n", + "27\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/458f8b1c-8643-11ef-acce-080038c050cd/tcactivity_48_17_20220127_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/458f8b1c-8643-11ef-acce-080038c050cd/tcactivity_48_17_20220127_lag0_Sindian.1.png'\n", + ")\n", + "28\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/49e9ace2-8643-11ef-8108-080038c050cd/tcactivity_48_17_20220128_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/49e9ace2-8643-11ef-8108-080038c050cd/tcactivity_48_17_20220128_lag0_Sindian.1.png'\n", + ")\n", + "29\n", + "\n", + "cycloneResponse(\n", + " output_csv='http://localhost:5000/outputs/4e399794-8643-11ef-b50c-080038c050cd/tcactivity_48_17_20220129_lag0_Sindian.csv',\n", + " output_png='http://localhost:5000/outputs/4e399794-8643-11ef-b50c-080038c050cd/tcactivity_48_17_20220129_lag0_Sindian.1.png'\n", + ")\n" ] - }, - { - "data": { - "text/plain": [ - "cycloneResponse(\n", - " output_csv='http://localhost:5000/outputs/a84d05c8-8624-11ef-a5f3-080038c050cd/tcactivity_48_17_20240217_lag0_Sindian.csv',\n", - " output_png='http://localhost:5000/outputs/a84d05c8-8624-11ef-a5f3-080038c050cd/tcactivity_48_17_20240217_lag0_Sindian.1.png'\n", - ")" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" } ], "source": [ - "resp = wps.cyclone(init_date=\"2024-02-17\", leadtime=\"0-48 h\", region=\"Southern Indian\")\n", - "print(resp)\n", - "resp.get()" + "for day in range(1,30):\n", + " print(day)\n", + " if day<10:\n", + " resp = wps.cyclone(init_date=f\"2022-01-0{day}\", leadtime=\"0-48 h\", region=\"Southern Indian\")\n", + " else:\n", + " resp = wps.cyclone(init_date=f\"2022-01-{day}\", leadtime=\"0-48 h\", region=\"Southern Indian\")\n", + " print(resp)\n", + " print(resp.get())\n" ] }, + { + "cell_type": "code", + "execution_count": null, + "id": "321eae5a-97fc-47b6-b3d2-355326213ffa", + "metadata": {}, + "outputs": [], + "source": [] + }, { "cell_type": "code", "execution_count": 4, diff --git a/shearwater/processes/wps_cyclone.py b/shearwater/processes/wps_cyclone.py index 1e98e6a..6784bf1 100644 --- a/shearwater/processes/wps_cyclone.py +++ b/shearwater/processes/wps_cyclone.py @@ -112,10 +112,10 @@ def __init__(self): def _handler(self, request, response): LOGGER.info("running cyclone ...") # TODO: lazy load tensorflow ... issues with sphinx doc build - import metview as mv from tensorflow.keras import models init_date = request.inputs['init_date'][0].data + leadtime = request.inputs['leadtime'][0].data region = request.inputs['region'][0].data @@ -162,9 +162,9 @@ def _handler(self, request, response): data = pd.DataFrame() for param1 in parameters: - path = f'/pool/data/ERA5/ET/{"sf" if param1[2]==[0] else "pl"}/an/1D/{str(param1[0]).zfill(3)}' + path = f'/pool/data/ERA5/E5/{"sf" if param1[2]==[0] else "pl"}/an/1D/{str(param1[0]).zfill(3)}' fs1_param = mv.read( - f"{path}/ET{'sf' if param1[2]==[0] else 'pl'}00_1D_{init_date[:7]}_{str(param1[0]).zfill(3)}.grb" + f"{path}/E5{'sf' if param1[2]==[0] else 'pl'}00_1D_{init_date[:7]}_{str(param1[0]).zfill(3)}.grb" ) fs1_param = fs1_param.select( date=init_date.replace("-", ""), level=param1[2]