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.

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

Number of files per transfer batch for new sessions.

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.

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()