Skip to content

Commit

Permalink
refactor: changelog was modified. Changes in clients, test_response a…
Browse files Browse the repository at this point in the history
…nd readme were rewinded
  • Loading branch information
rp280 committed Nov 29, 2023
1 parent 80eec36 commit b0586bf
Show file tree
Hide file tree
Showing 39 changed files with 68 additions and 111 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +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
- timestamps are converted without timezone information. Deviates from Ohsome API [(Issue #318)](https://github.com/GIScience/ohsome-api/issues/318)

### Removed

Expand Down
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,11 @@ time = pandas.date_range("2018-01-01", periods=3, freq="M")

## Contribution Guidelines

The easiest way to contribute is to file a comprehensive [issue](https://github.com/GIScience/ohsome-py/issues) with a reproducible example. Pull requests are always welcome, so if you want to contribute to this project, please fork the repository or create a new branch containing your changes. Follow the steps below to make sure that your contributed code follows the code style and does not break any functionality. Create a **pull request to the main/master** branch once it is ready to be merged.
The easiest way to contribute is to file a comprehensive [issue](https://github.com/GIScience/ohsome-py/issues) with a reproducible example. Pull requests are always welcome, so if you want to contribute to this project, please fork the repository or create a new branch containing your changes.

### Install Package
This package uses [poetry](https://python-poetry.org/) for dependency management.

This package uses [poetry](https://python-poetry.org/) for dependency management. To install all packages necessary for testing and development run
### Install Package

`poetry install`

Expand All @@ -147,10 +147,12 @@ This package uses [poetry](https://python-poetry.org/) for dependency management

### Run Tests

**Before pushing your commits**, run the python unit tests
**Before pushing your commits**, run python tests

`poetry run pytest`

Create a **pull request to the main/master** branch once it is ready to be merged.

#### VCR

ohsome-py records responses using [VCR](https://vcrpy.readthedocs.io/en/latest/) via [pytest-recording](https://github.com/kiwicom/pytest-recording) to prevent unnecessary network traffic and computing during testing. If you implement a test or change an existing one, make sure to update the recorded cassettes. In addition, you should delete all cassettes after a certain time (e.g. every 6m or on each new ohsome release) and re-record them. To do that run
Expand Down
28 changes: 1 addition & 27 deletions ohsome/clients.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,28 +740,8 @@ def count(self):
class _OhsomeClientContributionsAggregated(_OhsomePostClient):
@property
def density(self):
return _OhsomeClientContributionsAggregatedDensity(
self._base_api_url, self.log, self.log_dir, self._cache + ["density"]
)

@property
def groupByBoundary(self):
return _OhsomePostClient(
self._base_api_url,
self.log,
self.log_dir,
self._cache + ["groupBy", "boundary"],
)


class _OhsomeClientContributionsAggregatedDensity(_OhsomePostClient):
@property
def groupByBoundary(self):
return _OhsomePostClient(
self._base_api_url,
self.log,
self.log_dir,
self._cache + ["groupBy", "boundary"],
self._base_api_url, self.log, self.log_dir, self._cache + ["density"]
)


Expand All @@ -786,12 +766,6 @@ def geometry(self):
self._base_api_url, self.log, self.log_dir, self._cache + ["geometry"]
)

@property
def count(self):
return _OhsomeClientContributionsAggregated(
self._base_api_url, self.log, self.log_dir, self._cache + ["count"]
)


class _OhsomeClientUsers(_OhsomeBaseClient):
"""Subclass of _OhsomePostClient to define endpoints of ohsome API"""
Expand Down
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
Loading

0 comments on commit b0586bf

Please sign in to comment.