Configuration#

grad300-client uses an astropy-style ConfigNamespace to manage defaults. The singleton conf can be imported and modified at runtime.

Available parameters#

Parameter

Default

Description

base_url

https://grad300.lam.fr

Base URL of the GRAD300 server

api_prefix

/api/v1

API prefix appended to base_url

timeout

30.0

HTTP timeout in seconds

default_page_size

100

Default page size for list/query methods

Changing defaults at runtime#

from grad300_client import conf

conf.base_url = "https://my-local-instance.example.com"
conf.timeout = 60.0
conf.default_page_size = 200

Changes apply to any Grad300Client instances created after the modification. Existing instances are not affected because they resolve configuration values at construction time.

Temporary overrides with a context manager#

from grad300_client import conf, Grad300

with conf.set_temp("base_url", "https://staging.grad300.lam.fr"):
    client = Grad300(user="user@example.com", password="pass")
    table = client.query_source("Sun")
# conf.base_url is restored here

Per-instance overrides#

Constructor keyword arguments always take precedence over conf values:

client = Grad300(
    user="user@example.com",
    password="pass",
    base_url="https://dev.grad300.lam.fr",  # overrides conf.base_url
    timeout=10.0,                            # overrides conf.timeout
)