Skip to content

Commit 2cfd4c0

Browse files
aaronsteersdevin-ai-integration[bot]coderabbitai[bot]
authored
feat: Add InstallType.ANY and InstallType.INSTALLABLE enum values (#864)
Co-authored-by: Devin AI <158243242+devin-ai-integration[bot]@users.noreply.github.com> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent a8cf82c commit 2cfd4c0

File tree

2 files changed

+48
-23
lines changed

2 files changed

+48
-23
lines changed

airbyte/mcp/connector_registry.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def list_connectors(
8585
List of connector names.
8686
"""
8787
# Start with the full list of known connectors (all support Docker):
88-
connectors: list[str] = get_available_connectors(install_type=InstallType.DOCKER)
88+
connectors: list[str] = get_available_connectors(install_type=InstallType.ANY)
8989

9090
install_types_list: list[str] | None = resolve_list_of_strings(
9191
install_types, # type: ignore[arg-type] # Type check doesn't understand literal is str

airbyte/registry.py

Lines changed: 47 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,21 @@ class InstallType(str, Enum):
4949
"""The type of installation for a connector."""
5050

5151
YAML = "yaml"
52+
"""Manifest-only connectors that can be run without Docker."""
5253
PYTHON = "python"
54+
"""Python-based connectors available via PyPI."""
5355
DOCKER = "docker"
56+
"""Docker-based connectors (returns all connectors for backward compatibility)."""
5457
JAVA = "java"
58+
"""Java-based connectors."""
59+
60+
INSTALLABLE = "installable"
61+
"""Connectors installable in the current environment (environment-sensitive).
62+
63+
Returns all connectors if Docker is installed, otherwise only Python and YAML.
64+
"""
65+
ANY = "any"
66+
"""All connectors in the registry (environment-independent)."""
5567

5668

5769
class Language(str, Enum):
@@ -154,8 +166,14 @@ def _registry_entry_to_connector_metadata(entry: dict) -> ConnectorMetadata:
154166
)
155167

156168

157-
def _get_registry_cache(*, force_refresh: bool = False) -> dict[str, ConnectorMetadata]:
158-
"""Return the registry cache."""
169+
def _get_registry_cache(
170+
*,
171+
force_refresh: bool = False,
172+
) -> dict[str, ConnectorMetadata]:
173+
"""Return the registry cache.
174+
175+
Result is a mapping of connector name to ConnectorMetadata.
176+
"""
159177
global __cache
160178
if __cache and not force_refresh:
161179
return __cache
@@ -229,35 +247,40 @@ def get_connector_metadata(name: str) -> ConnectorMetadata | None:
229247
return cache[name]
230248

231249

232-
def get_available_connectors(install_type: InstallType | str | None = None) -> list[str]:
250+
def get_available_connectors(
251+
install_type: InstallType | str | None = InstallType.INSTALLABLE,
252+
) -> list[str]:
233253
"""Return a list of all available connectors.
234254
235255
Connectors will be returned in alphabetical order, with the standard prefix "source-".
256+
257+
Args:
258+
install_type: The type of installation for the connector.
259+
Defaults to `InstallType.INSTALLABLE`.
236260
"""
237-
if install_type is None:
238-
# No install type specified. Filter for whatever is runnable.
261+
if install_type is None or install_type == InstallType.INSTALLABLE:
262+
# Filter for installable connectors (default behavior).
239263
if is_docker_installed():
240264
logger.info("Docker is detected. Returning all connectors.")
241-
# If Docker is available, return all connectors.
242-
return sorted(conn.name for conn in _get_registry_cache().values())
265+
return sorted(_get_registry_cache().keys())
243266

244267
logger.info("Docker was not detected. Returning only Python and Manifest-only connectors.")
245-
246-
# If Docker is not available, return only Python and Manifest-based connectors.
247268
return sorted(
248-
conn.name
249-
for conn in _get_registry_cache().values()
250-
if conn.language in {Language.PYTHON, Language.MANIFEST_ONLY}
269+
[
270+
connector_name
271+
for connector_name, conn_info in _get_registry_cache().items()
272+
if conn_info.language in {Language.PYTHON, Language.MANIFEST_ONLY}
273+
]
251274
)
252275

253276
if not isinstance(install_type, InstallType):
254277
install_type = InstallType(install_type)
255278

256279
if install_type == InstallType.PYTHON:
257280
return sorted(
258-
conn.name
259-
for conn in _get_registry_cache().values()
260-
if conn.pypi_package_name is not None
281+
connector_name
282+
for connector_name, conn_info in _get_registry_cache().items()
283+
if conn_info.pypi_package_name is not None
261284
)
262285

263286
if install_type == InstallType.JAVA:
@@ -266,11 +289,13 @@ def get_available_connectors(install_type: InstallType | str | None = None) -> l
266289
stacklevel=2,
267290
)
268291
return sorted(
269-
conn.name for conn in _get_registry_cache().values() if conn.language == Language.JAVA
292+
connector_name
293+
for connector_name, conn_info in _get_registry_cache().items()
294+
if conn_info.language == Language.JAVA
270295
)
271296

272-
if install_type == InstallType.DOCKER:
273-
return sorted(conn.name for conn in _get_registry_cache().values())
297+
if install_type in {InstallType.DOCKER, InstallType.ANY}:
298+
return sorted(_get_registry_cache().keys())
274299

275300
if install_type == InstallType.YAML:
276301
return sorted(
@@ -445,12 +470,12 @@ def get_connector_api_docs_urls(connector_name: str) -> list[ApiDocsUrl]:
445470
Raises:
446471
AirbyteConnectorNotRegisteredError: If the connector is not found in the registry.
447472
"""
448-
if connector_name not in get_available_connectors(InstallType.DOCKER):
473+
if connector_name not in get_available_connectors(InstallType.ANY):
449474
raise exc.AirbyteConnectorNotRegisteredError(
450475
connector_name=connector_name,
451476
context={
452477
"registry_url": _get_registry_url(),
453-
"available_connectors": get_available_connectors(InstallType.DOCKER),
478+
"available_connectors": get_available_connectors(InstallType.ANY),
454479
},
455480
)
456481

@@ -505,12 +530,12 @@ def get_connector_version_history(
505530
>>> for v in versions[:5]:
506531
... print(f"{v.version}: {v.release_date}")
507532
"""
508-
if connector_name not in get_available_connectors(InstallType.DOCKER):
533+
if connector_name not in get_available_connectors(InstallType.ANY):
509534
raise exc.AirbyteConnectorNotRegisteredError(
510535
connector_name=connector_name,
511536
context={
512537
"registry_url": _get_registry_url(),
513-
"available_connectors": get_available_connectors(InstallType.DOCKER),
538+
"available_connectors": get_available_connectors(InstallType.ANY),
514539
},
515540
)
516541

0 commit comments

Comments
 (0)