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

Conversation

brianjlai
Copy link
Contributor

What

additional fix for https://github.com/airbytehq/oncall/issues/462

yaml_declarative_source.py is not properly reading files when running in a container. The working directory during an operation is not structured the same as the static files. Instead for each connector in setup.py we need to import yaml files so they can be used at runtime. And we can only access them using pkgutil.get_data(). This is the same way that read spec.yaml and spec.json files.

I tested this on a locally running instance of Airbyte. After this change goes out, we need to update all 3 connectors to the latest version of the CDK and add *.yaml to setup.py and change the path_to_yaml to sentry.yaml or whatever source we're fixing.

How

Replace the existing open() command that only works locally with a file reader from pkgutil

@brianjlai brianjlai requested a review from a team as a code owner August 19, 2022 23:11
@github-actions github-actions bot added the CDK Connector Development Kit label Aug 19, 2022
@@ -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

@@ -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

@brianjlai brianjlai requested review from sherifnada and a team August 19, 2022 23:15
@brianjlai
Copy link
Contributor Author

brianjlai commented Aug 20, 2022

/publish-cdk dry-run=true

🕑 https://github.com/airbytehq/airbyte/actions/runs/2892929781
https://github.com/airbytehq/airbyte/actions/runs/2892929781

@brianjlai
Copy link
Contributor Author

brianjlai commented Aug 20, 2022

/publish-cdk dry-run=false

🕑 https://github.com/airbytehq/airbyte/actions/runs/2892954976
https://github.com/airbytehq/airbyte/actions/runs/2892954976

@brianjlai brianjlai merged commit ca65136 into master Aug 20, 2022
@brianjlai brianjlai deleted the brian/fix_declarative_read_yaml branch August 20, 2022 01:16
rodireich pushed a commit that referenced this pull request Aug 25, 2022
* read configs from package_data

* update changelog and setup

* commenting out failing tests in the short term
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CDK Connector Development Kit
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants