Skip to content

Commit

Permalink
fix(connector-builder): add flag to disable cache (#45095)
Browse files Browse the repository at this point in the history
  • Loading branch information
lazebnyi authored Sep 9, 2024
1 parent 52744ec commit 41b8585
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def create_source(config: Mapping[str, Any], limits: TestReadLimits) -> Manifest
limit_pages_fetched_per_slice=limits.max_pages_per_slice,
limit_slices_fetched=limits.max_slices,
disable_retries=True,
disable_cache=True,
),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,13 +159,15 @@ def __init__(
limit_slices_fetched: Optional[int] = None,
emit_connector_builder_messages: bool = False,
disable_retries: bool = False,
disable_cache: bool = False,
message_repository: Optional[MessageRepository] = None,
):
self._init_mappings()
self._limit_pages_fetched_per_slice = limit_pages_fetched_per_slice
self._limit_slices_fetched = limit_slices_fetched
self._emit_connector_builder_messages = emit_connector_builder_messages
self._disable_retries = disable_retries
self._disable_cache = disable_cache
self._message_repository = message_repository or InMemoryMessageRepository( # type: ignore
self._evaluate_log_level(emit_connector_builder_messages)
)
Expand Down Expand Up @@ -825,6 +827,8 @@ def create_http_requester(self, model: HttpRequesterModel, decoder: Decoder, con
assert model.use_cache is not None # for mypy
assert model.http_method is not None # for mypy

use_cache = model.use_cache and not self._disable_cache

return HttpRequester(
name=name,
url_base=model.url_base,
Expand All @@ -837,7 +841,7 @@ def create_http_requester(self, model: HttpRequesterModel, decoder: Decoder, con
disable_retries=self._disable_retries,
parameters=model.parameters or {},
message_repository=self._message_repository,
use_cache=model.use_cache,
use_cache=use_cache,
decoder=decoder,
stream_response=decoder.is_stream_response() if decoder else False,
)
Expand Down Expand Up @@ -1199,6 +1203,7 @@ def _create_message_repository_substream_wrapper(self, model: ParentStreamConfig
limit_slices_fetched=self._limit_slices_fetched,
emit_connector_builder_messages=self._emit_connector_builder_messages,
disable_retries=self._disable_retries,
disable_cache=self._disable_cache,
message_repository=LogAppenderMessageRepositoryDecorator(
{"airbyte_cdk": {"stream": {"is_substream": True}}, "http": {"is_auxiliary": True}},
self._message_repository,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ def test_create_source():
assert isinstance(source, ManifestDeclarativeSource)
assert source._constructor._limit_pages_fetched_per_slice == limits.max_pages_per_slice
assert source._constructor._limit_slices_fetched == limits.max_slices
assert source._constructor._disable_cache


def request_log_message(request: dict) -> AirbyteMessage:
Expand Down

0 comments on commit 41b8585

Please sign in to comment.