Repository navigation
fix: defer pandas import in ResponseToFileExtractor #1221
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
Patrick Nilan (pnilan)
merged 3 commits into
main
from
devin/1791494270-defer-pandas-import
Oct 21, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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
70 changes: 70 additions & 0 deletions
70
unit_tests/source_declarative_manifest/test_source_declarative_manifest_imports.py
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,70 @@ | ||
| # Copyright (c) 2026 Airbyte, Inc., all rights reserved. | ||
|
|
||
| import json | ||
| import subprocess | ||
| import sys | ||
| from pathlib import Path | ||
|
|
||
| SCRIPT = """ | ||
| import json | ||
| import sys | ||
| from unittest.mock import patch | ||
|
|
||
| import requests_mock | ||
| import yaml | ||
|
|
||
| from airbyte_cdk.cli.source_declarative_manifest import _run | ||
|
|
||
| manifest_path, config_path = sys.argv[1:] | ||
| with open(manifest_path) as manifest_file: | ||
| manifest = yaml.safe_load(manifest_file) | ||
|
|
||
| with patch( | ||
| "airbyte_cdk.cli.source_declarative_manifest._run._is_local_manifest_command", | ||
| return_value=True, | ||
| ): | ||
| with patch( | ||
| "airbyte_cdk.cli.source_declarative_manifest._run.YamlDeclarativeSource._read_and_parse_yaml_file", | ||
| return_value=manifest, | ||
| ): | ||
| with requests_mock.Mocker() as mocker: | ||
| mocker.get( | ||
| "https://pokeapi.co/api/v2/pokemon/blastoise", | ||
| json={"name": "blastoise"}, | ||
| ) | ||
| _run.handle_command(["spec"]) | ||
| _run.handle_command(["check", "--config", config_path]) | ||
| _run.handle_command(["discover", "--config", config_path]) | ||
|
|
||
| print("LOADED_HEAVY_MODULES=" + json.dumps(sorted(m for m in ("pandas", "numpy") if m in sys.modules))) | ||
| """ | ||
|
|
||
|
|
||
| def test_spec_check_discover_do_not_import_pandas_or_numpy( | ||
| valid_local_manifest, valid_local_config_file | ||
| ) -> None: | ||
| """Declarative/SDM start-up must not import pandas or numpy. Import heavy libraries inside the function that needs them; `python -X importtime -c "import airbyte_cdk.cli.source_declarative_manifest._run"` shows which module pulls one in.""" | ||
| result = subprocess.run( | ||
| [ | ||
| sys.executable, | ||
| "-c", | ||
| SCRIPT, | ||
| str(valid_local_manifest), | ||
| str(valid_local_config_file), | ||
| ], | ||
| capture_output=True, | ||
| text=True, | ||
| timeout=120, | ||
| cwd=Path(__file__).resolve().parents[2], | ||
| ) | ||
|
|
||
| output = f"stdout:\n{result.stdout}\nstderr:\n{result.stderr}" | ||
| assert result.returncode == 0, output | ||
| assert '"connectionStatus":{"status":"SUCCEEDED"}' in result.stdout, output | ||
| assert '"catalog"' in result.stdout, output | ||
| marker = next( | ||
| (line for line in result.stdout.splitlines() if line.startswith("LOADED_HEAVY_MODULES=")), | ||
| None, | ||
| ) | ||
| assert marker is not None, output | ||
| assert json.loads(marker.split("=", 1)[1]) == [], output |
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.