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

[low code connectors] read configs from package_data #15810

Merged
merged 3 commits into from
Aug 20, 2022
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
3 changes: 3 additions & 0 deletions airbyte-cdk/python/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.1.78
- Fix yaml config parsing when running from docker container

## 0.1.77
- Add schema validation for declarative YAML connector configs

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def check_connection(self, source: Source, logger: logging.Logger, config: Mappi
records = stream.read_records(sync_mode=SyncMode.full_refresh)
next(records)
except Exception as error:
return False, f"Unable to connect to stream {stream} - {error}"
return False, f"Unable to connect to stream {stream_name} - {error}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for declarative yaml files we end up printing the entire yaml config in the UI which is pretty ugly and makes it hard to see the real error message

else:
raise ValueError(f"{stream_name} is not part of the catalog. Expected one of {stream_name_to_stream.keys()}")
return True, None
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import inspect
import json
import logging
import pkgutil
import typing
from dataclasses import dataclass, fields
from enum import Enum, EnumMeta
Expand Down Expand Up @@ -65,9 +66,11 @@ def streams(self, config: Mapping[str, Any]) -> List[Stream]:
return [self._factory.create_component(stream_config, config, True)() for stream_config in self._stream_configs()]

def _read_and_parse_yaml_file(self, path_to_yaml_file):
with open(path_to_yaml_file, "r") as f:
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

open() only works running locally and I am not sure how. this passes SAT, something we should follow up on. But replacing this with how we read spec files fixes the issue as long as we mount the package files in the connectors setup.py

config_content = f.read()
return YamlParser().parse(config_content)
package = self.__class__.__module__.split(".")[0]

yaml_config = pkgutil.get_data(package, path_to_yaml_file)
decoded_yaml = yaml_config.decode()
return YamlParser().parse(decoded_yaml)

def _validate_source(self):
full_config = {}
Expand Down
2 changes: 1 addition & 1 deletion airbyte-cdk/python/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

setup(
name="airbyte-cdk",
version="0.1.77",
version="0.1.78",
description="A framework for writing Airbyte Connectors.",
long_description=README,
long_description_content_type="text/markdown",
Expand Down
Loading