Skip to content

Commit

Permalink
fix measurement sdk cache key calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick-zippenfenig committed Jul 30, 2021
1 parent 9c3f3e8 commit 4693f78
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
2 changes: 1 addition & 1 deletion meteoblue_dataset_sdk/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def _parse_measurements(data):

@staticmethod
def _hash_params_measurements(path: str, params: dict) -> str:
return hashlib.md5(path.encode(), json.dumps(params).encode()).hexdigest()
return hashlib.md5(path.encode() + json.dumps(params).encode()).hexdigest()

@asynccontextmanager
async def _query_measurement_api(self, path: str, params: dict):
Expand Down
4 changes: 3 additions & 1 deletion tests/test_measurement_query.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from meteoblue_dataset_sdk import ApiError, Client
from meteoblue_dataset_sdk.protobuf.measurements_pb2 import MeasurementApiProtobuf
from meteoblue_dataset_sdk.caching import FileCache

import asyncio
import logging
Expand Down Expand Up @@ -68,7 +69,8 @@ def test_simple_query(self):
table = "dwdClimateMeasurement10MinuteAirTemperature"
path = f"/rawdata/{provider}/{table}/get"

client = Client(os.environ["APIKEY"])
cache = FileCache()
client = Client(os.environ["APIKEY"], cache=cache)
result = asyncio.run(client.measurement_query(path, query))
rows_per_page = result.rows_per_page
current_page = result.current_page
Expand Down

0 comments on commit 4693f78

Please sign in to comment.