Small Python client for the GRAD300 backend API
Project description
grad300-client
Small Python package to access the GRAD300 backend API.
Install
From PyPI (once published):
pip install grad300-client
From this repository:
pip install ./clients/grad300-client
Build and Publish (uv)
This project uses uv workspace tooling, so you do not need to add build or twine as package dev dependencies.
Build artifacts for this package:
uv build --package grad300-client -o clients/grad300-client/dist
Publish to TestPyPI first:
export UV_PUBLISH_TOKEN="pypi-..."
uv publish \
--publish-url https://test.pypi.org/legacy/ \
--check-url https://test.pypi.org/simple/ \
clients/grad300-client/dist/*
Publish to PyPI:
export UV_PUBLISH_TOKEN="pypi-..."
uv publish --check-url https://pypi.org/simple/ clients/grad300-client/dist/*
Local Compatibility Tests (tox)
Run the client test suite across Python 3.9 to 3.13:
cd clients/grad300-client
python -m pip install tox
tox
If some interpreters are not installed locally, tox will skip them.
GitLab CI Publishing (tags)
The repository CI can publish automatically to PyPI when a tag is pushed.
- Tag format:
v0.2(also supports patch tags likev0.2.1). - The package version is derived from Git tags via
hatch-vcs, so there is no manual version update inpyproject.tomlfor releases. - Configure
UV_PUBLISH_TOKENas a protected GitLab CI variable (PyPI token).
Quick start
from datetime import datetime
from grad300_client import Grad300
client = Grad300(user="student@example.com", password="your-password")
# Simple source query (astroquery-like helper)
tpi_scans = client.query_source("sun", scan_type="TPI")
print(tpi_scans["id", "scan_type", "file_name", "source", "date"])
# Query by scan filename fragment
named_scans = client.query_scan_name("2025062")
# Query by date range
march_scans = client.query_date_range(
date_from=datetime(2026, 3, 1),
date_to=datetime(2026, 3, 31, 23, 59, 59),
)
# Download one scan from a table row
if len(tpi_scans) > 0:
# In-memory return (no destination_dir):
# - TPI -> astropy.table.Table
tpi_data = client.download(tpi_scans[0])
# Save to file when destination_dir is provided
local_path = client.download(tpi_scans[0], destination_dir="./downloads")
print(local_path)
# Non-TPI in-memory return is an astropy.io.fits.HDUList
image_hdul = client.download_by_id(scan_type="Images", scan_id=30)
image_hdul.close()
client.close()
Configuration (astropy.config)
grad300-client exposes a global conf object (Astropy-style) for defaults.
from grad300_client import Grad300, conf
with (
conf.set_temp("base_url", "https://staging.grad300.lam.fr"),
conf.set_temp("api_prefix", "/api/v1"),
conf.set_temp("timeout", 60.0),
conf.set_temp("default_page_size", 200),
):
client = Grad300(user="student@example.com", password="your-password")
scans = client.query_source("sun", scan_type="TPI")
client.close()
Constructor arguments still override config defaults.
Notes
- The package wraps existing routes under
/api/v1. list,query_source,query_scan_name, andquery_date_rangereturnastropy.table.Table.- Use
list_recordsandquery_recordsif you prefer typed Python objects (ScanRecord). - You can authenticate either with
token=...or withuser=...andpassword=...in the constructor. download,download_by_id, anddownload_by_scan_namefetch FITS data from scan download endpoints.- If
destination_diris omitted: TPI returns anastropy.table.Table, other scan types return anastropy.io.fits.HDUList. - If
destination_diris provided, the FITS file is saved and the returned value is the localPath.
License
This package is distributed under the MIT License. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file grad300_client-0.1.1.tar.gz.
File metadata
- Download URL: grad300_client-0.1.1.tar.gz
- Upload date:
- Size: 11.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9ea68820e08999797c9e7daa7f3e4337c5bb65e3bd435a8fb29f06fdfb848067
|
|
| MD5 |
959f6242ff5d2738ed886dcff7e2b7f0
|
|
| BLAKE2b-256 |
de40eedfe5469b1e306c6059074704e0a4ef25d944780a416b45122a54735eee
|
File details
Details for the file grad300_client-0.1.1-py3-none-any.whl.
File metadata
- Download URL: grad300_client-0.1.1-py3-none-any.whl
- Upload date:
- Size: 12.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.9 {"installer":{"name":"uv","version":"0.10.9","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Debian GNU/Linux","version":"13","id":"trixie","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
06e73f0fd325b1b88197a0dce617a670257825c2c2105ae7a7a688a7dc4909ca
|
|
| MD5 |
43933b3458004515e2037713a8a5290d
|
|
| BLAKE2b-256 |
45618dfd28006e9ad6110b7487c24099aee9151dd1cee0bcb4bf09bbe3c38cc7
|