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 # Too many branches/arguments /statements
119128 name : str ,
120129 * ,
121130 version : str | None = None ,
@@ -217,21 +226,24 @@ def get_connector_executor( # noqa: PLR0912, PLR0913, PLR0915 # Too many branch
217226 if ":" not in docker_image :
218227 docker_image = f"{ docker_image } :{ version or 'latest' } "
219228
220- temp_dir = TEMP_DIR_OVERRIDE or Path (tempfile .gettempdir ())
229+ host_temp_dir = TEMP_DIR_OVERRIDE or Path (tempfile .gettempdir ())
230+ container_temp_dir = DEFAULT_AIRBYTE_CONTAINER_TEMP_DIR
221231
222232 local_mount_dir = Path ().absolute () / name
223233 local_mount_dir .mkdir (exist_ok = True )
224234
235+ volumes = {
236+ local_mount_dir : "/local" ,
237+ host_temp_dir : container_temp_dir ,
238+ }
225239 docker_cmd = [
226240 "docker" ,
227241 "run" ,
228242 "--rm" ,
229243 "-i" ,
230- "--volume" ,
231- f"{ local_mount_dir } :/local/" ,
232- "--volume" ,
233- f"{ temp_dir } :{ temp_dir } " ,
234244 ]
245+ for local_dir , container_dir in volumes .items ():
246+ docker_cmd .extend (["--volume" , f"{ local_dir } :{ container_dir } " ])
235247
236248 if use_host_network is True :
237249 docker_cmd .extend (["--network" , "host" ])
@@ -241,6 +253,7 @@ def get_connector_executor( # noqa: PLR0912, PLR0913, PLR0915 # Too many branch
241253 return DockerExecutor (
242254 name = name ,
243255 executable = docker_cmd ,
256+ volumes = volumes ,
244257 )
245258
246259 if source_manifest :
0 commit comments