Skip to content

Commit 6e37343

Browse files
author
Joe Reuter
authored
Small spec fixes to make sure they work with connector form UI (#21587)
1 parent 0cb8388 commit 6e37343

File tree

14 files changed

+42
-33
lines changed

14 files changed

+42
-33
lines changed

airbyte-config/init/src/main/resources/seed/source_definitions.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1510,7 +1510,7 @@
15101510
- name: S3
15111511
sourceDefinitionId: 69589781-7828-43c5-9f63-8925b1c1ccc2
15121512
dockerRepository: airbyte/source-s3
1513-
dockerImageTag: 0.1.29
1513+
dockerImageTag: 0.1.30
15141514
documentationUrl: https://docs.airbyte.com/integrations/sources/s3
15151515
icon: s3.svg
15161516
sourceType: file
@@ -1558,7 +1558,7 @@
15581558
- name: Sendgrid
15591559
sourceDefinitionId: fbb5fbe2-16ad-4cf4-af7d-ff9d9c316c87
15601560
dockerRepository: airbyte/source-sendgrid
1561-
dockerImageTag: 0.2.16
1561+
dockerImageTag: 0.3.0
15621562
documentationUrl: https://docs.airbyte.com/integrations/sources/sendgrid
15631563
icon: sendgrid.svg
15641564
sourceType: api

airbyte-config/init/src/main/resources/seed/source_specs.yaml

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12660,7 +12660,7 @@
1266012660
supportsNormalization: false
1266112661
supportsDBT: false
1266212662
supported_destination_sync_modes: []
12663-
- dockerImage: "airbyte/source-s3:0.1.29"
12663+
- dockerImage: "airbyte/source-s3:0.1.30"
1266412664
spec:
1266512665
documentationUrl: "https://docs.airbyte.com/integrations/sources/s3"
1266612666
changelogUrl: "https://docs.airbyte.com/integrations/sources/s3"
@@ -12869,14 +12869,10 @@
1286912869
- "infer"
1287012870
- "error"
1287112871
order: 1
12872-
allOf:
12873-
- title: "UnexpectedFieldBehaviorEnum"
12874-
description: "An enumeration."
12875-
enum:
12876-
- "ignore"
12877-
- "infer"
12878-
- "error"
12879-
type: "string"
12872+
enum:
12873+
- "ignore"
12874+
- "infer"
12875+
- "error"
1288012876
block_size:
1288112877
title: "Block Size"
1288212878
description: "The chunk size in bytes to process at a time in memory\
@@ -13236,7 +13232,7 @@
1323613232
supportsNormalization: false
1323713233
supportsDBT: false
1323813234
supported_destination_sync_modes: []
13239-
- dockerImage: "airbyte/source-sendgrid:0.2.16"
13235+
- dockerImage: "airbyte/source-sendgrid:0.3.0"
1324013236
spec:
1324113237
documentationUrl: "https://docs.airbyte.com/integrations/sources/sendgrid"
1324213238
connectionSpecification:
@@ -13256,9 +13252,7 @@
1325613252
order: 0
1325713253
start_time:
1325813254
title: "Start time"
13259-
type:
13260-
- "integer"
13261-
- "string"
13255+
type: "string"
1326213256
description: "Start time in ISO8601 format. Any data before this time point\
1326313257
\ will not be replicated."
1326413258
examples:

airbyte-integrations/connectors/source-s3/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ COPY source_s3 ./source_s3
1717
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
1818
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1919

20-
LABEL io.airbyte.version=0.1.29
20+
LABEL io.airbyte.version=0.1.30
2121
LABEL io.airbyte.name=airbyte/source-s3

airbyte-integrations/connectors/source-s3/acceptance-test-config.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ acceptance_tests:
44
spec:
55
tests:
66
- backward_compatibility_tests_config:
7-
disable_for_version: 0.1.26
7+
# skip because allOf gets converted into enum
8+
disable_for_version: 0.1.29
89
spec_path: integration_tests/spec.json
910

1011
connection:

airbyte-integrations/connectors/source-s3/acceptance-test-docker.sh

100644100755
File mode changed.

airbyte-integrations/connectors/source-s3/integration_tests/spec.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -186,14 +186,7 @@
186186
"default": "infer",
187187
"examples": ["ignore", "infer", "error"],
188188
"order": 1,
189-
"allOf": [
190-
{
191-
"title": "UnexpectedFieldBehaviorEnum",
192-
"description": "An enumeration.",
193-
"enum": ["ignore", "infer", "error"],
194-
"type": "string"
195-
}
196-
]
189+
"enum": ["ignore", "infer", "error"]
197190
},
198191
"block_size": {
199192
"title": "Block Size",

airbyte-integrations/connectors/source-s3/source_s3/source_files_abstract/spec.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,21 @@ def change_format_to_oneOf(schema: dict) -> dict:
8787
schema["properties"][prop]["oneOf"] = schema["properties"][prop].pop("anyOf")
8888
return schema
8989

90+
@staticmethod
91+
def remove_enum_allOf(schema: dict) -> dict:
92+
"""
93+
allOfs are not supported by the UI, but pydantic is automatically writing them for enums.
94+
Unpack them into the root
95+
"""
96+
objects_to_check = schema["properties"]["format"]["oneOf"]
97+
for object in objects_to_check:
98+
for key in object["properties"]:
99+
property = object["properties"][key]
100+
if "allOf" in property and "enum" in property["allOf"][0]:
101+
property["enum"] = property["allOf"][0]["enum"]
102+
property.pop("allOf")
103+
return schema
104+
90105
@staticmethod
91106
def check_provider_added(schema: dict) -> None:
92107
if "provider" not in schema["properties"]:
@@ -110,4 +125,5 @@ def schema(cls, *args: Any, **kwargs: Any) -> Dict[str, Any]:
110125
cls.check_provider_added(schema)
111126
schema = cls.change_format_to_oneOf(schema)
112127
schema = cls.resolve_refs(schema)
128+
schema = cls.remove_enum_allOf(schema)
113129
return schema

airbyte-integrations/connectors/source-sendgrid/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,5 @@ RUN pip install .
1212
ENV AIRBYTE_ENTRYPOINT "python /airbyte/integration_code/main.py"
1313
ENTRYPOINT ["python", "/airbyte/integration_code/main.py"]
1414

15-
LABEL io.airbyte.version=0.2.16
15+
LABEL io.airbyte.version=0.3.0
1616
LABEL io.airbyte.name=airbyte/source-sendgrid

airbyte-integrations/connectors/source-sendgrid/acceptance-test-config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ connector_image: airbyte/source-sendgrid:dev
22
tests:
33
spec:
44
- spec_path: "source_sendgrid/spec.json"
5+
backward_compatibility_tests_config:
6+
disable_for_version: "0.2.16"
57
connection:
68
- config_path: "secrets/config.json"
79
status: "succeed"

airbyte-integrations/connectors/source-sendgrid/source_sendgrid/spec.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
},
1717
"start_time": {
1818
"title": "Start time",
19-
"type": ["integer", "string"],
19+
"type": "string",
2020
"description": "Start time in ISO8601 format. Any data before this time point will not be replicated.",
2121
"examples": [
2222
"2021-12-12",

airbyte-integrations/connectors/source-sendgrid/source_sendgrid/streams.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import datetime
66
import urllib
77
from abc import ABC, abstractmethod
8-
from typing import Any, Iterable, Mapping, MutableMapping, Optional, Union
8+
from typing import Any, Iterable, Mapping, MutableMapping, Optional
99

1010
import pendulum
1111
import requests
@@ -91,7 +91,7 @@ def next_page_token(self, response: requests.Response) -> Optional[Mapping[str,
9191
class SendgridStreamIncrementalMixin(HttpStream, ABC):
9292
cursor_field = "created"
9393

94-
def __init__(self, start_time: Optional[Union[int, str]], **kwargs):
94+
def __init__(self, start_time: Optional[str], **kwargs):
9595
super().__init__(**kwargs)
9696
self._start_time = start_time or 0
9797
if isinstance(self._start_time, str):

airbyte-integrations/connectors/source-sendgrid/unit_tests/unit_test.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
)
2929

3030
FAKE_NOW = pendulum.DateTime(2022, 1, 1, tzinfo=pendulum.timezone("utc"))
31+
FAKE_NOW_ISO_STRING = FAKE_NOW.to_iso8601_string()
3132

3233

3334
@pytest.fixture(name="sendgrid_stream")
@@ -59,7 +60,7 @@ def test_source_wrong_credentials():
5960

6061

6162
def test_messages_stream_request_params(mock_pendulum_now):
62-
start_time = 1558359830
63+
start_time = "2019-05-20T13:43:50.000Z"
6364
stream = Messages(start_time)
6465
state = {"last_event_time": 1558359000}
6566
request_params = stream.request_params(state)
@@ -70,7 +71,7 @@ def test_messages_stream_request_params(mock_pendulum_now):
7071

7172

7273
def test_streams():
73-
streams = SourceSendgrid().streams(config={"apikey": "wrong.api.key123", "start_time": FAKE_NOW})
74+
streams = SourceSendgrid().streams(config={"apikey": "wrong.api.key123", "start_time": FAKE_NOW_ISO_STRING})
7475

7576
assert len(streams) == 15
7677

@@ -89,10 +90,10 @@ def test_pagination(mocker):
8990

9091
@patch.multiple(SendgridStreamIncrementalMixin, __abstractmethods__=set())
9192
def test_stream_state():
92-
stream = SendgridStreamIncrementalMixin(start_time=FAKE_NOW)
93+
stream = SendgridStreamIncrementalMixin(start_time=FAKE_NOW_ISO_STRING)
9394
state = {}
9495
request_params = stream.request_params(stream_state=state)
95-
assert request_params == {"end_time": pendulum.now().int_timestamp, "start_time": FAKE_NOW}
96+
assert request_params == {"end_time": pendulum.now().int_timestamp, "start_time": int(FAKE_NOW.timestamp())}
9697

9798

9899
@pytest.mark.parametrize(

docs/integrations/sources/s3.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@ The Jsonl parser uses pyarrow hence,only the line-delimited JSON format is suppo
209209
210210
| Version | Date | Pull Request | Subject |
211211
|:--------|:-----------|:----------------------------------------------------------------------------------------------------------------|:----------------------------------------------------------------------------------------|
212+
| 0.1.30 | 2023-01-25 | [21587](https://github.com/airbytehq/airbyte/pull/21587) | Make sure spec works as expected in UI |
212213
| 0.1.29 | 2023-01-19 | [21604](https://github.com/airbytehq/airbyte/pull/21604) | Handle OSError: skip unreachable keys and keep working on accessible ones. Warn a customer |
213214
| 0.1.28 | 2023-01-10 | [21210](https://github.com/airbytehq/airbyte/pull/21210) | Update block size for json file format |
214215
| 0.1.27 | 2022-12-08 | [20262](https://github.com/airbytehq/airbyte/pull/20262) | Check config settings for CSV file format |

docs/integrations/sources/sendgrid.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ The connector is restricted by normal Sendgrid [requests limitation](https://sen
7878

7979
| Version | Date | Pull Request | Subject |
8080
|:--------|:-----------|:---------------------------------------------------------|:------------------------------------------------------|
81+
| 0.3.0 | 2023-01-25 | [21587](https://github.com/airbytehq/airbyte/pull/21587) | Make sure spec works as expected in UI - make starttime parameter an ISO string instead of a timestamp |
8182
| 0.2.16 | 2022-11-02 | [18847](https://github.com/airbytehq/airbyte/pull/18847) | Skip the stream on `400, 401 - authorization required` with log message |
8283
| 0.2.15 | 2022-10-19 | [18182](https://github.com/airbytehq/airbyte/pull/18182) | Mark the sendgrid api key secret in the spec |
8384
| 0.2.14 | 2022-09-07 | [16400](https://github.com/airbytehq/airbyte/pull/16400) | Change Start Time config parameter to datetime string |

0 commit comments

Comments
 (0)