adam_roderick
03/21/2023, 11:11 PMget_starting_timestamp() requires a context object as a parameter. Where do I find that context object at runtime?edgar_ramirez_mondragon
03/21/2023, 11:17 PMget_url_params(self, context, next_page_token) . Where are you trying to call it?adam_roderick
03/22/2023, 1:41 AMadam_roderick
03/22/2023, 2:25 AMdef get_new_paginator(self) -> BaseAPIPaginator:
"""overrides base class method to return a paginator"""
bookmarked_updated_at = self.get_starting_timestamp(None)
return KrowPaginator(bookmarked_timestamp=bookmarked_updated_at)adam_roderick
03/22/2023, 2:26 AMget_starting_timestamp(None) returns the bookmark value for a parent stream when using this state
{
"bookmarks": {
"organizations": {
"replication_key": "updated_at",
"replication_key_value": "2023-03-22T02:03:52.751Z"
}
}
}adam_roderick
03/22/2023, 2:26 AMNone for child streams when using this state
{
"bookmarks": {
"campaigns": {
"partitions": [
{
"context": {
"organization_id": "0715aee1-54f9-4707-bb67-5950dc695ce7"
},
"replication_key": "updated_at",
"replication_key_value": "2023-03-21T23:13:38.720Z"
}
],
"replication_key_value": "2023-03-21T23:13:38.720Z"
},
"organizations": {}
}
}adam_roderick
03/22/2023, 3:04 AMget_new_paginator but the context at that moment has ALL the partitions in it, with no way to distinguish which is the current partition's value. And a call to get_starting_timestamp(None) returns None instead of the current child partition's replication key valueadam_roderick
03/22/2023, 3:11 AMadam_roderick
03/22/2023, 3:18 AMget_starting_timestamp) should be pre-filtered to the current partition "Many of the methods in the Stream class and its subclasses accept a context parameter, which is a dictionary that contains information about the stream partition or parent stream."Denis I.
03/22/2023, 7:13 AMstarting_timestamp value as stream’s attribute:
def get_records(self, context: Optional[dict]) -> Iterable[dict[str, Any]]:
self._starting_timestamp = self.get_starting_timestamp(context)
yield from super().get_records(context=context)
And passing it’s value to custom paginator:
def get_new_paginator(self) -> CustomPaginator:
return CustomPaginator(
start_value=0,
page_size=self._items_per_request_limit,
starting_date=self._starting_timestamp
)
The cleaner way IMO would be to add context to get_new_paginator call from RESTStream.request_records since it’s already has context: https://github.com/meltano/sdk/blob/47290d0470a38a9e978b53a7436212c43b605f2d/singer_sdk/streams/rest.py#L354
paginator = self.get_new_paginator(context)adam_roderick
03/22/2023, 2:02 PMadam_roderick
03/22/2023, 2:02 PMedgar_ramirez_mondragon
03/22/2023, 6:15 PM