Skip to content

Commit f5b256e

Browse files
committed
updated inter.context, docs and tests
1 parent 34fc880 commit f5b256e

File tree

5 files changed

+18
-12
lines changed

5 files changed

+18
-12
lines changed

airbyte_cdk/sources/declarative/declarative_component_schema.yaml

+6
Original file line numberDiff line numberDiff line change
@@ -1780,6 +1780,7 @@ definitions:
17801780
- stream_partition
17811781
- stream_slice
17821782
- creation_response
1783+
- polling_response
17831784
- download_target
17841785
examples:
17851786
- "/products"
@@ -3674,6 +3675,11 @@ interpolation:
36743675
type: object
36753676
examples:
36763677
- id: "1234"
3678+
- title: polling_response
3679+
description: The response received from the polling_requester in the AsyncRetriever component.
3680+
type: object
3681+
examples:
3682+
- id: "1234"
36773683
- title: download_target
36783684
description: The `URL` received from the polling_requester in the AsyncRetriever with jobStatus as `COMPLETED`.
36793685
type: string

airbyte_cdk/sources/declarative/requesters/README.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# AsyncHttpJobRepository sequence diagram
22

33
- Components marked as optional are not required and can be ignored.
4-
- if `url_requester` is not provided, `download_target_extractor` will get urls from the `polling_job_response`
5-
- interpolation_context, e.g. `create_job_response` or `polling_job_response` can be obtained from stream_slice
4+
- if `url_requester` is not provided, `download_target_extractor` will get urls from the `polling_response`
5+
- interpolation_context, e.g. `creation_response` or `polling_response` can be obtained from stream_slice
66

77
```mermaid
88
---
@@ -25,14 +25,14 @@ sequenceDiagram
2525
2626
loop Poll for job status
2727
AsyncHttpJobRepository ->> PollingRequester: Check job status
28-
PollingRequester ->> Reporting Server: Status request (interpolation_context: `create_job_response`)
28+
PollingRequester ->> Reporting Server: Status request (interpolation_context: `creation_response`)
2929
Reporting Server -->> PollingRequester: Status response
3030
PollingRequester -->> AsyncHttpJobRepository: Job status
3131
end
3232
3333
alt Status: Ready
3434
AsyncHttpJobRepository ->> UrlRequester: Request download URLs (if applicable)
35-
UrlRequester ->> Reporting Server: URL request (interpolation_context: `polling_job_response`)
35+
UrlRequester ->> Reporting Server: URL request (interpolation_context: `polling_response`)
3636
Reporting Server -->> UrlRequester: Download URLs
3737
UrlRequester -->> AsyncHttpJobRepository: Download URLs
3838

airbyte_cdk/sources/declarative/requesters/http_job_repository.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,11 @@ def _get_download_url(self, job: AsyncJob) -> Iterable[str]:
284284
if not self.url_requester:
285285
url_response = self._polling_job_response_by_id[job.api_job_id()]
286286
else:
287+
polling_response = self._polling_job_response_by_id[job.api_job_id()].json()
287288
stream_slice: StreamSlice = StreamSlice(
288-
partition={
289-
"polling_job_response": self._polling_job_response_by_id[job.api_job_id()]
290-
},
289+
partition={},
291290
cursor_slice={},
291+
extra_fields={"polling_response": polling_response},
292292
)
293293
url_response = self.url_requester.send_request(stream_slice=stream_slice) # type: ignore # we expect url_requester to always be presented, otherwise raise an exception as we cannot proceed with the report
294294
if not url_response:

unit_tests/sources/declarative/parsers/test_model_to_component_factory.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -3615,7 +3615,7 @@ def test_create_async_retriever():
36153615
"status_extractor": {"type": "DpathExtractor", "field_path": ["status"]},
36163616
"polling_requester": {
36173617
"type": "HttpRequester",
3618-
"path": "/v3/marketing/contacts/exports/{{stream_slice['create_job_response'].json()['id'] }}",
3618+
"path": "/v3/marketing/contacts/exports/{{creation_response['id'] }}",
36193619
"url_base": "https://api.sendgrid.com",
36203620
"http_method": "GET",
36213621
"authenticator": {
@@ -3635,19 +3635,19 @@ def test_create_async_retriever():
36353635
},
36363636
"download_requester": {
36373637
"type": "HttpRequester",
3638-
"path": "{{stream_slice['url']}}",
3638+
"path": "{{download_target}}",
36393639
"url_base": "",
36403640
"http_method": "GET",
36413641
},
36423642
"abort_requester": {
36433643
"type": "HttpRequester",
3644-
"path": "{{stream_slice['url']}}/abort",
3644+
"path": "{{download_target}}/abort",
36453645
"url_base": "",
36463646
"http_method": "POST",
36473647
},
36483648
"delete_requester": {
36493649
"type": "HttpRequester",
3650-
"path": "{{stream_slice['url']}}",
3650+
"path": "{{download_target}}",
36513651
"url_base": "",
36523652
"http_method": "POST",
36533653
},

unit_tests/sources/declarative/test_concurrent_declarative_source.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@
307307
"status_extractor": {"type": "DpathExtractor", "field_path": ["status"]},
308308
"polling_requester": {
309309
"type": "HttpRequester",
310-
"path": "/async_job/{{stream_slice['create_job_response'].json()['id'] }}",
310+
"path": "/async_job/{{creation_response['id'] }}",
311311
"http_method": "GET",
312312
"authenticator": {
313313
"type": "BearerAuthenticator",

0 commit comments

Comments
 (0)