1111
1212from airbyte import exceptions as exc
1313from airbyte ._executors .declarative import DeclarativeExecutor
14- from airbyte ._executors .docker import DockerExecutor
14+ from airbyte ._executors .docker import DEFAULT_AIRBYTE_CONTAINER_TEMP_DIR , DockerExecutor
1515from airbyte ._executors .local import PathExecutor
1616from airbyte ._executors .python import VenvExecutor
1717from airbyte ._util .meta import which
@@ -42,8 +42,8 @@ def _try_get_source_manifest(
4242
4343 Raises:
4444 - `PyAirbyteInputError`: If `source_name` is `None`.
45- - `HTTPError `: If fetching the URL was unsuccessful.
46- - `YAMLError`: If parsing the YAML failed .
45+ - `AirbyteConnectorInstallationError `: If the registry file cannot be downloaded or if the
46+ manifest YAML cannot be parsed .
4747 """
4848 if source_name is None :
4949 raise exc .PyAirbyteInputError (
@@ -62,7 +62,16 @@ def _try_get_source_manifest(
6262 url = manifest_url ,
6363 headers = {"User-Agent" : f"PyAirbyte/{ get_version ()} " },
6464 )
65- response .raise_for_status () # Raise HTTPError exception if the download failed
65+ try :
66+ response .raise_for_status () # Raise HTTPError exception if the download failed
67+ except requests .exceptions .HTTPError as ex :
68+ raise exc .AirbyteConnectorInstallationError (
69+ message = "Failed to download the connector manifest." ,
70+ context = {
71+ "manifest_url" : manifest_url ,
72+ },
73+ ) from ex
74+
6675 try :
6776 return cast ("dict" , yaml .safe_load (response .text ))
6877 except yaml .YAMLError as ex :
@@ -115,7 +124,7 @@ def _get_local_executor(
115124 )
116125
117126
118- def get_connector_executor ( # noqa: PLR0912, PLR0913, PLR0915 # Too many branches/arugments /statements
127+ def get_connector_executor ( # noqa: PLR0912, PLR0913, PLR0915, C901 # Too many branches/arguments /statements
119128 name : str ,
120129 * ,
121130 version : str | None = None ,
@@ -139,6 +148,19 @@ def get_connector_executor( # noqa: PLR0912, PLR0913, PLR0915 # Too many branch
139148 bool (source_manifest ),
140149 ]
141150 )
151+
152+ if version and pip_url :
153+ raise exc .PyAirbyteInputError (
154+ message = (
155+ "Cannot specify both version and pip_url. "
156+ "Make sure to specify the connector version directly in the pip_url."
157+ ),
158+ context = {
159+ "version" : version ,
160+ "pip_url" : pip_url ,
161+ },
162+ )
163+
142164 if install_method_count > 1 :
143165 raise exc .PyAirbyteInputError (
144166 message = (
@@ -189,6 +211,7 @@ def get_connector_executor( # noqa: PLR0912, PLR0913, PLR0915 # Too many branch
189211 source_manifest = True
190212 case InstallType .PYTHON :
191213 pip_url = metadata .pypi_package_name
214+ pip_url = f"{ pip_url } =={ version } " if version else pip_url
192215 case _:
193216 docker_image = True
194217
@@ -217,21 +240,24 @@ def get_connector_executor( # noqa: PLR0912, PLR0913, PLR0915 # Too many branch
217240 if ":" not in docker_image :
218241 docker_image = f"{ docker_image } :{ version or 'latest' } "
219242
220- temp_dir = TEMP_DIR_OVERRIDE or Path (tempfile .gettempdir ())
243+ host_temp_dir = TEMP_DIR_OVERRIDE or Path (tempfile .gettempdir ())
244+ container_temp_dir = DEFAULT_AIRBYTE_CONTAINER_TEMP_DIR
221245
222246 local_mount_dir = Path ().absolute () / name
223247 local_mount_dir .mkdir (exist_ok = True )
224248
249+ volumes = {
250+ local_mount_dir : "/local" ,
251+ host_temp_dir : container_temp_dir ,
252+ }
225253 docker_cmd = [
226254 "docker" ,
227255 "run" ,
228256 "--rm" ,
229257 "-i" ,
230- "--volume" ,
231- f"{ local_mount_dir } :/local/" ,
232- "--volume" ,
233- f"{ temp_dir } :{ temp_dir } " ,
234258 ]
259+ for local_dir , container_dir in volumes .items ():
260+ docker_cmd .extend (["--volume" , f"{ local_dir } :{ container_dir } " ])
235261
236262 if use_host_network is True :
237263 docker_cmd .extend (["--network" , "host" ])
@@ -241,6 +267,7 @@ def get_connector_executor( # noqa: PLR0912, PLR0913, PLR0915 # Too many branch
241267 return DockerExecutor (
242268 name = name ,
243269 executable = docker_cmd ,
270+ volumes = volumes ,
244271 )
245272
246273 if source_manifest :
0 commit comments