Skip to content

Commit da8e3b2

Browse files
author
maxi297
committed
Add file_based information in discovered catalog
1 parent ac278b9 commit da8e3b2

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

airbyte_cdk/sources/declarative/concurrent_declarative_source.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,7 @@ def _group_streams(
339339
else None,
340340
logger=self.logger,
341341
cursor=cursor,
342+
supports_file_transfer=bool(file_uploader),
342343
)
343344
)
344345
elif (
@@ -371,6 +372,7 @@ def _group_streams(
371372
cursor_field=None,
372373
logger=self.logger,
373374
cursor=final_state_cursor,
375+
supports_file_transfer=bool(file_uploader),
374376
)
375377
)
376378
elif (
@@ -425,6 +427,7 @@ def _group_streams(
425427
cursor_field=perpartition_cursor.cursor_field.cursor_field_key,
426428
logger=self.logger,
427429
cursor=perpartition_cursor,
430+
supports_file_transfer=bool(file_uploader),
428431
)
429432
)
430433
else:

airbyte_cdk/sources/streams/concurrent/default_stream.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ def __init__(
2929
logger: Logger,
3030
cursor: Cursor,
3131
namespace: Optional[str] = None,
32+
supports_file_transfer: bool = False,
3233
) -> None:
3334
self._stream_partition_generator = partition_generator
3435
self._name = name
@@ -39,6 +40,7 @@ def __init__(
3940
self._logger = logger
4041
self._cursor = cursor
4142
self._namespace = namespace
43+
self._supports_file_transfer = supports_file_transfer
4244

4345
def generate_partitions(self) -> Iterable[Partition]:
4446
yield from self._stream_partition_generator.generate()
@@ -68,6 +70,7 @@ def as_airbyte_stream(self) -> AirbyteStream:
6870
json_schema=dict(self._json_schema),
6971
supported_sync_modes=[SyncMode.full_refresh],
7072
is_resumable=False,
73+
is_file_based=self._supports_file_transfer,
7174
)
7275

7376
if self._namespace:

unit_tests/sources/declarative/file/test_file_stream.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
from airbyte_cdk.sources.declarative.yaml_declarative_source import YamlDeclarativeSource
88
from airbyte_cdk.test.catalog_builder import CatalogBuilder, ConfiguredAirbyteStreamBuilder
99
from airbyte_cdk.test.entrypoint_wrapper import EntrypointOutput
10+
from airbyte_cdk.test.entrypoint_wrapper import discover as entrypoint_discover
1011
from airbyte_cdk.test.entrypoint_wrapper import read as entrypoint_read
1112
from airbyte_cdk.test.state_builder import StateBuilder
1213

@@ -49,6 +50,10 @@ def read(
4950
_source(catalog, config, state), config, catalog, state, expecting_exception
5051
)
5152

53+
def discover(config_builder: ConfigBuilder, expecting_exception: bool = False) -> EntrypointOutput:
54+
config = config_builder.build()
55+
return entrypoint_discover(_source(CatalogBuilder().build(), config), config, expecting_exception)
56+
5257

5358
class FileStreamTest(TestCase):
5459
def _config(self) -> ConfigBuilder:
@@ -90,3 +95,9 @@ def test_get_article_attachments(self) -> None:
9095
assert file_reference.file_url
9196
assert file_reference.file_relative_path
9297
assert file_reference.file_size_bytes
98+
99+
def test_discover_article_attachments(self) -> None:
100+
output = discover(self._config())
101+
102+
article_attachments_stream = next(filter(lambda stream: stream.name == "article_attachments", output.catalog.catalog.streams))
103+
assert article_attachments_stream.is_file_based

0 commit comments

Comments
 (0)