Skip to content

Commit

Permalink
Merge pull request #44 from ParclLabs/autopaginate
Browse files Browse the repository at this point in the history
autopaginate param
  • Loading branch information
bhagyasharma committed Jun 6, 2024
2 parents f681c7e + 1e5b51c commit 77527b8
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 2 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
### v0.4.2
- Add `auto_paginate` support for all endpoints (retrieve & retrieve_many)

### v0.4.1
- Backend Parcl Labs Services refactor

Expand Down
2 changes: 1 addition & 1 deletion parcllabs/__version__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
VERSION = "0.4.1"
VERSION = "0.4.2"
10 changes: 9 additions & 1 deletion parcllabs/services/parcllabs_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ def retrieve_many_items(
self,
parcl_ids: List[int],
params: Optional[Mapping[str, Any]] = None,
auto_paginate: bool = False,
get_key_on_last_request: List[str] = [],
**kwargs,
) -> Dict[str, Any]:
Expand All @@ -171,7 +172,12 @@ def retrieve_many_items(
with alive_bar(len(parcl_ids)) as bar:
for parcl_id in parcl_ids:
try:
output = self.retrieve(parcl_id=parcl_id, params=params, **kwargs)
output = self.retrieve(
parcl_id=parcl_id,
params=params,
auto_paginate=auto_paginate,
**kwargs,
)
results[parcl_id] = output.get("items")
except RequestException as e:
# continue if no data is found for the parcl_id
Expand All @@ -189,6 +195,7 @@ def retrieve_many(
end_date: str = None,
params: Optional[Mapping[str, Any]] = None,
as_dataframe: bool = False,
auto_paginate: bool = False,
get_key_on_last_request: List[str] = [],
):
start_date = self.validate_date(start_date)
Expand All @@ -203,6 +210,7 @@ def retrieve_many(
results, additional_output = self.retrieve_many_items(
parcl_ids=parcl_ids,
params=params,
auto_paginate=auto_paginate,
get_key_on_last_request=get_key_on_last_request,
)

Expand Down
2 changes: 2 additions & 0 deletions parcllabs/services/portfolio_size_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def retrieve_many(
portfolio_size: str = None,
params: Optional[Mapping[str, Any]] = {},
as_dataframe: bool = False,
auto_paginate: bool = False,
):
portfolio_size = self.validate_portfolio_size(portfolio_size)

Expand All @@ -50,5 +51,6 @@ def retrieve_many(
end_date=end_date,
params=params,
as_dataframe=as_dataframe,
auto_paginate=auto_paginate,
get_key_on_last_request=["portfolio_size"],
)
2 changes: 2 additions & 0 deletions parcllabs/services/property_type_service.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ def retrieve_many(
property_type: str = None,
params: Optional[Mapping[str, Any]] = {},
as_dataframe: bool = False,
auto_paginate: bool = False,
):
property_type = self.validate_property_type(property_type)

Expand All @@ -50,5 +51,6 @@ def retrieve_many(
end_date=end_date,
params=params,
as_dataframe=as_dataframe,
auto_paginate=auto_paginate,
get_key_on_last_request=["property_type"],
)

0 comments on commit 77527b8

Please sign in to comment.