Skip to content

Commit 06cccc5

Browse files
author
octavia-squidington-iii
committed
Auto-fix lint and format issues
1 parent 9af489d commit 06cccc5

File tree

4 files changed

+73
-79
lines changed

4 files changed

+73
-79
lines changed

airbyte_cdk/sources/declarative/concurrent_declarative_source.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,11 @@ def _group_streams(
216216
declarative_stream.name
217217
].get("incremental_sync")
218218

219-
if name_to_stream_mapping[declarative_stream.name].get("retriever", {}).get("full_refresh_no_slice_in_params", False):
219+
if (
220+
name_to_stream_mapping[declarative_stream.name]
221+
.get("retriever", {})
222+
.get("full_refresh_no_slice_in_params", False)
223+
):
220224
incremental_sync_component_definition["step"] = None
221225
incremental_sync_component_definition["cursor_granularity"] = None
222226
incremental_sync_component_definition["start_time_option"] = None

airbyte_cdk/sources/declarative/manifest_declarative_source.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,12 @@ def update_with_cache_parent_configs(parent_configs: list[dict[str, Any]]) -> No
163163
for parent_config in parent_configs:
164164
parent_streams.add(parent_config["stream"]["name"])
165165
if parent_config["stream"]["retriever"]["type"] == "StateDelegatingRetriever":
166-
parent_config["stream"]["retriever"]["full_refresh_retriever"]["requester"]["use_cache"] = True
167-
parent_config["stream"]["retriever"]["incremental_retriever"]["requester"]["use_cache"] = True
166+
parent_config["stream"]["retriever"]["full_refresh_retriever"]["requester"][
167+
"use_cache"
168+
] = True
169+
parent_config["stream"]["retriever"]["incremental_retriever"]["requester"][
170+
"use_cache"
171+
] = True
168172
else:
169173
parent_config["stream"]["retriever"]["requester"]["use_cache"] = True
170174

@@ -190,8 +194,12 @@ def update_with_cache_parent_configs(parent_configs: list[dict[str, Any]]) -> No
190194
for stream_config in stream_configs:
191195
if stream_config["name"] in parent_streams:
192196
if stream_config["retriever"]["type"] == "StateDelegatingRetriever":
193-
stream_config["retriever"]["full_refresh_retriever"]["requester"]["use_cache"] = True
194-
stream_config["retriever"]["incremental_retriever"]["requester"]["use_cache"] = True
197+
stream_config["retriever"]["full_refresh_retriever"]["requester"][
198+
"use_cache"
199+
] = True
200+
stream_config["retriever"]["incremental_retriever"]["requester"][
201+
"use_cache"
202+
] = True
195203
else:
196204
stream_config["retriever"]["requester"]["use_cache"] = True
197205

airbyte_cdk/sources/declarative/models/declarative_component_schema.py

Lines changed: 42 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -609,9 +609,7 @@ class OAuthAuthenticator(BaseModel):
609609
scopes: Optional[List[str]] = Field(
610610
None,
611611
description="List of scopes that should be granted to the access token.",
612-
examples=[
613-
["crm.list.read", "crm.objects.contacts.read", "crm.schema.contacts.read"]
614-
],
612+
examples=[["crm.list.read", "crm.objects.contacts.read", "crm.schema.contacts.read"]],
615613
title="Scopes",
616614
)
617615
token_expiry_date: Optional[str] = Field(
@@ -1080,28 +1078,24 @@ class OAuthConfigSpecification(BaseModel):
10801078
class Config:
10811079
extra = Extra.allow
10821080

1083-
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = (
1084-
Field(
1085-
None,
1086-
description="OAuth specific blob. This is a Json Schema used to validate Json configurations used as input to OAuth.\nMust be a valid non-nested JSON that refers to properties from ConnectorSpecification.connectionSpecification\nusing special annotation 'path_in_connector_config'.\nThese are input values the user is entering through the UI to authenticate to the connector, that might also shared\nas inputs for syncing data via the connector.\nExamples:\nif no connector values is shared during oauth flow, oauth_user_input_from_connector_config_specification=[]\nif connector values such as 'app_id' inside the top level are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['app_id']\n }\n }\nif connector values such as 'info.app_id' nested inside another object are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['info', 'app_id']\n }\n }",
1087-
examples=[
1088-
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
1089-
{
1090-
"app_id": {
1091-
"type": "string",
1092-
"path_in_connector_config": ["info", "app_id"],
1093-
}
1094-
},
1095-
],
1096-
title="OAuth user input",
1097-
)
1081+
oauth_user_input_from_connector_config_specification: Optional[Dict[str, Any]] = Field(
1082+
None,
1083+
description="OAuth specific blob. This is a Json Schema used to validate Json configurations used as input to OAuth.\nMust be a valid non-nested JSON that refers to properties from ConnectorSpecification.connectionSpecification\nusing special annotation 'path_in_connector_config'.\nThese are input values the user is entering through the UI to authenticate to the connector, that might also shared\nas inputs for syncing data via the connector.\nExamples:\nif no connector values is shared during oauth flow, oauth_user_input_from_connector_config_specification=[]\nif connector values such as 'app_id' inside the top level are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['app_id']\n }\n }\nif connector values such as 'info.app_id' nested inside another object are used to generate the API url for the oauth flow,\n oauth_user_input_from_connector_config_specification={\n app_id: {\n type: string\n path_in_connector_config: ['info', 'app_id']\n }\n }",
1084+
examples=[
1085+
{"app_id": {"type": "string", "path_in_connector_config": ["app_id"]}},
1086+
{
1087+
"app_id": {
1088+
"type": "string",
1089+
"path_in_connector_config": ["info", "app_id"],
1090+
}
1091+
},
1092+
],
1093+
title="OAuth user input",
10981094
)
1099-
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = (
1100-
Field(
1101-
None,
1102-
description='The DeclarativeOAuth specific blob.\nPertains to the fields defined by the connector relating to the OAuth flow.\n\nInterpolation capabilities:\n- The variables placeholders are declared as `{{my_var}}`.\n- The nested resolution variables like `{{ {{my_nested_var}} }}` is allowed as well.\n\n- The allowed interpolation context is:\n + base64Encoder - encode to `base64`, {{ {{my_var_a}}:{{my_var_b}} | base64Encoder }}\n + base64Decorer - decode from `base64` encoded string, {{ {{my_string_variable_or_string_value}} | base64Decoder }}\n + urlEncoder - encode the input string to URL-like format, {{ https://test.host.com/endpoint | urlEncoder}}\n + urlDecorer - decode the input url-encoded string into text format, {{ urlDecoder:https%3A%2F%2Fairbyte.io | urlDecoder}}\n + codeChallengeS256 - get the `codeChallenge` encoded value to provide additional data-provider specific authorisation values, {{ {{state_value}} | codeChallengeS256 }}\n\nExamples:\n - The TikTok Marketing DeclarativeOAuth spec:\n {\n "oauth_connector_input_specification": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "consent_url": "https://ads.tiktok.com/marketing_api/auth?{{client_id_key}}={{client_id_value}}&{{redirect_uri_key}}={{ {{redirect_uri_value}} | urlEncoder}}&{{state_key}}={{state_value}}",\n "access_token_url": "https://business-api.tiktok.com/open_api/v1.3/oauth2/access_token/",\n "access_token_params": {\n "{{ auth_code_key }}": "{{ auth_code_value }}",\n "{{ client_id_key }}": "{{ client_id_value }}",\n "{{ client_secret_key }}": "{{ client_secret_value }}"\n },\n "access_token_headers": {\n "Content-Type": "application/json",\n "Accept": "application/json"\n },\n "extract_output": ["data.access_token"],\n "client_id_key": "app_id",\n "client_secret_key": "secret",\n "auth_code_key": "auth_code"\n }\n }\n }',
1103-
title="DeclarativeOAuth Connector Specification",
1104-
)
1095+
oauth_connector_input_specification: Optional[OauthConnectorInputSpecification] = Field(
1096+
None,
1097+
description='The DeclarativeOAuth specific blob.\nPertains to the fields defined by the connector relating to the OAuth flow.\n\nInterpolation capabilities:\n- The variables placeholders are declared as `{{my_var}}`.\n- The nested resolution variables like `{{ {{my_nested_var}} }}` is allowed as well.\n\n- The allowed interpolation context is:\n + base64Encoder - encode to `base64`, {{ {{my_var_a}}:{{my_var_b}} | base64Encoder }}\n + base64Decorer - decode from `base64` encoded string, {{ {{my_string_variable_or_string_value}} | base64Decoder }}\n + urlEncoder - encode the input string to URL-like format, {{ https://test.host.com/endpoint | urlEncoder}}\n + urlDecorer - decode the input url-encoded string into text format, {{ urlDecoder:https%3A%2F%2Fairbyte.io | urlDecoder}}\n + codeChallengeS256 - get the `codeChallenge` encoded value to provide additional data-provider specific authorisation values, {{ {{state_value}} | codeChallengeS256 }}\n\nExamples:\n - The TikTok Marketing DeclarativeOAuth spec:\n {\n "oauth_connector_input_specification": {\n "type": "object",\n "additionalProperties": false,\n "properties": {\n "consent_url": "https://ads.tiktok.com/marketing_api/auth?{{client_id_key}}={{client_id_value}}&{{redirect_uri_key}}={{ {{redirect_uri_value}} | urlEncoder}}&{{state_key}}={{state_value}}",\n "access_token_url": "https://business-api.tiktok.com/open_api/v1.3/oauth2/access_token/",\n "access_token_params": {\n "{{ auth_code_key }}": "{{ auth_code_value }}",\n "{{ client_id_key }}": "{{ client_id_value }}",\n "{{ client_secret_key }}": "{{ client_secret_value }}"\n },\n "access_token_headers": {\n "Content-Type": "application/json",\n "Accept": "application/json"\n },\n "extract_output": ["data.access_token"],\n "client_id_key": "app_id",\n "client_secret_key": "secret",\n "auth_code_key": "auth_code"\n }\n }\n }',
1098+
title="DeclarativeOAuth Connector Specification",
11051099
)
11061100
complete_oauth_output_specification: Optional[Dict[str, Any]] = Field(
11071101
None,
@@ -1119,9 +1113,7 @@ class Config:
11191113
complete_oauth_server_input_specification: Optional[Dict[str, Any]] = Field(
11201114
None,
11211115
description="OAuth specific blob. This is a Json Schema used to validate Json configurations persisted as Airbyte Server configurations.\nMust be a valid non-nested JSON describing additional fields configured by the Airbyte Instance or Workspace Admins to be used by the\nserver when completing an OAuth flow (typically exchanging an auth code for refresh token).\nExamples:\n complete_oauth_server_input_specification={\n client_id: {\n type: string\n },\n client_secret: {\n type: string\n }\n }",
1122-
examples=[
1123-
{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}
1124-
],
1116+
examples=[{"client_id": {"type": "string"}, "client_secret": {"type": "string"}}],
11251117
title="OAuth input specification",
11261118
)
11271119
complete_oauth_server_output_specification: Optional[Dict[str, Any]] = Field(
@@ -1774,9 +1766,7 @@ class RecordSelector(BaseModel):
17741766
description="Responsible for filtering records to be emitted by the Source.",
17751767
title="Record Filter",
17761768
)
1777-
schema_normalization: Optional[
1778-
Union[SchemaNormalization, CustomSchemaNormalization]
1779-
] = Field(
1769+
schema_normalization: Optional[Union[SchemaNormalization, CustomSchemaNormalization]] = Field(
17801770
SchemaNormalization.None_,
17811771
description="Responsible for normalization according to the schema.",
17821772
title="Schema Normalization",
@@ -1975,12 +1965,12 @@ class Config:
19751965
extra = Extra.allow
19761966

19771967
type: Literal["DeclarativeStream"]
1978-
retriever: Union[
1979-
AsyncRetriever, CustomRetriever, SimpleRetriever, StateDelegatingRetriever
1980-
] = Field(
1981-
...,
1982-
description="Component used to coordinate how records are extracted across stream slices and request pages.",
1983-
title="Retriever",
1968+
retriever: Union[AsyncRetriever, CustomRetriever, SimpleRetriever, StateDelegatingRetriever] = (
1969+
Field(
1970+
...,
1971+
description="Component used to coordinate how records are extracted across stream slices and request pages.",
1972+
title="Retriever",
1973+
)
19841974
)
19851975
incremental_sync: Optional[
19861976
Union[CustomIncrementalSync, DatetimeBasedCursor, IncrementingCountCursor]
@@ -1989,9 +1979,7 @@ class Config:
19891979
description="Component used to fetch data incrementally based on a time field in the data.",
19901980
title="Incremental Sync",
19911981
)
1992-
name: Optional[str] = Field(
1993-
"", description="The stream name.", example=["Users"], title="Name"
1994-
)
1982+
name: Optional[str] = Field("", description="The stream name.", example=["Users"], title="Name")
19951983
primary_key: Optional[PrimaryKey] = Field(
19961984
"", description="The primary key of the stream.", title="Primary Key"
19971985
)
@@ -2248,19 +2236,15 @@ class StateDelegatingRetriever(BaseModel):
22482236
False,
22492237
description="If set to true, a single slice will be used and its request options will be ignored when sending requests.",
22502238
)
2251-
full_refresh_retriever: Union[AsyncRetriever, CustomRetriever, SimpleRetriever] = (
2252-
Field(
2253-
...,
2254-
description="Component used to coordinate how records are extracted across stream slices and request pages.",
2255-
title="Retriever",
2256-
)
2239+
full_refresh_retriever: Union[AsyncRetriever, CustomRetriever, SimpleRetriever] = Field(
2240+
...,
2241+
description="Component used to coordinate how records are extracted across stream slices and request pages.",
2242+
title="Retriever",
22572243
)
2258-
incremental_retriever: Union[AsyncRetriever, CustomRetriever, SimpleRetriever] = (
2259-
Field(
2260-
...,
2261-
description="Component used to coordinate how records are extracted across stream slices and request pages.",
2262-
title="Retriever",
2263-
)
2244+
incremental_retriever: Union[AsyncRetriever, CustomRetriever, SimpleRetriever] = Field(
2245+
...,
2246+
description="Component used to coordinate how records are extracted across stream slices and request pages.",
2247+
title="Retriever",
22642248
)
22652249
parameters: Optional[Dict[str, Any]] = Field(None, alias="$parameters")
22662250

@@ -2288,11 +2272,7 @@ class SimpleRetriever(BaseModel):
22882272
CustomPartitionRouter,
22892273
ListPartitionRouter,
22902274
SubstreamPartitionRouter,
2291-
List[
2292-
Union[
2293-
CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter
2294-
]
2295-
],
2275+
List[Union[CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter]],
22962276
]
22972277
] = Field(
22982278
[],
@@ -2336,9 +2316,7 @@ class AsyncRetriever(BaseModel):
23362316
)
23372317
download_extractor: Optional[
23382318
Union[CustomRecordExtractor, DpathExtractor, ResponseToFileExtractor]
2339-
] = Field(
2340-
None, description="Responsible for fetching the records from provided urls."
2341-
)
2319+
] = Field(None, description="Responsible for fetching the records from provided urls.")
23422320
creation_requester: Union[CustomRequester, HttpRequester] = Field(
23432321
...,
23442322
description="Requester component that describes how to prepare HTTP requests to send to the source API to create the async server-side job.",
@@ -2372,11 +2350,7 @@ class AsyncRetriever(BaseModel):
23722350
CustomPartitionRouter,
23732351
ListPartitionRouter,
23742352
SubstreamPartitionRouter,
2375-
List[
2376-
Union[
2377-
CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter
2378-
]
2379-
],
2353+
List[Union[CustomPartitionRouter, ListPartitionRouter, SubstreamPartitionRouter]],
23802354
]
23812355
] = Field(
23822356
[],
@@ -2444,12 +2418,10 @@ class DynamicDeclarativeStream(BaseModel):
24442418
stream_template: DeclarativeStream = Field(
24452419
..., description="Reference to the stream template.", title="Stream Template"
24462420
)
2447-
components_resolver: Union[HttpComponentsResolver, ConfigComponentsResolver] = (
2448-
Field(
2449-
...,
2450-
description="Component resolve and populates stream templates with components values.",
2451-
title="Components Resolver",
2452-
)
2421+
components_resolver: Union[HttpComponentsResolver, ConfigComponentsResolver] = Field(
2422+
...,
2423+
description="Component resolve and populates stream templates with components values.",
2424+
title="Components Resolver",
24532425
)
24542426

24552427

airbyte_cdk/sources/declarative/parsers/model_to_component_factory.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1808,7 +1808,10 @@ def _build_incremental_cursor(
18081808
stream_slicer: Optional[PartitionRouter],
18091809
config: Config,
18101810
) -> Optional[StreamSlicer]:
1811-
if model.retriever.type == "StateDelegatingRetriever" and model.retriever.full_refresh_no_slice_in_params:
1811+
if (
1812+
model.retriever.type == "StateDelegatingRetriever"
1813+
and model.retriever.full_refresh_no_slice_in_params
1814+
):
18121815
model.incremental_sync.step = None
18131816
model.incremental_sync.cursor_granularity = None
18141817
model.incremental_sync.start_time_option = None
@@ -1918,7 +1921,11 @@ def _merge_stream_slicers(
19181921
raise ValueError("Per partition state is not supported yet for AsyncRetriever.")
19191922

19201923
if retriever_model.type == "StateDelegatingRetriever":
1921-
retriever_model = retriever_model.incremental_retriever if self._connector_state_manager.get_stream_state(model.name, None) else retriever_model.full_refresh_retriever
1924+
retriever_model = (
1925+
retriever_model.incremental_retriever
1926+
if self._connector_state_manager.get_stream_state(model.name, None)
1927+
else retriever_model.full_refresh_retriever
1928+
)
19221929

19231930
stream_slicer = self._build_stream_slicer_from_partition_router(retriever_model, config)
19241931

@@ -2746,8 +2753,11 @@ def create_state_delegating_retriever(
27462753
client_side_incremental_sync: Optional[Dict[str, Any]] = None,
27472754
transformations: List[RecordTransformation],
27482755
) -> SimpleRetriever:
2749-
2750-
retriever_model = model.incremental_retriever if self._connector_state_manager.get_stream_state(name, None) else model.full_refresh_retriever
2756+
retriever_model = (
2757+
model.incremental_retriever
2758+
if self._connector_state_manager.get_stream_state(name, None)
2759+
else model.full_refresh_retriever
2760+
)
27512761

27522762
return self._create_component_from_model(
27532763
model=retriever_model,

0 commit comments

Comments
 (0)