energy_data_retrieval.sources.cds.client#

Native CDS downloads, immutable requests and checksum-verified local reuse.

The official SDK owns authentication, queue polling and transfer retries. Files retain source units/calendars/intervals; this adapter does not normalize weather.

class energy_data_retrieval.sources.cds.client.CDSRequest(dataset, selection)[source]#

Bases: object

One dataset slug and the selection copied from its CDS download form.

Dataset-specific validity and permissions are checked by CDS. The local boundary validates JSON and excludes credential/transport fields. The stored canonical JSON cannot be changed by later mutation of the caller’s dictionary.

Parameters:
  • dataset (str)

  • selection (Mapping[str, JSONValue])

dataset: str#
property selection: dict[str, JSONValue]#
as_dict()[source]#
Return type:

dict[str, JSONValue]

property sha256: str#
property reference_ids: tuple[str, ...]#
class energy_data_retrieval.sources.cds.client.CDSDownload(path: 'Path', manifest_path: 'Path', sha256: 'str', bytes: 'int', reused: 'bool')[source]#

Bases: object

Parameters:
  • path (Path)

  • manifest_path (Path)

  • sha256 (str)

  • bytes (int)

  • reused (bool)

path: Path#
manifest_path: Path#
sha256: str#
bytes: int#
reused: bool#
class energy_data_retrieval.sources.cds.client.CDSClient(*, timeout_seconds=60, attempts=3, maximum_download_bytes=1073741824, sdk=None)[source]#

Bases: object

Lazy official SDK, sequential transfers and verified completed-download reuse.

timeout_seconds is a network timeout, not a deadline for CDS’s queue. maximum_download_bytes checks advertised size before transfer and actual size afterwards; the SDK owns streaming. No token is accepted in request JSON. sdk permits offline tests or an explicitly configured compatible client.

Parameters:
  • timeout_seconds (int)

  • attempts (int)

  • maximum_download_bytes (int)

  • sdk (_SDK | None)

download(request, output)[source]#

Store one native result and its provenance in a request-hash directory.

Matching complete artifacts are reused after hashing, without SDK imports or credential reads. Failed transfers remove their temporary directory. Interrupted remote jobs are not persisted/reconnected: retrying may submit a new job. Completed earlier monthly requests remain independently reusable.

Parameters:
Return type:

CDSDownload