-
Notifications
You must be signed in to change notification settings - Fork 72
Feat: Add experimental support for low-code source execution via manifest YAML #175
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
Merged
Aaron ("AJ") Steers (aaronsteers)
merged 38 commits into
main
from
aj/feat/source-declarative-manifest
Jun 4, 2024
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit
Hold shift + click to select a range
47ec7a4
skeleton of native declarative source support
aaronsteers 8288ce8
improve implementation
aaronsteers be4ecd4
update with native execution, wrapping the proper CDK classes
aaronsteers d9445ca
Merge remote-tracking branch 'origin/main' into aj/feat/source-declar…
aaronsteers 95d0561
update pyproject.toml
aaronsteers 8857c41
add missing property 'reported_version'
aaronsteers 2b263dc
partially working sync! 🎉
aaronsteers 9f828d1
downgrade cdk to declared version in manifest
aaronsteers 28cdb77
lint fix
aaronsteers 24431d6
add error handler in declarative yaml
aaronsteers 3a8e79f
fix start page
aaronsteers 1ae64ac
feat: enable detecting yaml declarative sources in `get_available_con…
aaronsteers 564f572
feat: auto-download manifest.yaml from github `master` branch
aaronsteers 46be6f2
update example script
aaronsteers b438206
add hard-coded low-code exclusions
aaronsteers 925f4de
raise errors when low-code definition isn't viable
aaronsteers bb49e79
print debug info on non-installable connectors
aaronsteers 8ecf5cc
add simple test
aaronsteers 5e18e3d
include printed count of connectors in example script
aaronsteers 8f0d838
lint fixes
aaronsteers 438fbce
chore: bump source-faker and airbyte-cdk to latest
aaronsteers b1c5c71
add integration tests for all hard-coded failures
aaronsteers 8e28bfc
remove stale failures list
aaronsteers 82baf69
tests: only autouse source registry in specific files
aaronsteers e6b2655
lint fixes
aaronsteers 40cae57
fix autouse
aaronsteers f0183e0
fix some tests
aaronsteers 7623619
add missing fixture inclusions
aaronsteers d3aef35
Merge remote-tracking branch 'origin/main' into aj/feat/source-declar…
aaronsteers b5d0924
improve fixture isolation for 'source_test_registry'
aaronsteers 4376af1
chore: improve error message
aaronsteers b178d33
fix: add new bamboo connector to exception list
aaronsteers 6753854
use enum values directly
aaronsteers 83ead8e
make registry parsing safer and more resilient
aaronsteers 836e00f
bump to latest airbyte-cdk
aaronsteers b34c45d
Auto-fix lint and format issues
8b09522
tests: xfail pokemon no-code on windows
aaronsteers 3cdaf7e
Merge branch 'main' into aj/feat/source-declarative-manifest
aaronsteers 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,104 @@ | ||
| # Copyright (c) 2023 Airbyte, Inc., all rights reserved. | ||
| """Support for declarative yaml source testing.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| import json | ||
| from pathlib import Path | ||
| from typing import TYPE_CHECKING, cast | ||
|
|
||
| from airbyte_cdk.entrypoint import AirbyteEntrypoint | ||
| from airbyte_cdk.sources.declarative.manifest_declarative_source import ManifestDeclarativeSource | ||
|
|
||
| from airbyte._executor import Executor | ||
| from airbyte.exceptions import PyAirbyteInternalError | ||
| from airbyte.sources.base import Source | ||
|
|
||
|
|
||
| if TYPE_CHECKING: | ||
| from collections.abc import Iterator | ||
|
|
||
|
|
||
| class DeclarativeExecutor(Executor): | ||
| """An executor for declarative sources.""" | ||
|
|
||
| def __init__( | ||
| self, | ||
| manifest: str | dict | Path, | ||
| ) -> None: | ||
| """Initialize a declarative executor. | ||
|
|
||
| - If `manifest` is a path, it will be read as a json file. | ||
| - If `manifest` is a string, it will be parsed as an HTTP path. | ||
| - If `manifest` is a dict, it will be used as is. | ||
| """ | ||
| self._manifest_dict: dict | ||
| if isinstance(manifest, Path): | ||
| self._manifest_dict = cast(dict, json.loads(manifest.read_text())) | ||
|
|
||
| elif isinstance(manifest, str): | ||
| # TODO: Implement HTTP path parsing | ||
| raise NotImplementedError("HTTP path parsing is not yet implemented.") | ||
|
|
||
| elif isinstance(manifest, dict): | ||
| self._manifest_dict = manifest | ||
|
|
||
| if not isinstance(self._manifest_dict, dict): | ||
| raise PyAirbyteInternalError(message="Manifest must be a dict.") | ||
|
|
||
| self.declarative_source = ManifestDeclarativeSource(source_config=self._manifest_dict) | ||
| self.reported_version: str | None = None # TODO: Consider adding version detection | ||
|
|
||
| def execute(self, args: list[str]) -> Iterator[str]: | ||
| """Execute the declarative source.""" | ||
| source_entrypoint = AirbyteEntrypoint(self.declarative_source) | ||
| parsed_args = source_entrypoint.parse_args(args) | ||
| yield from source_entrypoint.run(parsed_args) | ||
|
|
||
| def ensure_installation(self, *, auto_fix: bool = True) -> None: | ||
| """No-op. The declarative source is included with PyAirbyte.""" | ||
| _ = auto_fix | ||
| pass | ||
|
|
||
| def install(self) -> None: | ||
| """No-op. The declarative source is included with PyAirbyte.""" | ||
| pass | ||
|
|
||
| def uninstall(self) -> None: | ||
| """No-op. The declarative source is included with PyAirbyte.""" | ||
| pass | ||
|
|
||
|
|
||
| class DeclarativeSource(Source): | ||
| """A declarative source using Airbyte's Yaml low-code/no-code framework.""" | ||
|
|
||
| def __init__( | ||
| self, | ||
| manifest: str | dict | Path, | ||
| ) -> None: | ||
| """Initialize a declarative source. | ||
|
|
||
| Sample usages: | ||
| ```python | ||
| manifest_path = "path/to/manifest.yaml" | ||
|
|
||
| source_a = DeclarativeSource(manifest=Path(manifest_path)) | ||
| source_b = DeclarativeSource(manifest=Path(manifest_path).read_text()) | ||
| source_c = DeclarativeSource(manifest=yaml.load(Path(manifest_path).read_text())) | ||
| ``` | ||
|
|
||
| Args: | ||
| manifest: The manifest for the declarative source. This can be a path to a yaml file, a | ||
| yaml string, or a dict. | ||
| """ | ||
| # TODO: Conform manifest to a dict or str (TBD) | ||
| self.manifest = manifest | ||
|
|
||
| # Initialize the source using the base class implementation | ||
| super().__init__( | ||
| name="Declarative", # TODO: Get name from manifest | ||
| config={ # TODO: Put 'real' config here | ||
| "manifest": manifest, | ||
| }, | ||
| executor=DeclarativeExecutor(manifest), | ||
| ) |
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.