Skip to main content

snap_client.SNAPConfig

Runtime configuration for SNAP GPT processing.

Usage

Source

snap_client.SNAPConfig(
    bin=None,
    rasterio_profile=None,
    max_workers=None,
    max_ram_gb=None,
    threads_per_job=None,
    cache_ratio=None,
    auxdata_path=None,
    timeout=(lambda: get_settings().snap.timeout)()
)

Parameters

bin: Path | None = None

A SNAP installation’s bin directory, used to locate the gpt executable. Defaults to SNAP_BIN, then gpt discovered on PATH.

rasterio_profile: dict[str, Any] | None = None

Overrides for the rasterio profile used when rewriting GPT output GeoTIFFs. Merged over {"dtype": "float32", "nodata": "nan"}.

max_workers: int | None = None

Number of parallel GPT subprocesses; at least 1. Defaults to SNAP_MAX_WORKERS (or 1).

max_ram_gb: float | None = None

Total RAM budget across all GPT processes in GB; must be positive and large enough to give every worker a 512 MB heap on top of 3 GB of JVM and OS overhead. Defaults to SNAP_MAX_RAM_GB (or 8).

threads_per_job: int | None = None

Threads per GPT process (-q); at least 1. Defaults to SNAP_THREADS_PER_JOB or cpu_count // max_workers.

cache_ratio: float | None = None

Fraction of the per-process Java heap used for the GPT tile cache (-c); greater than 0 and at most 1. Defaults to SNAP_CACHE_RATIO (or 0.7).

auxdata_path: Path | None = None

Shared SNAP auxdata cache (DEM tiles, orbit files). Defaults to SNAP_AUXDATA_PATH (or ~/.snap/auxdata).

timeout: float | None = (lambda: get_settings().snap.timeout)()
Seconds one GPT run may take before it is stopped and recorded as failed; must be positive and finite, or None for no limit. Defaults to SNAP_TIMEOUT (or 3600), where none means no limit.

Attributes

resolved_gpt_path

The gpt executable this configuration runs, from bin, SNAP_BIN or PATH.

resolved_snap_version
Version of the SNAP installation that gpt belongs to, such as (14, 0, 0), or None if it cannot be determined.

Raises

ValueError

If a resource argument or timeout is out of range, or if the RAM budget cannot cover the workers and max_ram_gb or max_workers was passed.

ConfigurationError
If a SNAP_* environment variable is invalid, if the RAM budget cannot cover the workers and both values come from the environment, or if GPT or the auxdata path cannot be resolved.

Methods

Name Description
__post_init__() Validate configuration and resolve resource budgets.

__post_init__()

Validate configuration and resolve resource budgets.

Usage

Source

__post_init__()