Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore: Rename override constant to TEMP_DIR_OVERRIDE #370

Merged
merged 1 commit into from
Sep 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,
aaronsteers marked this conversation as resolved.
Show resolved Hide resolved
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
Loading