Skip to content

Commit

Permalink
fix: using user-level directories for temporary files
Browse files Browse the repository at this point in the history
  • Loading branch information
niyasrad committed Sep 17, 2024
1 parent f10933f commit 7403b02
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 3 additions & 2 deletions airbyte/_executors/util.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Copyright (c) 2023 Airbyte, Inc., all rights reserved.
from __future__ import annotations

import tempfile
from pathlib import Path
from typing import TYPE_CHECKING, Literal, cast

Expand Down Expand Up @@ -203,7 +202,9 @@ def get_connector_executor( # noqa: PLR0912, PLR0913 # Too complex
if ":" not in docker_image:
docker_image = f"{docker_image}:{version or 'latest'}"

temp_dir = tempfile.gettempdir()
temp_dir = Path.home() / ".airbyte" / "temp"
temp_dir.mkdir(exist_ok=True)

local_mount_dir = Path().absolute() / name
local_mount_dir.mkdir(exist_ok=True)

Expand Down
4 changes: 4 additions & 0 deletions airbyte/_util/temp_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ def as_temp_files(files_contents: list[dict | str]) -> Generator[list[str], Any,
"""Write the given contents to temporary files and yield the file paths as strings."""
temp_files: list[Any] = []
try:
temp_dir = Path.home() / ".airbyte" / "temp"
temp_dir.mkdir(exist_ok=True)

for content in files_contents:
use_json = isinstance(content, dict)
temp_file = tempfile.NamedTemporaryFile( # noqa: SIM115 # Avoiding context manager
mode="w+t",
delete=False,
encoding="utf-8",
dir=temp_dir,
suffix=".json" if use_json else ".txt",
)
temp_file.write(
Expand Down

0 comments on commit 7403b02

Please sign in to comment.