Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "[Low Code CDK] Pass DeclarativeStream's name into DefaultSchemaLoader (#21516)" #21649

Merged
merged 1 commit into from
Jan 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def create_declarative_stream(model: DeclarativeStreamModel, config: Config, **k
if model.schema_loader:
schema_loader = _create_component_from_model(model=model.schema_loader, config=config)
else:
schema_loader = DefaultSchemaLoader(config=config, name=model.name, options=model.options)
schema_loader = DefaultSchemaLoader(config=config, options=model.options)

transformations = []
if model.transformations:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,9 @@ class DefaultSchemaLoader(SchemaLoader, JsonSchemaMixin):
"""

config: Config
name: InitVar[str]
options: InitVar[Mapping[str, Any]]

def __post_init__(self, name: str, options: Mapping[str, Any]):
options = options or {}
if "name" not in options:
options["name"] = name
def __post_init__(self, options: Mapping[str, Any]):
self._options = options
self.default_loader = JsonFileSchemaLoader(options=options, config=self.config)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1011,37 +1011,3 @@ def test_add_fields(self):
)
]
assert stream.transformations == expected

def test_default_schema_loader(self):
component_definition = {
"type": "DeclarativeStream",
"name": "test",
"primary_key": [],
"retriever": {
"type": "SimpleRetriever",
"name": "test",
"primary_key": [],
"requester": {
"type": "HttpRequester",
"name": "test",
"url_base": "http://localhost:6767/",
"path": "items/",
"request_options_provider": {
"request_parameters": {},
"request_headers": {},
"request_body_json": {},
"type": "InterpolatedRequestOptionsProvider",
},
"authenticator": {"type": "BearerAuthenticator", "api_token": "{{ config['api_key'] }}"},
},
"record_selector": {"type": "RecordSelector", "extractor": {"type": "DpathExtractor", "field_pointer": ["items"]}},
"paginator": {"type": "NoPagination"},
},
}
resolved_manifest = resolver.preprocess_manifest(component_definition)
propagated_source_config = ManifestComponentTransformer().propagate_types_and_options("", resolved_manifest, {})
stream = factory.create_component(
model_type=DeclarativeStreamModel, component_definition=propagated_source_config, config=input_config
)
schema_loader = stream.schema_loader
assert schema_loader.default_loader._get_json_filepath() == f"./{stream.name}.json"