dials-py
The Python client of the DIALS API.
The full documentation, with every endpoint, filters, pandas and progress bar support, retrying and resuming long queries, ML certification JSONs and the development instance, is in the dials-py user guide.
Installation
pip install cmsdials
The pandas and tqdm extras enable conversion to DataFrames and progress bars:
pip install "cmsdials[pandas,tqdm]"
Usage
Tokens are issued by CERN's Keycloak directly, dials-py never sends your password or a client secret to DIALS.
To log in as yourself, with the device flow (interactive, the credentials are cached in .cache/ and renewed automatically):
from cmsdials.auth.device import Credentials
creds = Credentials.from_creds_file()
To log in as an application, with its client id and secret (unattended scripts, the application must be granted API access):
import os
from cmsdials.auth.client_credentials import Credentials
creds = Credentials(client_id="my-application", client_secret=os.environ["CLIENT_SECRET"])
Then query DIALS, optionally in another workspace than the one picked from your e-groups:
from cmsdials import Dials
from cmsdials.filters import LumisectionHistogram1DFilters
dials = Dials(creds, workspace="tracker")
data = dials.h1d.list_all(
LumisectionHistogram1DFilters(me="PixelPhase1/Tracks/PXBarrel/charge_PXLayer_2"),
max_pages=5,
)
Development
Install the dependencies and the package using uv:
uv sync --all-groups --extra pandas --extra tqdm
uv run pre-commit install
uv pip install -e .
Running tests
The repository has some tests written to make sure DIALS responses are compatible with pydantic metaclasses, you can use pytest to run all tests but you need to specify the client id and secret of an application to authenticate non-interactively against DIALS api:
CLIENT_SECRET=... CLIENT_ID=... uv run pytest tests
Any application granted API access in DIALS can be used: CLIENT_ID is its client id and CLIENT_SECRET its client secret, both obtained from the applications portal. Tests target the dev Keycloak applications by default, overwrite them with AUTH_CLIENT_ID and AUTH_AUDIENCE. The interactive authentication flow should be tested manually, an example for this can be found in test_auth_client.py.
If testing against a local version of DIALS you need to specify the BASE_URL:
CLIENT_SECRET=... CLIENT_ID=... BASE_URL=http://localhost:8000 uv run pytest tests
Tox
Tox is pre-configured in tox.ini, so you can run the following to test against multiple python versions locally:
CLIENT_SECRET=... CLIENT_ID=... uv run tox
asdf users
tox requires multiple versions of Python to be installed. Using asdf, you have multiple versions installed, but they aren’t normally exposed to the current shell. You can use the following command to expose multiple versions of Python in the current directory:
asdf set python 3.12.9 3.11.10 3.10.13 3.9.19
This will use 3.12.9 by default (if you just run python), but it will also put python3.11, python3.10 and python3.9 symlinks in your path so you can run those too (which is exactly what tox is looking for).
Releasing the package on PyPI
The package is available in PyPI at cmsdials, under the cmsdqm organization. You'll need at leat Mantainer rights to be able to push new versions.
CI
Do not worry. The GitLab CI is configured to automatically publish the package on PyPI and the release notes in GitLab whever a tag is pushed to the repo.
Manual
If you want to follow the manual approach, you need to first build and then publish.
Build
You can use uv to build the package using:
uv build
The build system will automatically update the package version based on the git tag of the current commit.
Publish
Provided you have already generate a PyPI api token in your account or in CMDQM org, you can publish using:
UV_PUBLISH_TOKEN=... uv publish
Metadata
Release files for cmsdials 3.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| cmsdials-3.0.0.tar.gz | 160.1 kB | Without provenance | Details for cmsdials-3.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| cmsdials-3.0.0-py3-none-any.whl | Python 3 | none | any | Details for cmsdials-3.0.0-py3-none-any.whl |
Total release size: 200.3 kB
Release files / cmsdials-3.0.0.tar.gz
| Download URL | cmsdials-3.0.0.tar.gz |
|---|---|
| Size | 160.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e625eb20f98610bc91bb4fb608d513d69de6918eefb34d3518786f07974cc9c
|
|
BLAKE2b-256 checksum How to use checksums |
1ed4a9ce106a2304515c2ddcc159f189c8337ab19e5ef59889f13de05fb886d8
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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}
|
Release files / cmsdials-3.0.0-py3-none-any.whl
| Download URL | cmsdials-3.0.0-py3-none-any.whl |
|---|---|
| Size | 40.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7431b854627309560c5d55e65d7742b0beb976b63ec71105b8f76864da67ee3e
|
|
BLAKE2b-256 checksum How to use checksums |
d310e2601da96acddc53c240dceb1cd6670bb0c90551de451d7336a6d5beee12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","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}
|
Security for cmsdials 3.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.