Skip to content

Commit

Permalink
fixing tests?
Browse files Browse the repository at this point in the history
  • Loading branch information
Paolo Bonetti committed Oct 9, 2024
1 parent aa43f0e commit 38e7677
Show file tree
Hide file tree
Showing 3 changed files with 153 additions and 25 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ 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
with:
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:
Expand All @@ -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

164 changes: 146 additions & 18 deletions notebooks/first_test.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -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"
]
}
Expand Down Expand Up @@ -64,29 +64,157 @@
"name": "stdout",
"output_type": "stream",
"text": [
"<birdy.client.utils.WPSExecution object at 0x7fff67db5a10>\n"
"1\n",
"2\n",
"3\n",
"4\n",
"5\n",
"6\n",
"7\n",
"8\n",
"9\n",
"10\n",
"<birdy.client.utils.WPSExecution object at 0x7fffd64dde50>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67dadf10>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67dae810>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67dafc90>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67dae510>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67dad890>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67dafcd0>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67dae850>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67daf310>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67de4910>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67de7f50>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67de7490>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67de4210>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67da7bd0>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67da5d90>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67da7c50>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67da4390>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67de5450>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67da5910>\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",
"<birdy.client.utils.WPSExecution object at 0x7fff67d84f10>\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,
Expand Down
6 changes: 3 additions & 3 deletions shearwater/processes/wps_cyclone.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 38e7677

Please sign in to comment.