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] replace emptySchemaLoader with DefaultSchemaLoader #18947

Merged
merged 8 commits into from
Nov 4, 2022

Conversation

brianjlai
Copy link
Contributor

@brianjlai brianjlai commented Nov 4, 2022

What

In #18532 overlooked that now a lot of our contributors might not have defined a JsonSchema in their manifest because it was defaulted. Switching with the EmptySchemaLoader is a regression in being able to read schemas

How

Replaces/renames the EmptySchemaLoader as DefaultSchemaLoader whose default functionality will be to attempt to read from the default location, otherwise return the empty schema.

Recommended reading order

  1. default_schema_loader.py

@github-actions github-actions bot added the CDK Connector Development Kit label Nov 4, 2022
@@ -59,7 +58,6 @@
"DefaultErrorHandler": DefaultErrorHandler,
"DefaultPaginator": DefaultPaginator,
"DpathExtractor": DpathExtractor,
"EmptySchemaLoader": EmptySchemaLoader,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this entirely since I don't really see a use case where a developer should need to define the default.

Copy link
Contributor

Choose a reason for hiding this comment

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

is it worth adding the default schema loader?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's what I meant that we wouldn't need the default loader defined since we don't expect developers to need to define it themselves.

from airbyte_cdk.sources.declarative.schema.schema_loader import SchemaLoader
from airbyte_cdk.sources.declarative.types import Config
from dataclasses_jsonschema import JsonSchemaMixin


@dataclass
class EmptySchemaLoader(SchemaLoader, JsonSchemaMixin):
class DefaultSchemaLoader(SchemaLoader, JsonSchemaMixin):
Copy link
Contributor Author

@brianjlai brianjlai Nov 4, 2022

Choose a reason for hiding this comment

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

The alternative here would have been to fold the defaulting to the empty schema logic into the existing JsonFileSchemaLoader and have that remain as the default. The drawback there is that it starts to blur the line between how errors should be reported when schema files don't exist. I think its good to have very clear failures when a developer explicitly defines their SchemaLoader like when a file does not exist. However, when using the default we should just continue w/ the empty schema like we do for this component.

@brianjlai brianjlai requested a review from girarda November 4, 2022 00:40
@brianjlai brianjlai marked this pull request as ready for review November 4, 2022 00:40
@brianjlai brianjlai requested a review from a team as a code owner November 4, 2022 00:40
@@ -59,7 +58,6 @@
"DefaultErrorHandler": DefaultErrorHandler,
"DefaultPaginator": DefaultPaginator,
"DpathExtractor": DpathExtractor,
"EmptySchemaLoader": EmptySchemaLoader,
Copy link
Contributor

Choose a reason for hiding this comment

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

is it worth adding the default schema loader?

return {}
try:
return self.default_loader.get_json_schema()
except FileNotFoundError:
Copy link
Contributor

Choose a reason for hiding this comment

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

can we add a log message?

@brianjlai
Copy link
Contributor Author

brianjlai commented Nov 4, 2022

/publish-cdk dry-run=true

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

@brianjlai
Copy link
Contributor Author

brianjlai commented Nov 4, 2022

/publish-cdk dry-run=false

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

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