如何通过PyAirbyte加载本地修改的Source-Appsflyer连接器?
解决PyAirbyte加载本地修改版Source-Appsflyer连接器的问题
核心解决方案步骤
1. 正确构建本地修改的连接器可执行文件
进入你的本地Source-Appsflyer目录(/app/source_appsflyer/),执行以下操作确保可执行文件基于修改后的代码生成:
# 清理旧虚拟环境,避免依赖残留 poetry env remove --all # 重新安装开发依赖 poetry install --with dev # 以可编辑模式安装,修改代码后可自动同步到可执行文件 poetry run pip install -e .
执行完成后,poetry虚拟环境的bin目录下会生成source-appsflyer可执行文件,路径就是你之前指定的/root/.cache/pypoetry/virtualenvs/source-appsflyer-OcVLBknA-py3.10/bin/source-appsflyer。
2. 验证本地可执行文件有效性
直接运行可执行文件测试,确认修改已生效:
# 检查配置合法性 /root/.cache/pypoetry/virtualenvs/source-appsflyer-OcVLBknA-py3.10/bin/source-appsflyer check --config configs/appsflyer.json # 查看流结构,确认修改的字段/流存在 /root/.cache/pypoetry/virtualenvs/source-appsflyer-OcVLBknA-py3.10/bin/source-appsflyer discover --config configs/appsflyer.json
3. 修改PyAirbyte代码强制使用本地版本
更新测试代码,添加install_if_missing=False参数阻止PyAirbyte自动从PyPI安装,同时明确指定本地可执行文件路径:
import airbyte as ab import json CONFIG_PATH = "configs/appsflyer.json" with open(CONFIG_PATH, "r") as f: source_config = json.load(f) source = ab.get_source( "source-appsflyer", config=source_config, local_executable="/root/.cache/pypoetry/virtualenvs/source-appsflyer-OcVLBknA-py3.10/bin/source-appsflyer", install_if_missing=False # 关键:禁止自动安装PyPI版本 ) source.select_streams(["my_target_stream"]) all_streams = source.get_selected_streams() read_result = source.read()
常见问题排查
- 仍使用PyPI版本:确认已添加
install_if_missing=False,同时检查local_executable路径是否正确,可执行文件是否存在且能正常运行。 - 依赖冲突:绝对不要将连接器安装到PyAirbyte的Python环境中,两者需保持环境隔离——PyAirbyte仅通过CLI调用连接器可执行文件,无需共享依赖。
- 代码修改未同步:确保用了
poetry run pip install -e .的可编辑安装模式,修改代码后无需重新构建;若使用poetry build,每次修改后需重新构建wheel并安装到虚拟环境。
内容的提问来源于stack exchange,提问作者nickolasclarke
相关产品推荐
相关产品推荐

