Skip to content

Commit

Permalink
Chore: Rename override constant to TEMP_DIR_OVERRIDE (#370)
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronsteers authored Sep 17, 2024
1 parent e534a3d commit e305043
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
4 changes: 2 additions & 2 deletions airbyte/_executors/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from airbyte._executors.python import VenvExecutor
from airbyte._util.meta import which
from airbyte._util.telemetry import EventState, log_install_state # Non-public API
from airbyte.constants import OVERRIDE_TEMP_DIR
from airbyte.constants import TEMP_DIR_OVERRIDE
from airbyte.sources.registry import ConnectorMetadata, InstallType, get_connector_metadata


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

temp_dir = OVERRIDE_TEMP_DIR or Path(tempfile.gettempdir())
temp_dir = TEMP_DIR_OVERRIDE or Path(tempfile.gettempdir())

local_mount_dir = Path().absolute() / name
local_mount_dir.mkdir(exist_ok=True)
Expand Down
6 changes: 2 additions & 4 deletions airbyte/_util/temp_files.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from pathlib import Path
from typing import TYPE_CHECKING, Any

from airbyte.constants import OVERRIDE_TEMP_DIR
from airbyte.constants import TEMP_DIR_OVERRIDE


if TYPE_CHECKING:
Expand All @@ -23,15 +23,13 @@ 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 = OVERRIDE_TEMP_DIR

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,
dir=TEMP_DIR_OVERRIDE or None,
suffix=".json" if use_json else ".txt",
)
temp_file.write(
Expand Down
2 changes: 1 addition & 1 deletion airbyte/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def _str_to_bool(value: str) -> bool:
return bool(value) and value.lower() not in {"", "0", "false", "f", "no", "n", "off"}


OVERRIDE_TEMP_DIR: Path | None = (
TEMP_DIR_OVERRIDE: Path | None = (
Path(os.environ["AIRBYTE_TEMP_DIR"]) if os.getenv("AIRBYTE_TEMP_DIR") else None
)
"""The directory to use for temporary files.
Expand Down

0 comments on commit e305043

Please sign in to comment.