Skip to content

Commit

Permalink
feat(response): assert all timestamps are without time zone
Browse files Browse the repository at this point in the history
because they are always in UTC anyway
closes #103
  • Loading branch information
rp280 authored Nov 29, 2023
1 parent bcf2ad7 commit 927dd15
Show file tree
Hide file tree
Showing 39 changed files with 129 additions and 69 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- start and end timestamp meta information of the client are now datetime objects
- accept shapely Polygon and MultiPolygon for `bpolys` input parameter
- if a request fails a bash script containing the respective `curl` command is logged (if possible). This allows for easier debugging and sharing of failed requests.
- timestamps are converted without timezone information. Deviates from Ohsome API [(Issue #318)](https://github.com/GIScience/ohsome-api/issues/318)

### Changed

Expand Down
16 changes: 8 additions & 8 deletions ohsome/response.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,30 +112,30 @@ def _as_geodataframe(

if "@validFrom" in features.columns:
features["@validFrom"] = pd.to_datetime(
features["@validFrom"], format="%Y-%m-%dT%H:%M:%SZ"
features["@validFrom"].str.replace("Z", ""), format="ISO8601"
)
features["@validTo"] = pd.to_datetime(
features["@validTo"], format="%Y-%m-%dT%H:%M:%SZ"
features["@validTo"].str.replace("Z", ""), format="ISO8601"
)
if multi_index:
features = features.set_index(["@osmId", "@validFrom", "@validTo"])
elif "@snapshotTimestamp" in features.columns:
features["@snapshotTimestamp"] = pd.to_datetime(
features["@snapshotTimestamp"], format="%Y-%m-%dT%H:%M:%SZ"
features["@snapshotTimestamp"].str.replace("Z", ""), format="ISO8601"
)
if multi_index:
features = features.set_index(["@osmId", "@snapshotTimestamp"])
elif (
"timestamp" in features.columns and "groupByBoundaryId" in features.columns
):
features["timestamp"] = pd.to_datetime(
features["timestamp"], format="%Y-%m-%dT%H:%M:%SZ"
features["timestamp"].str.replace("Z", ""), format="ISO8601"
)
if multi_index:
features = features.set_index(["groupByBoundaryId", "timestamp"])
elif "@timestamp" in features.columns:
features["@timestamp"] = pd.to_datetime(
features["@timestamp"], format="%Y-%m-%dT%H:%M:%SZ"
features["@timestamp"].str.replace("Z", ""), format="ISO8601"
)
if multi_index:
features = features.set_index(["@timestamp"])
Expand Down Expand Up @@ -200,12 +200,12 @@ def _format_timestamp(self, result_df: DataFrame) -> None:
"""
if "timestamp" in result_df.columns:
result_df["timestamp"] = pd.to_datetime(
result_df["timestamp"], format="ISO8601"
result_df["timestamp"].str.replace("Z", ""), format="ISO8601"
)
else:
result_df["fromTimestamp"] = pd.to_datetime(
result_df["fromTimestamp"], format="ISO8601"
result_df["fromTimestamp"].str.replace("Z", ""), format="ISO8601"
)
result_df["toTimestamp"] = pd.to_datetime(
result_df["toTimestamp"], format="ISO8601"
result_df["toTimestamp"].str.replace("Z", ""), format="ISO8601"
)
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:04 GMT
- Wed, 29 Nov 2023 13:54:48 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:04 GMT
- Wed, 29 Nov 2023 13:54:48 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
interactions:
- request:
body: bcircles=0%3A8.678770065307615%2C49.414435400453954%2C100%7C1%3A8.697137832641602%2C49.41007968889129%2C150&time=2023-11-11T22%3A00%3A00&filter=amenity%3Drestaurant+and+type%3Away
body: bcircles=0%3A8.678770065307615%2C49.414435400453954%2C100%7C1%3A8.697137832641602%2C49.41007968889129%2C150&time=2023-11-25T13%3A00%3A00&filter=amenity%3Drestaurant+and+type%3Away
headers:
Accept:
- '*/*'
Expand All @@ -20,7 +20,7 @@ interactions:
body:
string: "{\n \"attribution\" : {\n \"url\" : \"https://ohsome.org/copyrights\",\n
\ \"text\" : \"\xA9 OpenStreetMap contributors\"\n },\n \"apiVersion\"
: \"1.10.1\",\n \"result\" : [ {\n \"timestamp\" : \"2023-11-11T22:00:00Z\",\n
: \"1.10.1\",\n \"result\" : [ {\n \"timestamp\" : \"2023-11-25T13:00:00Z\",\n
\ \"value\" : 0.0\n } ]\n}"
headers:
Access-Control-Allow-Credentials:
Expand All @@ -42,7 +42,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:06 GMT
- Wed, 29 Nov 2023 13:54:48 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:13 GMT
- Wed, 29 Nov 2023 13:54:53 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down
10 changes: 5 additions & 5 deletions ohsome/test/cassettes/test_client/test_format_bboxes_list.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:13 GMT
- Wed, 29 Nov 2023 13:54:53 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down Expand Up @@ -99,7 +99,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:14 GMT
- Wed, 29 Nov 2023 13:54:53 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down Expand Up @@ -156,7 +156,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:14 GMT
- Wed, 29 Nov 2023 13:54:55 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down Expand Up @@ -213,7 +213,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:16 GMT
- Wed, 29 Nov 2023 13:54:55 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down Expand Up @@ -270,7 +270,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:16 GMT
- Wed, 29 Nov 2023 13:54:55 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:06 GMT
- Wed, 29 Nov 2023 13:54:49 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:08 GMT
- Wed, 29 Nov 2023 13:54:51 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down Expand Up @@ -102,7 +102,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:08 GMT
- Wed, 29 Nov 2023 13:54:51 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down Expand Up @@ -159,7 +159,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:09 GMT
- Wed, 29 Nov 2023 13:54:51 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down Expand Up @@ -216,7 +216,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:09 GMT
- Wed, 29 Nov 2023 13:54:52 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:11 GMT
- Wed, 29 Nov 2023 13:54:52 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down
2 changes: 1 addition & 1 deletion ohsome/test/cassettes/test_client/test_format_bpolys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:11 GMT
- Wed, 29 Nov 2023 13:54:52 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ interactions:
Content-disposition:
- attachment;filename=ohsome.geojson
Date:
- Fri, 17 Nov 2023 15:37:17 GMT
- Wed, 29 Nov 2023 13:54:56 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down Expand Up @@ -115,7 +115,7 @@ interactions:
Content-disposition:
- attachment;filename=ohsome.geojson
Date:
- Fri, 17 Nov 2023 15:37:17 GMT
- Wed, 29 Nov 2023 13:54:56 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down
6 changes: 3 additions & 3 deletions ohsome/test/cassettes/test_client/test_user_agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ interactions:
: {\n \"type\" : \"Polygon\",\n \"coordinates\" : [ [ [ -180.0,
-90.0 ], [ 180.0, -90.0 ], [ 180.0, 90.0 ], [ -180.0, 90.0 ], [ -180.0, -90.0
] ] ]\n },\n \"temporalExtent\" : {\n \"fromTimestamp\" : \"2007-10-08T00:00:00Z\",\n
\ \"toTimestamp\" : \"2023-11-11T22:00Z\"\n },\n \"replicationSequenceNumber\"
: 97863\n }\n}"
\ \"toTimestamp\" : \"2023-11-25T13:00Z\"\n },\n \"replicationSequenceNumber\"
: 98190\n }\n}"
headers:
Access-Control-Allow-Credentials:
- 'true'
Expand All @@ -42,7 +42,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:03 GMT
- Wed, 29 Nov 2023 13:54:44 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interactions:
uri: https://api.ohsome.org/v1/elements/geometry
response:
body:
string: "{\n \"timestamp\" : \"2023-11-17T15:37:19.579114653\",\n \"status\"
string: "{\n \"timestamp\" : \"2023-11-29T13:54:57.479125767\",\n \"status\"
: 413,\n \"message\" : \"The given query is too large in respect to the given
timeout. Please use a smaller region and/or coarser time period.\",\n \"requestUrl\"
: \"https://api.ohsome.org/v1/elements/geometry\"\n}"
Expand All @@ -44,7 +44,7 @@ interactions:
Content-disposition:
- attachment;filename=ohsome.geojson
Date:
- Fri, 17 Nov 2023 15:37:19 GMT
- Wed, 29 Nov 2023 13:54:56 GMT
Server:
- Apache
Strict-Transport-Security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:26 GMT
- Wed, 29 Nov 2023 13:55:14 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interactions:
uri: https://api.ohsome.org/v1/elements/count/groupBy/tag
response:
body:
string: "{\n \"timestamp\" : \"2023-11-17T15:37:26.890336955\",\n \"status\"
string: "{\n \"timestamp\" : \"2023-11-29T13:55:14.60175905\",\n \"status\"
: 400,\n \"message\" : \"You need to give one groupByKey parameter, if you
want to use groupBy/tag.\",\n \"requestUrl\" : \"https://api.ohsome.org/v1/elements/count/groupBy/tag\"\n}"
headers:
Expand All @@ -41,7 +41,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:26 GMT
- Wed, 29 Nov 2023 13:55:14 GMT
Server:
- Apache
Strict-Transport-Security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ interactions:
Content-Type:
- text/html
Date:
- Fri, 17 Nov 2023 15:37:19 GMT
- Wed, 29 Nov 2023 13:54:57 GMT
ETag:
- '"25c-5c7180820e5fc"'
Keep-Alive:
Expand Down
4 changes: 2 additions & 2 deletions ohsome/test/cassettes/test_exceptions/test_log_bpolys.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interactions:
uri: https://api.ohsome.org/v1/elements/count
response:
body:
string: "{\n \"timestamp\" : \"2023-11-17T15:37:20.131942698\",\n \"status\"
string: "{\n \"timestamp\" : \"2023-11-29T13:54:57.656277775\",\n \"status\"
: 413,\n \"message\" : \"The given query is too large in respect to the given
timeout. Please use a smaller region and/or coarser time period.\",\n \"requestUrl\"
: \"https://api.ohsome.org/v1/elements/count\"\n}"
Expand All @@ -42,7 +42,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 15:37:20 GMT
- Wed, 29 Nov 2023 13:54:57 GMT
Server:
- Apache
Strict-Transport-Security:
Expand Down
4 changes: 2 additions & 2 deletions ohsome/test/cassettes/test_exceptions/test_log_curl.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interactions:
uri: https://api.ohsome.org/v1/elements/count
response:
body:
string: "{\n \"timestamp\" : \"2023-11-17T12:28:28.06766606\",\n \"status\"
string: "{\n \"timestamp\" : \"2023-11-29T13:54:57.759114624\",\n \"status\"
: 413,\n \"message\" : \"The given query is too large in respect to the given
timeout. Please use a smaller region and/or coarser time period.\",\n \"requestUrl\"
: \"https://api.ohsome.org/v1/elements/count\"\n}"
Expand All @@ -42,7 +42,7 @@ interactions:
Content-Type:
- application/json
Date:
- Fri, 17 Nov 2023 12:28:27 GMT
- Wed, 29 Nov 2023 13:54:57 GMT
Server:
- Apache
Strict-Transport-Security:
Expand Down
4 changes: 2 additions & 2 deletions ohsome/test/cassettes/test_exceptions/test_timeout_error.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ interactions:
uri: https://api.ohsome.org/v1/elements/geometry
response:
body:
string: "{\n \"timestamp\" : \"2023-11-17T15:37:19.028799445\",\n \"status\"
string: "{\n \"timestamp\" : \"2023-11-29T13:54:57.300350483\",\n \"status\"
: 413,\n \"message\" : \"The given query is too large in respect to the given
timeout. Please use a smaller region and/or coarser time period.\",\n \"requestUrl\"
: \"https://api.ohsome.org/v1/elements/geometry\"\n}"
Expand All @@ -44,7 +44,7 @@ interactions:
Content-disposition:
- attachment;filename=ohsome.geojson
Date:
- Fri, 17 Nov 2023 15:37:19 GMT
- Wed, 29 Nov 2023 13:54:56 GMT
Server:
- Apache
Strict-Transport-Security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ interactions:
Content-disposition:
- attachment;filename=ohsome.geojson
Date:
- Fri, 17 Nov 2023 15:37:41 GMT
- Wed, 29 Nov 2023 13:55:21 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ interactions:
Content-disposition:
- attachment;filename=ohsome.geojson
Date:
- Fri, 17 Nov 2023 15:37:41 GMT
- Wed, 29 Nov 2023 13:55:23 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ interactions:
Content-disposition:
- attachment;filename=ohsome.geojson
Date:
- Fri, 17 Nov 2023 15:37:39 GMT
- Wed, 29 Nov 2023 13:55:21 GMT
Keep-Alive:
- timeout=5, max=100
Server:
Expand Down
Loading

0 comments on commit 927dd15

Please sign in to comment.