Skip to content

Commit 683d41f

Browse files
Merge pull request #359 from killer0071234/forecast-test
First forecast test version
2 parents c57ad47 + 30020cb commit 683d41f

19 files changed

Lines changed: 501 additions & 57 deletions

.devcontainer/devcontainer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"vscode": {
99
"extensions": [
1010
"ms-python.vscode-pylance",
11-
"visualstudioexptteam.vscodeintellicode",
1211
"redhat.vscode-yaml",
1312
"esbenp.prettier-vscode",
1413
"GitHub.vscode-pull-request-github"

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[flake8]
22
max-line-length = 88
3-
ignore = D202,E501,W503
3+
ignore = D202,E203,E501,W503
44
per-file-ignores = tests/*:DAR,S101

.pre-commit-config.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ repos:
1818
rev: 1.7.4
1919
hooks:
2020
- id: bandit
21+
additional_dependencies:
22+
- pbr
2123
args:
2224
- --quiet
2325
- --format=custom
@@ -58,6 +60,12 @@ repos:
5860
files: ^(src|examples|tests)/.+\.py$
5961
- repo: local
6062
hooks:
63+
- id: isort
64+
name: isort
65+
entry: isort
66+
language: system
67+
types: [python]
68+
args: [--profile=black]
6169
- id: black
6270
name: black
6371
entry: black
@@ -70,16 +78,10 @@ repos:
7078
language: system
7179
types: [python]
7280
require_serial: true
73-
- id: reorder-python-imports
74-
name: Reorder python imports
75-
entry: reorder-python-imports
76-
language: system
77-
types: [python]
78-
args: [--application-directories=src]
7981
- id: pytest
8082
name: 🧪 Running tests and test coverage with pytest
8183
language: system
8284
types: [python]
83-
entry: poetry run pytest
85+
entry: bash -c 'poetry run python -m coverage --version >/dev/null 2>&1 && poetry run python -m coverage run -m pytest && poetry run python -m coverage report -m || poetry run pytest'
8486
pass_filenames: false
8587
always_run: true

.vscode/launch.json

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,26 @@
66
"configurations": [
77
{
88
"name":"Python: Current File",
9-
"type":"python",
9+
"type":"debugpy",
1010
"request":"launch",
1111
"module":"${file}",
1212
"console":"integratedTerminal"
1313
},
1414
{
1515
"name": "Python: Run (control.py)",
16-
"type": "python",
16+
"type": "debugpy",
1717
"request": "launch",
1818
"module": "control",
1919
"justMyCode": false,
2020
"args": ["--debug", "-c", "config"]
2121
},
22+
{
23+
"name": "Python: Run (forecast_test.py)",
24+
"type": "debugpy",
25+
"request": "launch",
26+
"module": "forecast_test",
27+
"justMyCode": false,
28+
"args": ["--debug", "-c", "config"]
29+
},
2230
]
2331
}

Dockerfile.dev

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
1-
FROM mcr.microsoft.com/vscode/devcontainers/python:3.11
1+
FROM mcr.microsoft.com/devcontainers/python:3.13
22

33
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
44

55
RUN \
6-
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | apt-key add - \
7-
&& apt-get update \
6+
apt-get update \
87
&& DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends \
98
# Additional library needed by some tests and accordingly by VScode Tests Discovery
109
git \
1110
&& apt-get clean \
1211
&& rm -rf /var/lib/apt/lists/*
1312

14-
WORKDIR /usr/src
15-
1613
WORKDIR /workspaces
1714

1815
# Install Python dependencies from requirements
1916
COPY requirements.txt ./
2017
COPY .github/workflows/constraints.txt ./
21-
RUN pip3 install -r requirements.txt
22-
RUN pip3 install -r constraints.txt
23-
RUN rm -rf requirements.txt
24-
RUN rm -rf constraints.txt
18+
RUN pip3 install -r requirements.txt -c constraints.txt \
19+
&& rm -f requirements.txt constraints.txt
2520

2621
# Set the default shell to bash instead of sh
2722
ENV SHELL /bin/bash

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ async def main():
4242
async with src.zamg.zamg.ZamgData() as zamg:
4343
# option to disable verify of ssl check
4444
zamg.verify_ssl = False
45-
# trying to read zamg station id of the closest station
45+
# trying to read GeoSphere Austria station id of the closest station
4646
data = await zamg.closest_station(46.99, 15.499)
4747
# set closest station as default one to read
4848
zamg.set_default_station(data)
@@ -69,7 +69,7 @@ async def main():
6969
+ str(zamg.get_data(parameter=param, data_type="unit"))
7070
)
7171
print("last update: %s", zamg.last_update)
72-
except (ZamgError) as exc:
72+
except ZamgError as exc:
7373
print(exc)
7474

7575

control.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# pylint: disable=W0621
22
"""Asynchronous Python client for GeoSphere Austria weather data."""
3+
34
import asyncio
45

56
import src.zamg.zamg

examples/read_data.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# pylint: disable=W0621
22
"""Asynchronous Python client for GeoSphere Austria weather data."""
3+
34
import asyncio
45
from os import curdir
56

forecast.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# pylint: disable=W0621
2+
"""Asynchronous Python client for GeoSphere Austria weather data."""
3+
4+
import asyncio
5+
6+
import src.zamg.zamg
7+
from src.zamg.exceptions import ZamgError
8+
9+
10+
async def main():
11+
"""Sample of getting data"""
12+
try:
13+
async with src.zamg.zamg.ZamgData() as zamg:
14+
# option to disable verify of ssl check
15+
zamg.verify_ssl = False
16+
17+
# data = await zamg.zamg_stations()
18+
19+
# print(f"forecast_metadata: {zamg.forecast_metadata}")
20+
# print(f"get_forecast_all_parameters: {zamg.get_forecast_all_parameters()}")
21+
22+
data = await zamg.get_forecast("46.99,15.499", current_only=True)
23+
print(f"get_forecast(current_only=True): {data}")
24+
data = await zamg.get_forecast("46.99,15.499", current_only=False)
25+
print(f"get_forecast(current_only=False): {data}")
26+
27+
return
28+
29+
# trying to read GeoSphere Austria station id of the closest station
30+
data = await zamg.closest_station(46.99, 15.499)
31+
# set closest station as default one to read
32+
zamg.set_default_station(data)
33+
print("closest_station = " + str(zamg.get_station_name) + " / " + str(data))
34+
# print list with all possible parameters
35+
print(f"Possible station parameters: {zamg.get_all_parameters()}")
36+
# set parameters directly
37+
zamg.station_parameters = "TL,SO"
38+
# or set parameters as list
39+
zamg.set_parameters(("TL", "SO"))
40+
# if none of the above parameters are set, all possible parameters are read
41+
# do an update
42+
await zamg.update()
43+
44+
print(f"---------- Weather for station {zamg.get_station_name} ({data})")
45+
for param in zamg.get_parameters():
46+
print(
47+
str(param)
48+
+ " -> "
49+
+ str(zamg.get_data(parameter=param, data_type="name"))
50+
+ " -> "
51+
+ str(zamg.get_data(parameter=param))
52+
+ " "
53+
+ str(zamg.get_data(parameter=param, data_type="unit"))
54+
)
55+
print("last update: %s", zamg.last_update)
56+
except ZamgError as exc:
57+
print(exc)
58+
59+
60+
if __name__ == "__main__":
61+
asyncio.run(main())

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zamg",
3-
"version": "0.3.6",
3+
"version": "0.4.0",
44
"private": true,
55
"description": "Asynchronous Python client for GeoSphere Austria (ZAMG) weather data.",
66
"scripts": {

0 commit comments

Comments
 (0)