Skip to content

Config

Settings management via Pydantic BaseSettings.

q2google.config

Runtime configuration for q2google.

Loads settings from environment variables (prefix Q2GOOGLE_), optional .env in the working directory, and defaults suitable for local CLI use.

Q2GoogleSettings

Bases: BaseSettings

Application settings merged from defaults, .env, and Q2GOOGLE_* environment variables.

Environment variables are uppercase with prefix Q2GOOGLE_; for example, state_dir maps to Q2GOOGLE_STATE_DIR. Unknown env keys are ignored.

Attributes:

Name Type Description
credentials_path Path

Path to the OAuth client secrets JSON (installed application).

token_path Path

Path where the authorized user refresh token is stored.

state_dir Path

Directory containing one JSON file per sync session (used when state_uri is unset).

state_uri str | None

Backend URI whose scheme selects the storage engine; overrides state_dir when set.

session_id str | None

Optional default session identifier when the CLI omits --session-id.

gopro_access_token str

GoPro cloud access token for discovery and CDN URL resolution.

gopro_max_items int

Upper bound passed to GoPro cloud listing.

gopro_prefer_height int

Preferred pixel height when resolving GoPro CDN assets.

google_photos_timeout_seconds float

Total timeout per Library API HTTP request.

chunk_granularity_multiplier int

Multiplier for resumable upload chunk size vs API granularity.

sync_batch_size int

Legacy transfer batch size. When set (env/kwargs) without photo/video overrides, both :attr:sync_photo_batch_size and :attr:sync_video_batch_size inherit it.

sync_photo_batch_size int

Transfer batch size for photo items.

sync_video_batch_size int

Transfer batch size for video items (typically smaller).

photos_library_batch_size int

Number of items per batchCreate call (at most 50).

fail_fast bool

Whether to stop the pipeline after the first persisted error.

download_chunk_size_bytes int

Read/write chunk size for CDN streaming downloads.

cdn_download_sock_connect_seconds float | None

Connect-phase timeout for CDN aiohttp sessions.

temp_dir_prefix str

Prefix for temporary directories used during transfer.

log_level str

Default logging level name for the CLI.

batch_size_for(media_type: MediaType) -> int

Return the transfer batch size configured for media_type.

Parameters:

Name Type Description Default
media_type MediaType

photo or video.

required

Returns:

Type Description
int

attr:sync_photo_batch_size or :attr:sync_video_batch_size.

Raises:

Type Description
ValueError

When media_type is not photo or video.

Source code in q2google/config.py
def batch_size_for(self, media_type: MediaType) -> int:
    """Return the transfer batch size configured for ``media_type``.

    Args:
        media_type: ``photo`` or ``video``.

    Returns:
        :attr:`sync_photo_batch_size` or :attr:`sync_video_batch_size`.

    Raises:
        ValueError: When ``media_type`` is not ``photo`` or ``video``.
    """
    if media_type == "photo":
        return self.sync_photo_batch_size
    if media_type == "video":
        return self.sync_video_batch_size
    raise ValueError(f"Unsupported media_type: {media_type!r}")

get_settings() -> Q2GoogleSettings cached

Return the process-wide settings singleton.

The result is memoized. Call get_settings.cache_clear() before constructing a new Q2GoogleSettings instance when tests mutate the environment.

Returns:

Name Type Description
Parsed Q2GoogleSettings

class:Q2GoogleSettings for the current process.

Source code in q2google/config.py
@lru_cache
def get_settings() -> Q2GoogleSettings:
    """Return the process-wide settings singleton.

    The result is memoized. Call ``get_settings.cache_clear()`` before constructing a new
    ``Q2GoogleSettings`` instance when tests mutate the environment.

    Returns:
        Parsed :class:`Q2GoogleSettings` for the current process.
    """
    return Q2GoogleSettings()