Skip to content

Config

The config module defines data structures for configuring the Scythe client.

This module includes configuration data classes that group related Scythe arguments, simplifying the construction of the Scythe class.

Classes:

Name Description
HTTPConfig

Groups the HTTP arguments controlling how requests are made.

RetryConfig

Groups the retry arguments controlling how failed requests are retried.

HTTPConfig dataclass

A data class grouping the HTTP arguments of the Scythe client.

The HTTP configuration controls how requests are made. It determines the HTTP method, the request timeout, optional authentication credentials, the character encoding used for decoding responses, and the user agent string sent with every request.

Attributes:

Name Type Description
http_method str

The HTTP method to use for requests. Must be "GET" or "POST". Default is "GET".

timeout float

The timeout (in seconds) for HTTP requests. Default is 60.

auth AuthTypes | None

Optional authentication credentials for accessing the OAI-PMH interface.

encoding str

The character encoding for decoding responses. Default is "utf-8".

user_agent str

The user agent string sent with every request. Defaults to "oaipmh-scythe/".

RetryConfig dataclass

A data class grouping the retry arguments of the Scythe client.

The retry configuration controls how failed HTTP requests are retried. It determines the number of retries, the HTTP status codes that trigger a retry, and the default wait time between retries if the server does not provide a 'retry-after' header. Optionally, requests failing with a transport error (e.g. connection failures or timeouts) can be retried using exponential backoff.

Attributes:

Name Type Description
max_retries int

The maximum number of retries for a request in case of failures. Default is 0 (no retries).

retry_status_codes tuple[int, ...]

The HTTP status codes on which to retry the request. Default is (503,).

default_retry_after float

The default wait time (in seconds) between retries if no 'retry-after' header is present. Default is 60.

retry_on_transport_error bool

Whether to retry requests failing with a transport error (e.g. connection failures or timeouts). Default is False. Only effective if max_retries is greater than 0.

initial_backoff float

The initial wait time (in seconds) between retries after a transport error. The wait time doubles with each retry (exponential backoff), is capped at default_retry_after, and is randomized between 50% and 100% of the computed value (jitter). Default is 1.0.