Skip to content
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

Feat: Add install_root arg for get_source(), allows users to override virtualenv base path #268

Merged
merged 3 commits into from
Jun 4, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion airbyte/sources/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def get_connector(

# This non-public function includes the `docker_image` parameter, which is not exposed in the
# public API. See the `experimental` module for more info.
def _get_source( # noqa: PLR0912 # Too many branches
def _get_source( # noqa: PLR0912, PLR0913 # Too many branches
name: str,
config: dict[str, Any] | None = None,
*,
Expand All @@ -55,6 +55,7 @@ def _get_source( # noqa: PLR0912 # Too many branches
local_executable: Path | str | None = None,
docker_image: str | bool = False,
install_if_missing: bool = True,
install_root: Path | None = None,
aaronsteers marked this conversation as resolved.
Show resolved Hide resolved
) -> Source:
"""Get a connector by name and version.
Expand All @@ -79,6 +80,8 @@ def _get_source( # noqa: PLR0912 # Too many branches
(e.g. `my-image:latest`), the version will be appended as a tag (e.g. `my-image:0.1.0`).
install_if_missing: Whether to install the connector if it is not available locally. This
parameter is ignored when local_executable is set.
install_root: (Optional.) The root directory where the virtual environment will be
created. If not provided, the current working directory will be used.
"""
if sum([bool(local_executable), bool(docker_image), bool(pip_url)]) > 1:
raise exc.PyAirbyteInputError(
Expand Down Expand Up @@ -186,6 +189,7 @@ def _get_source( # noqa: PLR0912 # Too many branches
metadata=metadata,
target_version=version,
pip_url=pip_url,
install_root=install_root,
)
if install_if_missing:
executor.ensure_installation()
Expand Down Expand Up @@ -213,6 +217,7 @@ def get_source(
pip_url: str | None = None,
local_executable: Path | str | None = None,
install_if_missing: bool = True,
install_root: Path | None = None,
) -> Source:
"""Get a connector by name and version.
Expand All @@ -233,6 +238,8 @@ def get_source(
automatically in a virtual environment.
install_if_missing: Whether to install the connector if it is not available locally. This
parameter is ignored when local_executable is set.
install_root: (Optional.) The root directory where the virtual environment will be
created. If not provided, the current working directory will be used.
"""
return _get_source(
name=name,
Expand All @@ -242,6 +249,7 @@ def get_source(
pip_url=pip_url,
local_executable=local_executable,
install_if_missing=install_if_missing,
install_root=install_root,
)


Expand Down