Skip to content

Commit eb0af5d

Browse files
authored
Merge branch 'main' into aj/tests/improve-fast-test-outputs
2 parents 66df838 + acb92dd commit eb0af5d

File tree

19 files changed

+450
-114
lines changed

19 files changed

+450
-114
lines changed

.github/pr-welcome-community.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
## 👋 Welcome to the Airbyte Python CDK!
2+
3+
Thank you for your contribution from **{{ .repo_name }}**! We're excited to have you in the Airbyte community.
4+
5+
### Testing This CDK Version
6+
7+
You can test this version of the CDK using the following:
8+
9+
```bash
10+
# Run the CLI from this branch:
11+
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@{{ .branch_name }}#egg=airbyte-python-cdk[dev]' --help
12+
13+
# Update a connector to use the CDK from this branch ref:
14+
cd airbyte-integrations/connectors/source-example
15+
poe use-cdk-branch {{ .branch_name }}
16+
```
17+
18+
### Helpful Resources
19+
20+
- [Contributing Guidelines](https://docs.airbyte.com/contributing-to-airbyte/)
21+
- [CDK API Reference](https://airbytehq.github.io/airbyte-python-cdk/)
22+
23+
### PR Slash Commands
24+
25+
As needed or by request, Airbyte Maintainers can execute the following slash commands on your PR:
26+
27+
- `/autofix` - Fixes most formatting and linting issues
28+
- `/poetry-lock` - Updates poetry.lock file
29+
- `/test` - Runs connector tests with the updated CDK
30+
31+
If you have any questions, feel free to ask in the PR comments or join our [Slack community](https://airbytehq.slack.com/).
32+

.github/pr-welcome-internal.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
## 👋 Greetings, Airbyte Team Member!
2+
3+
Here are some helpful tips and reminders for your convenience.
4+
5+
### Testing This CDK Version
6+
7+
You can test this version of the CDK using the following:
8+
9+
```bash
10+
# Run the CLI from this branch:
11+
uvx 'git+https://github.com/airbytehq/airbyte-python-cdk.git@{{ .branch_name }}#egg=airbyte-python-cdk[dev]' --help
12+
13+
# Update a connector to use the CDK from this branch ref:
14+
cd airbyte-integrations/connectors/source-example
15+
poe use-cdk-branch {{ .branch_name }}
16+
```
17+
18+
### Helpful Resources
19+
20+
- [CDK API Reference](https://airbytehq.github.io/airbyte-python-cdk/)
21+
22+
### PR Slash Commands
23+
24+
Airbyte Maintainers can execute the following slash commands on your PR:
25+
26+
- `/autofix` - Fixes most formatting and linting issues
27+
- `/poetry-lock` - Updates poetry.lock file
28+
- `/test` - Runs connector tests with the updated CDK
29+
- `/poe <command>` - Runs any poe command in the CDK environment
30+
31+
[📝 _Edit this welcome message._](https://github.com/airbytehq/airbyte-python-cdk/blob/main/.github/pr-welcome-internal.md)

.github/workflows/connector-tests.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ jobs:
7777
- connector: destination-motherduck
7878
# For now, we mark as 'n/a' to always test this connector
7979
cdk_extra: n/a # change to 'sql' to test less often
80-
- connector: source-amplitude
81-
cdk_extra: n/a
80+
# source-amplitude failing for unrelated issue "date too far back"
81+
# e.g. https://github.com/airbytehq/airbyte-python-cdk/actions/runs/16053716569/job/45302638848?pr=639
82+
# - connector: source-amplitude
83+
# cdk_extra: n/a
8284
- connector: source-intercom
8385
cdk_extra: n/a
8486
- connector: source-pokeapi
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: Community PR Welcome Message
2+
3+
# This workflow automatically adds a welcome message to PRs from community contributors (forks)
4+
# It includes CDK usage instructions and other helpful resources for testing changes
5+
#
6+
# MANUAL TESTING INSTRUCTIONS:
7+
# To manually test this workflow, temporarily uncomment the "synchronize" event type as a workflow trigger.
8+
# Then the workflow will run for all new commits.
9+
#
10+
# Before merging, remember to again comment-out the "synchronize" clause and uncomment the `if:` condition.
11+
12+
on:
13+
pull_request:
14+
types:
15+
- opened
16+
- reopened
17+
# Toggle this line, uncommenting for testing:
18+
# - synchronize
19+
20+
jobs:
21+
welcome-contributor:
22+
name: PR Welcome Message
23+
permissions:
24+
contents: read
25+
issues: write
26+
pull-requests: write
27+
runs-on: ubuntu-24.04
28+
steps:
29+
- name: Checkout repository
30+
uses: actions/checkout@v4
31+
32+
- name: Render template
33+
id: template
34+
uses: chuhlomin/[email protected]
35+
with:
36+
# Use a different template for internal vs forks (community)
37+
template: ${{ github.event.pull_request.head.repo.fork == true && '.github/pr-welcome-community.md' || '.github/pr-welcome-internal.md' }}
38+
vars: |
39+
repo_name: ${{ github.event.pull_request.head.repo.full_name }}
40+
branch_name: ${{ github.event.pull_request.head.ref }}
41+
42+
- name: Create comment
43+
uses: peter-evans/create-or-update-comment@v4
44+
with:
45+
issue-number: ${{ github.event.pull_request.number }}
46+
body: ${{ steps.template.outputs.result }}

airbyte_cdk/manifest_migrations/migrations/http_requester_request_body_json_data_to_request_body.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def _migrate_body_json(self, manifest: ManifestType, key: str) -> None:
5454
if isinstance(manifest[key], str):
5555
self._migrate_value(manifest, key, text_type)
5656
elif isinstance(manifest[key], dict):
57-
if manifest[key].get(query_key) is not None:
57+
if isinstance(manifest[key].get(query_key), str):
5858
self._migrate_value(manifest, key, graph_ql_type)
5959
else:
6060
self._migrate_value(manifest, key, json_object_type)

airbyte_cdk/sources/declarative/declarative_component_schema.yaml

Lines changed: 26 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -2140,30 +2140,6 @@ definitions:
21402140
- stream_interval
21412141
- stream_partition
21422142
- stream_slice
2143-
examples:
2144-
- type: RequestBodyJsonObject
2145-
value:
2146-
sort_order: "ASC"
2147-
sort_field: "CREATED_AT"
2148-
- type: RequestBodyJsonObject
2149-
value:
2150-
key: "{{ config['value'] }}"
2151-
- type: RequestBodyJsonObject
2152-
value:
2153-
sort:
2154-
field: "updated_at"
2155-
order: "ascending"
2156-
- type: RequestBodyPlainText
2157-
value: "plain_text_body"
2158-
- type: RequestBodyUrlEncodedForm
2159-
value:
2160-
param1: "value1"
2161-
param2: "{{ config['param2_value'] }}"
2162-
- type: RequestBodyGraphQL
2163-
value:
2164-
query:
2165-
param1: "value1"
2166-
param2: "{{ config['param2_value'] }}"
21672143
error_handler:
21682144
title: Error Handler
21692145
description: Error handler component that defines how to handle errors.
@@ -3145,28 +3121,19 @@ definitions:
31453121
type:
31463122
type: string
31473123
enum: [ParentStreamConfig]
3148-
lazy_read_pointer:
3149-
title: Lazy Read Pointer
3150-
description: If set, this will enable lazy reading, using the initial read of parent records to extract child records.
3151-
type: array
3152-
default: []
3153-
items:
3154-
type: string
3155-
interpolation_context:
3156-
- config
3124+
stream:
3125+
title: Parent Stream
3126+
description: Reference to the parent stream.
3127+
anyOf:
3128+
- "$ref": "#/definitions/DeclarativeStream"
3129+
- "$ref": "#/definitions/StateDelegatingStream"
31573130
parent_key:
31583131
title: Parent Key
31593132
description: The primary key of records from the parent stream that will be used during the retrieval of records for the current substream. This parent identifier field is typically a characteristic of the child records being extracted from the source API.
31603133
type: string
31613134
examples:
31623135
- "id"
31633136
- "{{ config['parent_record_id'] }}"
3164-
stream:
3165-
title: Parent Stream
3166-
description: Reference to the parent stream.
3167-
anyOf:
3168-
- "$ref": "#/definitions/DeclarativeStream"
3169-
- "$ref": "#/definitions/StateDelegatingStream"
31703137
partition_field:
31713138
title: Current Parent Key Value Identifier
31723139
description: While iterating over parent records during a sync, the parent_key value can be referenced by using this field.
@@ -3183,6 +3150,15 @@ definitions:
31833150
description: Indicates whether the parent stream should be read incrementally based on updates in the child stream.
31843151
type: boolean
31853152
default: false
3153+
lazy_read_pointer:
3154+
title: Lazy Read Pointer
3155+
description: If set, this will enable lazy reading, using the initial read of parent records to extract child records.
3156+
type: array
3157+
default: []
3158+
items:
3159+
type: string
3160+
interpolation_context:
3161+
- config
31863162
extra_fields:
31873163
title: Extra Fields
31883164
description: Array of field paths to include as additional fields in the stream slice. Each path is an array of strings representing keys to access fields in the respective parent record. Accessible via `stream_slice.extra_fields`. Missing fields are set to `None`.
@@ -3616,18 +3592,18 @@ definitions:
36163592
default: false
36173593
partition_router:
36183594
title: Partition Router
3619-
description: PartitionRouter component that describes how to partition the stream, enabling incremental syncs and checkpointing.
3620-
default: []
3595+
description: Used to iteratively execute requests over a set of values, such as a parent stream's records or a list of constant values.
36213596
anyOf:
3622-
- "$ref": "#/definitions/ListPartitionRouter"
36233597
- "$ref": "#/definitions/SubstreamPartitionRouter"
3598+
- "$ref": "#/definitions/ListPartitionRouter"
36243599
- "$ref": "#/definitions/GroupingPartitionRouter"
36253600
- "$ref": "#/definitions/CustomPartitionRouter"
36263601
- type: array
3602+
title: Multiple Partition Routers
36273603
items:
36283604
anyOf:
3629-
- "$ref": "#/definitions/ListPartitionRouter"
36303605
- "$ref": "#/definitions/SubstreamPartitionRouter"
3606+
- "$ref": "#/definitions/ListPartitionRouter"
36313607
- "$ref": "#/definitions/GroupingPartitionRouter"
36323608
- "$ref": "#/definitions/CustomPartitionRouter"
36333609
$parameters:
@@ -4259,6 +4235,11 @@ definitions:
42594235
- "$ref": "#/definitions/HttpComponentsResolver"
42604236
- "$ref": "#/definitions/ConfigComponentsResolver"
42614237
- "$ref": "#/definitions/ParametrizedComponentsResolver"
4238+
use_parent_parameters:
4239+
title: Use Parent Parameters
4240+
description: Whether or not to prioritize parent parameters over component parameters when constructing dynamic streams. Defaults to true for backward compatibility.
4241+
type: boolean
4242+
default: true
42624243
required:
42634244
- type
42644245
- stream_template
@@ -4326,10 +4307,9 @@ definitions:
43264307
- query
43274308
properties:
43284309
query:
4329-
type: object
4330-
additionalProperties: true
4310+
type: string
43314311
description: The GraphQL query to be executed
4332-
default: {}
4312+
default: "query {\n \n}"
43334313
additionalProperties: true
43344314
DpathValidator:
43354315
title: Dpath Validator

airbyte_cdk/sources/declarative/interpolation/macros.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
import builtins
66
import datetime
7+
import re
78
import typing
89
from typing import Optional, Union
910
from urllib.parse import quote_plus
@@ -194,6 +195,18 @@ def sanitize_url(value: str) -> str:
194195
return sanitization_strategy(value)
195196

196197

198+
def camel_case_to_snake_case(value: str) -> str:
199+
"""
200+
Converts CamelCase strings to snake_case format
201+
202+
Usage:
203+
`"{{ camel_case_to_snake_case('CamelCase') }}"`
204+
:param value: string to convert from CamelCase to snake_case
205+
:return: snake_case formatted string
206+
"""
207+
return re.sub(r"(?<!^)(?=[A-Z])", "_", value).lower()
208+
209+
197210
_macros_list = [
198211
now_utc,
199212
today_utc,
@@ -206,5 +219,6 @@ def sanitize_url(value: str) -> str:
206219
today_with_timezone,
207220
str_to_datetime,
208221
sanitize_url,
222+
camel_case_to_snake_case,
209223
]
210224
macros = {f.__name__: f for f in _macros_list}

airbyte_cdk/sources/declarative/manifest_declarative_source.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -553,9 +553,13 @@ def _dynamic_stream_configs(
553553
for dynamic_stream in components_resolver.resolve_components(
554554
stream_template_config=stream_template_config
555555
):
556+
# Get the use_parent_parameters configuration from the dynamic definition
557+
# Default to True for backward compatibility, since connectors were already using it by default when this param was added
558+
use_parent_parameters = dynamic_definition.get("use_parent_parameters", True)
559+
556560
dynamic_stream = {
557561
**ManifestComponentTransformer().propagate_types_and_parameters(
558-
"", dynamic_stream, {}, use_parent_parameters=True
562+
"", dynamic_stream, {}, use_parent_parameters=use_parent_parameters
559563
)
560564
}
561565

0 commit comments

Comments
 (0)