Skip to content

Commit

Permalink
Feat: Add pip_url support in CLI (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsteers authored Oct 9, 2024
1 parent 919a812 commit f3bc4c6
Showing 1 changed file with 21 additions and 0 deletions.
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,
)

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

0 comments on commit f3bc4c6

Please sign in to comment.