Skip to content
Open
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
61 changes: 44 additions & 17 deletions airbyte/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,12 +46,24 @@


class InstallType(str, Enum):
"""The type of installation for a connector."""
"""The type of installation for a connector.

Values:
YAML: Manifest-only connectors that can be run without Docker
PYTHON: Python-based connectors available via PyPI
DOCKER: Docker-based connectors (returns all connectors for backward compatibility)
JAVA: Java-based connectors
ANY: All connectors in the registry (environment-independent)
INSTALLABLE: Connectors installable in the current environment (environment-sensitive:
returns all connectors if Docker is installed, otherwise only Python and YAML)
"""

YAML = "yaml"
PYTHON = "python"
DOCKER = "docker"
JAVA = "java"
ANY = "any"
INSTALLABLE = "installable"


class Language(str, Enum):
Expand Down Expand Up @@ -238,17 +250,17 @@ def get_available_connectors(install_type: InstallType | str | None = None) -> l
# No install type specified. Filter for whatever is runnable.
if is_docker_installed():
logger.info("Docker is detected. Returning all connectors.")
# If Docker is available, return all connectors.
return sorted(conn.name for conn in _get_registry_cache().values())

logger.info("Docker was not detected. Returning only Python and Manifest-only connectors.")

# If Docker is not available, return only Python and Manifest-based connectors.
return sorted(
conn.name
for conn in _get_registry_cache().values()
if conn.language in {Language.PYTHON, Language.MANIFEST_ONLY}
)
connectors = _get_registry_cache().values()
else:
logger.info(
"Docker was not detected. Returning only Python and Manifest-only connectors."
)
connectors = (
conn
for conn in _get_registry_cache().values()
if conn.language in {Language.PYTHON, Language.MANIFEST_ONLY}
)
return sorted(conn.name for conn in connectors)

if not isinstance(install_type, InstallType):
install_type = InstallType(install_type)
Expand All @@ -269,9 +281,24 @@ def get_available_connectors(install_type: InstallType | str | None = None) -> l
conn.name for conn in _get_registry_cache().values() if conn.language == Language.JAVA
)

if install_type == InstallType.DOCKER:
if install_type in {InstallType.DOCKER, InstallType.ANY}:
return sorted(conn.name for conn in _get_registry_cache().values())

if install_type == InstallType.INSTALLABLE:
if is_docker_installed():
logger.info("Docker is detected. Returning all connectors.")
connectors = _get_registry_cache().values()
else:
logger.info(
"Docker was not detected. Returning only Python and Manifest-only connectors."
)
connectors = (
conn
for conn in _get_registry_cache().values()
if conn.language in {Language.PYTHON, Language.MANIFEST_ONLY}
)
return sorted(conn.name for conn in connectors)

if install_type == InstallType.YAML:
return sorted(
conn.name
Expand Down Expand Up @@ -445,12 +472,12 @@ def get_connector_api_docs_urls(connector_name: str) -> list[ApiDocsUrl]:
Raises:
AirbyteConnectorNotRegisteredError: If the connector is not found in the registry.
"""
if connector_name not in get_available_connectors(InstallType.DOCKER):
if connector_name not in get_available_connectors(InstallType.ANY):
raise exc.AirbyteConnectorNotRegisteredError(
connector_name=connector_name,
context={
"registry_url": _get_registry_url(),
"available_connectors": get_available_connectors(InstallType.DOCKER),
"available_connectors": get_available_connectors(InstallType.ANY),
},
)

Expand Down Expand Up @@ -505,12 +532,12 @@ def get_connector_version_history(
>>> for v in versions[:5]:
... print(f"{v.version}: {v.release_date}")
"""
if connector_name not in get_available_connectors(InstallType.DOCKER):
if connector_name not in get_available_connectors(InstallType.ANY):
raise exc.AirbyteConnectorNotRegisteredError(
connector_name=connector_name,
context={
"registry_url": _get_registry_url(),
"available_connectors": get_available_connectors(InstallType.DOCKER),
"available_connectors": get_available_connectors(InstallType.ANY),
},
)

Expand Down