Skip to main content

limen-common

Shared building blocks for the Limen libraries.

Every library of the Limen family wrote its own retry loop, data folder, bounding box, quantile and reliability score, each a little different: six retry loops that disagree on whether a 500 is worth another try, six bounding boxes, three ways to take a percentile, four scales for "how far to trust this". limen-common holds one of each, so the libraries agree.

Module What Replaces
limen_common.http (extra [http]) RetryPolicy, send (async), send_sync: 429/5xx and transport errors retried with exponential backoff, Retry-After honoured, everything else returned as it is the retry loops of dpc-radar, egms-client, ingv-shakemap, copernicus-ems, firms-client, imageserver-export; none in effis-client
limen_common.paths data_dir(lib): the argument, then <LIB>_DATA_DIR, then $DATA_ROOT/<lib>, then ./data/<lib>; atomic_write through .part and a rename each library's own folder rule and .part writes
limen_common.geo Point and BBox, longitude first and range-checked; ITALY; haversine_m; BBox.around six BBox types, (lon, lat) tuples and Nodes, three haversines
limen_common.stats quantile, quantiles, rank: linear interpolation (numpy/R type 7) by default, nearest rank by name; None and NaN left out nearest rank (effis-client), linear (fwi-chain), the ad hoc ones
limen_common.danger the EFFIS FWI classes and effis_class the copies in fwi-chain and effis-client ("very high" vs "Very High")
limen_common.reliability Reliability(measured, score, reasons), its level (none, poor, fair, good) and weakest(*parts) dpc-radar's score, glofas-ewds' word, rainfall-thresholds' interval, egms-client's thresholds
limen_common.record (extra [record] to check) the open-data record opendata-record/v2: typed Observation, Fact, Event, Layer, the JSON Schema, problems, validate, read, from_csv the schema kept in egms-client; the record built by hand in rainfall-thresholds
limen_common.check one answer checker: check_text(text, facts, *, lang, question, rules) -> list[Misquote], check_signs, check_claims, fill; units and direction words as data in Rules the checkers of rainfall-thresholds, egms-client, fwi-chain, effis-client, ingv-shakemap, firms-client, with diverging signatures
limen_common.facts stamp, rounded, the shared ANSWER_RULES and answer_rules(about, *rules) each library's stamp, _round and the rules repeated in every ANSWER_RULES
limen_common.llms (extra [llms] for API pages) Site and main: llms.txt, llms-full.txt and the agent skill from zensical.toml and the docstrings the nine copies of tools/build_llms.py

The convention

None means "not measured". It is never zero, never NaN, never a neutral 0.5. A radar outage, a cell with no InSAR pixel, a region with no dated landslide are not dry weather, still ground or a safe slope: a function that cannot answer says so, and Reliability.not_measured(...) says why.

Nothing reads the clock. A function that needs "today" takes it.

Longitude first, as GeoJSON: Point(lon, lat), BBox(west, south, east, north). Point.from_lat_lon and BBox.lat_lon() are there for the services that put latitude first.

Install

uv add "limen-common[http]"      # with the retry policy (httpx)
uv add "limen-common[record]"    # checking records (jsonschema)
uv add "limen-common[llms]"      # API pages in llms-full.txt (griffe)
uv add limen-common              # the rest has no dependency

Examples

import httpx
from limen_common import Point, Reliability, data_dir, quantile, weakest
from limen_common.http import RetryPolicy, send

folder = data_dir("dpc-radar")  # $DATA_ROOT/dpc-radar
sarno = Point.of(14.62, 40.81)

async with httpx.AsyncClient() as client:
    response = await send(client, "GET", url, policy=RetryPolicy(retries=4))

p95 = quantile([12.0, None, 30.5, 8.1], 0.95)  # None is left out

answer = weakest(
    Reliability.of(0.8, "radar visible from two sites"),
    Reliability.not_measured("no rain gauge within 20 km"),
)
answer.measured  # False: one part was not measured

A record, checked, and a text checked against its facts:

from datetime import UTC, datetime
from limen_common import Point, Reliability
from limen_common.check import check_text
from limen_common.record import MadeBy, Observation, Source, Time, Trust

record = Observation(
    source=Source(name="DPC radar", licence="CC BY-SA 4.0"),
    made_by=MadeBy("dpc-radar", "1.2.0"),
    time=Time.at(datetime(2026, 10, 10, 12, tzinfo=UTC)),
    where=Point(11.25, 43.77),
    reliability=Trust.of(Reliability.of(0.8, "two radars see it"), "radar visibility"),
    property="rainfall",
    value=12.5,
    unit="mm",
).check()  # a dict valid against opendata-record/v2, or RecordError with every problem

facts = {"total_mm": 165.7, "needed_mm": 30.9}
check_text("165.7 mm fell; the threshold asks 30.9 mm/h", facts)
# [Misquote(said='30.9 mm/h', fault='unit', unit='mm/h', key='needed_mm', fact=30.9)]

The checker's faults are invented, unit, rounded, sign and swapped. What is a library's own (a unit like decades, a word like sinks) goes in Rules: RULES.with_units({"decades": "decades"}, keys=[("_decades", "decades")]), RULES.with_directions(down={"en": ["sinks?"]}).

Moving a library onto it

One library at a time, behaviour first: replace its own helper with the one here, keep its public names as thin aliases for one minor release, and note any change of behaviour (a status now retried, a quantile method) in its CHANGELOG. The issues "Adopt limen-common" in each repository track it.

Licence

Apache-2.0.

Metadata

Release files for limen-common 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for limen-common 0.1.1
File Size Uploaded Provenance Actions
limen_common-0.1.1.tar.gz 39.2 kB With provenance Details for limen_common-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for limen-common 0.1.1
File Interpreter ABI Platform Actions
limen_common-0.1.1-py3-none-any.whl Python 3 none any Details for limen_common-0.1.1-py3-none-any.whl

Total release size: 82.6 kB

Release files / limen_common-0.1.1.tar.gz

Download URL limen_common-0.1.1.tar.gz
Size 39.2 kB
Tags Source
SHA-256 checksum
How to use checksums
446623e28bdf1cc6c3637501b3cbd3c02f9a5d71396f8d58ab83cf42fdb73306
BLAKE2b-256 checksum
How to use checksums
711daf5160b3505dff66bb9709aab2b9e61badc1d66a6c466cabd9cd94c54265
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Release files / limen_common-0.1.1-py3-none-any.whl

Download URL limen_common-0.1.1-py3-none-any.whl
Size 43.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
7240e8c0da7e58183aa4c342f84e95a27d9f9912e2951479dd2234676f1c10c1
BLAKE2b-256 checksum
How to use checksums
caeb082588538b9ffb9c999df2ab1460958a254de0bc3b82b1c211d1969a8f8c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

Security for limen-common 0.1.1

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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for limen_common-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 2, 2026.

Transparency log

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page