-
Notifications
You must be signed in to change notification settings - Fork 74
fix(declarative): [DO-NOT-MERGE] pass config into declarative source #1113
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
Open
Aaron ("AJ") Steers (aaronsteers)
wants to merge
13
commits into
main
Choose a base branch
from
devin/1787019774-declarative-config-passthrough
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
5f43def
Use provided config in declarative executor
adileo fcf3197
Add config parameter to executor factory function
adileo 2a118e9
Add config parameter to Source initialization
adileo 33256c0
Apply suggestion from @coderabbitai[bot]
aaronsteers d734058
fix: avoid mutable declarative config defaults
devin-ai-integration[bot] d7da9c8
fix: resolve declarative config from execution args
devin-ai-integration[bot] d42c363
test: cover declarative config resolution paths
devin-ai-integration[bot] 3fb2f86
test: cover component injection during source creation
devin-ai-integration[bot] 27f89dd
fix: satisfy declarative config lint checks
devin-ai-integration[bot] 3dd0ee1
fix: preserve declarative executor call compatibility
devin-ai-integration[bot] 0979735
refactor: centralize declarative source creation
devin-ai-integration[bot] b3dd812
test: align declarative executor test conventions
devin-ai-integration[bot] 95d7aae
fix: preserve declarative component injection
devin-ai-integration[bot] 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
Some comments aren't visible on the classic Files Changed page.
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,127 @@ | ||
| # Copyright (c) 2026 Airbyte, Inc., all rights reserved. | ||
| """Unit tests for declarative executor configuration resolution.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from collections.abc import Iterator | ||
| import json | ||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| import pytest | ||
|
|
||
| from airbyte._executors import declarative | ||
| from airbyte._executors.declarative import DeclarativeExecutor | ||
| from airbyte.sources import util as sources_util | ||
|
|
||
|
|
||
| def test_get_source_passes_config_to_declarative_executor( | ||
| monkeypatch: pytest.MonkeyPatch, | ||
| ) -> None: | ||
| manifest = {"version": "1.0.0"} | ||
| config = {"api_key": "configured"} | ||
|
|
||
| def fake_get_connector_executor(**kwargs: Any) -> DeclarativeExecutor: | ||
| return DeclarativeExecutor( | ||
| name=kwargs["name"], | ||
| manifest=kwargs["source_manifest"], | ||
| config=kwargs["config"], | ||
| components_py="class Component:\n pass\n", | ||
| ) | ||
|
|
||
| monkeypatch.setattr( | ||
| sources_util, | ||
| "get_connector_executor", | ||
| fake_get_connector_executor, | ||
| ) | ||
| monkeypatch.setattr( | ||
| declarative, | ||
| "ConcurrentDeclarativeSource", | ||
| lambda **kwargs: kwargs, | ||
| ) | ||
|
|
||
| source = sources_util.get_source( | ||
| name="source-test", | ||
| config=config, | ||
| source_manifest=manifest, | ||
| ) | ||
|
|
||
| declarative_config = source.executor.declarative_source["config"] | ||
| assert declarative_config["api_key"] == config["api_key"] | ||
| assert declarative_config["__injected_components_py"] | ||
| assert config == {"api_key": "configured"} | ||
|
|
||
|
|
||
| def test_execute_uses_config_set_after_get_source_and_preserves_injected_components( | ||
| monkeypatch: pytest.MonkeyPatch, | ||
| tmp_path: Path, | ||
| ) -> None: | ||
| captured: dict[str, Any] = {} | ||
| manifest = {"version": "1.0.0"} | ||
| late_config = {"api_key": "configured-later"} | ||
|
|
||
| def fake_get_connector_executor(**kwargs: Any) -> DeclarativeExecutor: | ||
| return DeclarativeExecutor( | ||
| name=kwargs["name"], | ||
| manifest=kwargs["source_manifest"], | ||
| config=kwargs["config"], | ||
| components_py="class Component:\n pass\n", | ||
| ) | ||
|
|
||
| class FakeEntrypoint: | ||
| def __init__(self, source: Any) -> None: | ||
| captured["source"] = source | ||
|
|
||
| def parse_args(self, args: list[str]) -> list[str]: | ||
| return args | ||
|
|
||
| def run(self, args: list[str]) -> Iterator[str]: | ||
| yield from args | ||
|
|
||
| monkeypatch.setattr( | ||
| sources_util, | ||
| "get_connector_executor", | ||
| fake_get_connector_executor, | ||
| ) | ||
| monkeypatch.setattr( | ||
| declarative, | ||
| "ConcurrentDeclarativeSource", | ||
| lambda **kwargs: kwargs, | ||
| ) | ||
| monkeypatch.setattr(declarative, "AirbyteEntrypoint", FakeEntrypoint) | ||
|
|
||
| source = sources_util.get_source( | ||
| name="source-test", | ||
| source_manifest=manifest, | ||
| ) | ||
| source.set_config(late_config, validate=False) | ||
| config_path = tmp_path / "config.json" | ||
| config_file_config = { | ||
| **source._hydrated_config, | ||
| "__injected_components_py": "bogus", | ||
| "__injected_components_py_checksums": {"md5": "bogus"}, | ||
| } | ||
| config_path.write_text( | ||
| json.dumps(config_file_config), | ||
| encoding="utf-8", | ||
| ) | ||
|
|
||
| list(source.executor.execute(["read", "--config", str(config_path)])) | ||
|
|
||
| config = captured["source"]["config"] | ||
| assert config["api_key"] == late_config["api_key"] | ||
| assert config["__injected_components_py"] == "class Component:\n pass\n" | ||
| assert config["__injected_components_py_checksums"]["md5"] | ||
|
|
||
|
|
||
| def test_declarative_executor_copies_config_before_component_injection() -> None: | ||
| config = {"api_key": "configured"} | ||
|
|
||
| DeclarativeExecutor( | ||
| name="source-test", | ||
| manifest={"version": "1.0.0"}, | ||
| config=config, | ||
| components_py="class Component:\n pass\n", | ||
| ) | ||
|
|
||
| assert config == {"api_key": "configured"} |
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.
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.
π Not changing here, flagging for the maintainer. Correct that those two bullets are wrong β
manifestis parsed withyaml.safe_load()and the annotation isdict | Path, so neither "read as a json file" nor thestr/HTTP-path bullet matches the code. Both predate this PR, though; this branch only added theconfigbullet. Leaving them alone to keep this diff to the #868 fix β happy to correct them here if Aaron ("AJ") Steers (@aaronsteers) prefers.