Skip to content

Commit b10d7a1

Browse files
author
Oleksandr Bazarnov
committed
removed post_resolve_manifest flag
1 parent 748892d commit b10d7a1

File tree

4 files changed

+17
-33
lines changed

4 files changed

+17
-33
lines changed

airbyte_cdk/connector_builder/connector_builder_handler.py

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55

66
from dataclasses import asdict, dataclass, field
7-
from typing import Any, ClassVar, Dict, List, Mapping, Optional
7+
from typing import Any, ClassVar, Dict, List, Mapping
88

99
from airbyte_cdk.connector_builder.test_reader import TestReader
1010
from airbyte_cdk.models import (
@@ -55,6 +55,7 @@ def get_limits(config: Mapping[str, Any]) -> TestLimits:
5555
max_streams = command_config.get(MAX_STREAMS_KEY) or DEFAULT_MAXIMUM_STREAMS
5656
return TestLimits(max_records, max_pages_per_slice, max_slices, max_streams)
5757

58+
5859
def normalize_manifest(config: Mapping[str, Any]) -> bool:
5960
"""
6061
Check if the manifest should be normalized.
@@ -63,13 +64,6 @@ def normalize_manifest(config: Mapping[str, Any]) -> bool:
6364
"""
6465
return config.get("__requires_normalization", False)
6566

66-
def post_resolve_manifest(config: Mapping[str, Any]) -> bool:
67-
"""
68-
Check if the manifest should be post-resolved.
69-
:param config: The configuration to check
70-
:return: True if the manifest should be post-resolved, False otherwise.
71-
"""
72-
return config.get("__post_resolve_manifest", False)
7367

7468
def create_source(
7569
config: Mapping[str, Any],
@@ -81,7 +75,6 @@ def create_source(
8175
emit_connector_builder_messages=True,
8276
source_config=manifest,
8377
normalize_manifest=normalize_manifest(config),
84-
post_resolve_manifest=post_resolve_manifest(config),
8578
component_factory=ModelToComponentFactory(
8679
emit_connector_builder_messages=True,
8780
limit_pages_fetched_per_slice=limits.max_pages_per_slice,

airbyte_cdk/connector_builder/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,10 @@ def handle_connector_builder_request(
8888
raise ValueError(f"Unrecognized command {command}.")
8989

9090

91-
def handle_request(args: List[str], post_resolve_manifest: Optional[bool] = False) -> str:
91+
def handle_request(args: List[str]) -> str:
9292
command, config, catalog, state = get_config_and_catalog_from_args(args)
9393
limits = get_limits(config)
94-
source = create_source(config, limits, post_resolve_manifest=post_resolve_manifest)
94+
source = create_source(config, limits)
9595
return orjson.dumps(
9696
AirbyteMessageSerializer.dump(
9797
handle_connector_builder_request(source, command, config, catalog, state, limits)

airbyte_cdk/sources/declarative/manifest_declarative_source.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def __init__(
9191
debug: bool = False,
9292
emit_connector_builder_messages: bool = False,
9393
component_factory: Optional[ModelToComponentFactory] = None,
94-
post_resolve_manifest: Optional[bool] = False,
94+
normalize_manifest: Optional[bool] = False,
9595
) -> None:
9696
"""
9797
Args:
@@ -100,6 +100,8 @@ def __init__(
100100
debug: True if debug mode is enabled.
101101
emit_connector_builder_messages: True if messages should be emitted to the connector builder.
102102
component_factory: optional factory if ModelToComponentFactory's default behavior needs to be tweaked.
103+
normalize_manifest: Optional flag to indicate if the manifest should be normalized.
104+
post_resolve_manifest: Optional flag to indicate if the manifest should be resolved after normalization.
103105
"""
104106
self.logger = logging.getLogger(f"airbyte.{self.name}")
105107

@@ -119,24 +121,16 @@ def __init__(
119121
"", resolved_source_config, {}
120122
)
121123

122-
if emit_connector_builder_messages:
123-
# Connector Builder Ui rendering requires the manifest to be in a specific format.
124+
if normalize_manifest:
125+
# Connector Builder UI rendering requires the manifest to be in a specific format.
124126
# 1) references have been resolved
125-
# 2) deprecated fields have been migrated
126-
# 3) the commonly used definitions are extracted to the `definitions.shared.*`
127-
# 4) ! the normalized manifest could be validated after the additional UI post-processing.
127+
# 2) the commonly used definitions are extracted to the `definitions.shared.*`
128+
# 3) ! the normalized manifest could be validated only after the additional UI post-processing.
128129
propagated_source_config = ManifestNormalizer(
129130
propagated_source_config,
130131
self._declarative_component_schema,
131132
).normalize()
132133

133-
# The manifest is now in a format that the Connector Builder UI can use.
134-
# however, the local tests may depend on the completely resolved manifest.
135-
if post_resolve_manifest:
136-
propagated_source_config = ManifestReferenceResolver().preprocess_manifest(
137-
propagated_source_config
138-
)
139-
140134
self._source_config = propagated_source_config
141135
self._debug = debug
142136
self._emit_connector_builder_messages = emit_connector_builder_messages

unit_tests/connector_builder/test_connector_builder_handler.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,6 @@ def test_handle_resolve_manifest(valid_resolve_manifest_config_file, dummy_catal
504504
"--catalog",
505505
str(dummy_catalog),
506506
],
507-
post_resolve_manifest=True,
508507
)
509508
assert patched_handle.call_count == 1
510509

@@ -523,7 +522,6 @@ def test_handle_test_read(valid_read_config_file, configured_catalog):
523522
"--catalog",
524523
str(configured_catalog),
525524
],
526-
post_resolve_manifest=True,
527525
)
528526
assert patch.call_count == 1
529527

@@ -875,7 +873,7 @@ def test_handle_429_response():
875873

876874
config = TEST_READ_CONFIG
877875
limits = TestLimits()
878-
source = create_source(config, limits, post_resolve_manifest=True)
876+
source = create_source(config, limits)
879877

880878
with patch("requests.Session.send", return_value=response) as mock_send:
881879
response = handle_connector_builder_request(
@@ -934,7 +932,6 @@ def test_invalid_config_command(invalid_config_file, dummy_catalog):
934932
"--catalog",
935933
str(dummy_catalog),
936934
],
937-
post_resolve_manifest=True,
938935
)
939936

940937

@@ -1002,7 +999,7 @@ def test_create_source():
1002999

10031000
config = {"__injected_declarative_manifest": MANIFEST}
10041001

1005-
source = create_source(config, limits, post_resolve_manifest=True)
1002+
source = create_source(config, limits)
10061003

10071004
assert isinstance(source, ManifestDeclarativeSource)
10081005
assert source._constructor._limit_pages_fetched_per_slice == limits.max_pages_per_slice
@@ -1096,7 +1093,7 @@ def test_read_source(mock_http_stream):
10961093

10971094
config = {"__injected_declarative_manifest": MANIFEST}
10981095

1099-
source = create_source(config, limits, post_resolve_manifest=True)
1096+
source = create_source(config, limits)
11001097

11011098
output_data = read_stream(source, config, catalog, _A_PER_PARTITION_STATE, limits).record.data
11021099
slices = output_data["slices"]
@@ -1143,7 +1140,7 @@ def test_read_source_single_page_single_slice(mock_http_stream):
11431140

11441141
config = {"__injected_declarative_manifest": MANIFEST}
11451142

1146-
source = create_source(config, limits, post_resolve_manifest=True)
1143+
source = create_source(config, limits)
11471144

11481145
output_data = read_stream(source, config, catalog, _A_PER_PARTITION_STATE, limits).record.data
11491146
slices = output_data["slices"]
@@ -1229,7 +1226,7 @@ def test_handle_read_external_requests(deployment_mode, url_base, expected_error
12291226
test_manifest["streams"][0]["$parameters"]["url_base"] = url_base
12301227
config = {"__injected_declarative_manifest": test_manifest}
12311228

1232-
source = create_source(config, limits, post_resolve_manifest=True)
1229+
source = create_source(config, limits)
12331230

12341231
with mock.patch.dict(os.environ, {"DEPLOYMENT_MODE": deployment_mode}, clear=False):
12351232
output_data = read_stream(
@@ -1325,7 +1322,7 @@ def test_handle_read_external_oauth_request(deployment_mode, token_url, expected
13251322
)
13261323
config = {"__injected_declarative_manifest": test_manifest}
13271324

1328-
source = create_source(config, limits, post_resolve_manifest=True)
1325+
source = create_source(config, limits)
13291326

13301327
with mock.patch.dict(os.environ, {"DEPLOYMENT_MODE": deployment_mode}, clear=False):
13311328
output_data = read_stream(

0 commit comments

Comments
 (0)