11
11
12
12
from airbyte import exceptions as exc
13
13
from airbyte ._executors .declarative import DeclarativeExecutor
14
- from airbyte ._executors .docker import DockerExecutor
14
+ from airbyte ._executors .docker import DEFAULT_AIRBYTE_CONTAINER_TEMP_DIR , DockerExecutor
15
15
from airbyte ._executors .local import PathExecutor
16
16
from airbyte ._executors .python import VenvExecutor
17
17
from airbyte ._util .meta import which
@@ -42,8 +42,8 @@ def _try_get_source_manifest(
42
42
43
43
Raises:
44
44
- `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 .
47
47
"""
48
48
if source_name is None :
49
49
raise exc .PyAirbyteInputError (
@@ -62,7 +62,16 @@ def _try_get_source_manifest(
62
62
url = manifest_url ,
63
63
headers = {"User-Agent" : f"PyAirbyte/{ get_version ()} " },
64
64
)
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
+
66
75
try :
67
76
return cast ("dict" , yaml .safe_load (response .text ))
68
77
except yaml .YAMLError as ex :
@@ -115,7 +124,7 @@ def _get_local_executor(
115
124
)
116
125
117
126
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
119
128
name : str ,
120
129
* ,
121
130
version : str | None = None ,
@@ -217,21 +226,24 @@ def get_connector_executor( # noqa: PLR0912, PLR0913, PLR0915 # Too many branch
217
226
if ":" not in docker_image :
218
227
docker_image = f"{ docker_image } :{ version or 'latest' } "
219
228
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
221
231
222
232
local_mount_dir = Path ().absolute () / name
223
233
local_mount_dir .mkdir (exist_ok = True )
224
234
235
+ volumes = {
236
+ local_mount_dir : "/local" ,
237
+ host_temp_dir : container_temp_dir ,
238
+ }
225
239
docker_cmd = [
226
240
"docker" ,
227
241
"run" ,
228
242
"--rm" ,
229
243
"-i" ,
230
- "--volume" ,
231
- f"{ local_mount_dir } :/local/" ,
232
- "--volume" ,
233
- f"{ temp_dir } :{ temp_dir } " ,
234
244
]
245
+ for local_dir , container_dir in volumes .items ():
246
+ docker_cmd .extend (["--volume" , f"{ local_dir } :{ container_dir } " ])
235
247
236
248
if use_host_network is True :
237
249
docker_cmd .extend (["--network" , "host" ])
@@ -241,6 +253,7 @@ def get_connector_executor( # noqa: PLR0912, PLR0913, PLR0915 # Too many branch
241
253
return DockerExecutor (
242
254
name = name ,
243
255
executable = docker_cmd ,
256
+ volumes = volumes ,
244
257
)
245
258
246
259
if source_manifest :
0 commit comments