-
Notifications
You must be signed in to change notification settings - Fork 4.4k
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] replace file retrieval with pkgutil to fix getting schema files #15814
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
ca8d7ba
replace file retrieval with pkgutil to fix getting schema files
brianjlai 396f57f
slightly better error handling on missing files
brianjlai 092f5e0
filter our schema gen warnings for some classes that cannot generate …
brianjlai b553160
add comment for todo
brianjlai 06c4e59
add changelog and setup before publish
brianjlai File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
airbyte-cdk/python/unit_tests/sources/declarative/schema/test_json_schema.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# | ||
# Copyright (c) 2022 Airbyte, Inc., all rights reserved. | ||
# | ||
|
||
import pytest | ||
from airbyte_cdk.sources.declarative.schema import JsonSchema | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"test_name, input_path, expected_resource, expected_path", | ||
[ | ||
("path_prefixed_with_dot", "./source_example/schemas/lists.json", "source_example", "schemas/lists.json"), | ||
("path_prefixed_with_slash", "/source_example/schemas/lists.json", "source_example", "schemas/lists.json"), | ||
("path_starting_with_source", "source_example/schemas/lists.json", "source_example", "schemas/lists.json"), | ||
("path_starting_missing_source", "schemas/lists.json", "schemas", "lists.json"), | ||
("path_with_file_only", "lists.json", "", "lists.json"), | ||
("empty_path_does_not_crash", "", "", ""), | ||
("empty_path_with_slash_does_not_crash", "/", "", ""), | ||
], | ||
) | ||
def test_extract_resource_and_schema_path(test_name, input_path, expected_resource, expected_path): | ||
json_schema = JsonSchema(input_path, {}, {}) | ||
actual_resource, actual_path = json_schema.extract_resource_and_schema_path(input_path) | ||
|
||
assert actual_resource == expected_resource | ||
assert actual_path == expected_path |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't love this solution of splitting the URL. As mentioned in the below comment, this is a slight hack for us to figure out what resource the schemas are mounted under. Because setup.py mounts them in the
source_sentry
resource for example, we need to figure out from theairbyte_cdk
module what the original source name was. All existing configs already prefix the source name so we can extract it from the first part of the path.An alternative that I thought about was adding a new field to the JsonSchema dataclass called resource. However, I didn't like that because it will in 100% of cases always end up being the same as the name of the connector. It's also a weak abstraction and exposes our underlying file parsing mechanism by breaking it into two parts.