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 pip_url support in CLI #416

Merged
merged 1 commit into from
Oct 9, 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
21 changes: 21 additions & 0 deletions airbyte/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def _resolve_source_job(
source: str | None = None,
config: str | None = None,
streams: str | None = None,
pip_url: str | None = None,
) -> Source:
"""Resolve the source job into a configured Source object.

Expand All @@ -187,6 +188,7 @@ def _resolve_source_job(
config: The path to a configuration file for the named source or destination.
streams: A comma-separated list of stream names to select for reading. If set to "*",
all streams will be selected. If not provided, all streams will be selected.
pip_url: Optional. A location from which to install the connector.
"""
config_dict = _resolve_config(config) if config else None
streams_list: str | list[str] = streams or "*"
Expand All @@ -200,6 +202,7 @@ def _resolve_source_job(
docker_image=source,
config=config_dict,
streams=streams_list,
pip_url=pip_url,
)
return source_obj

Expand All @@ -218,6 +221,7 @@ def _resolve_source_job(
local_executable=source_executable,
config=config_dict,
streams=streams_list,
pip_url=pip_url,
)
return source_obj

Expand All @@ -233,13 +237,15 @@ def _resolve_source_job(
name=source_name,
config=config_dict,
streams=streams_list,
pip_url=pip_url,
)


def _resolve_destination_job(
*,
destination: str,
config: str | None = None,
pip_url: str | None = None,
) -> Destination:
"""Resolve the destination job into a configured Destination object.

Expand All @@ -249,6 +255,7 @@ def _resolve_destination_job(
If the destination contains a colon (':'), it will be interpreted as a docker image
and tag.
config: The path to a configuration file for the named source or destination.
pip_url: Optional. A location from which to install the connector.
"""
if not config:
raise PyAirbyteInputError(
Expand All @@ -271,13 +278,15 @@ def _resolve_destination_job(
name=destination_executable.stem,
local_executable=destination_executable,
config=config_dict,
pip_url=pip_url,
)

# else: # Treat the destination as a name.

return get_destination(
name=destination,
config=config_dict,
pip_url=pip_url,
)


Expand All @@ -293,6 +302,15 @@ def _resolve_destination_job(
type=str,
help="The connector name or a path to the local executable.",
)
@click.option(
"--pip-url",
type=str,
help=(
"Optional. The location from which to install the connector. "
"This can be a anything pip accepts, including: a PyPI package name, a local path, "
"a git repository, a git branch ref, etc."
),
)
@click.option(
"--config",
type=str,
Expand All @@ -302,6 +320,7 @@ def _resolve_destination_job(
def validate(
connector: str | None = None,
config: str | None = None,
pip_url: str | None = None,
) -> None:
"""Validate the connector."""
if not connector:
Expand All @@ -315,11 +334,13 @@ def validate(
source=connector,
config=None,
streams=None,
pip_url=pip_url,
)
else: # destination
connector_obj = _resolve_destination_job(
destination=connector,
config=None,
pip_url=pip_url,
aaronsteers marked this conversation as resolved.
Show resolved Hide resolved
)

print("Getting `spec` output from connector...")
Expand Down
Loading