hcx
hcx defines typed, runtime-usable contracts for hydrological model batches, forecasts, output specifications, models, and model factories.
The contract specification is normative. Public docstrings and this README are explanatory summaries of that specification.
The distribution combines three parts: the normative specification, an
inline-typed Python contract marked with py.typed, and a standalone
conformance harness. Independent model packages can import the same contract
and prove their behavior without an application, training engine, or external
dataset.
Authoring a model package
-
Add
hcxas a runtime dependency of the model package. -
Implement a
torch.nn.Modulewhoseforward(batch: Batch) -> Forecastbehavior satisfiesForecastModel, including the normative shape, dtype/device, and metadata identity rules. -
Implement a callable matching
ModelFactory. It accepts a model-specificdict[str, object]and the keyword-only ordereddynamic_inputsandstatic_inputs, resolvedinput_size,static_size, andoutput_size, and a resolvedOutputSpecification[object]. It returns the module. Preserve name order; the sizes are resolved from the first batch. -
Declare the factory in the model package's
pyproject.toml:[project.entry-points.'hcx.models'] my_model = "my_model_package.factory:create_model"
-
Exercise the complete contract with synthetic data:
from importlib.metadata import entry_points from hcx import Point, assert_conforms, make_synthetic_batch batch = make_synthetic_batch() assert batch.scalar_dynamic is not None assert batch.scalar_static is not None factory = entry_points(group="hcx.models", name="my_model")[0].load() dynamic_inputs = [ f"dynamic_{index}" for index in range(batch.scalar_dynamic.shape[-1]) ] static_inputs = [ f"static_{index}" for index in range(batch.scalar_static.shape[-1]) ] model = factory( {}, dynamic_inputs=dynamic_inputs, static_inputs=static_inputs, input_size=batch.scalar_dynamic.shape[-1], static_size=batch.scalar_static.shape[-1], output_size=batch.target.shape[-1], output_specification=Point(), ) assert_conforms(model, batch)
The factory can also be imported and called directly in this smoke test. hcx
packages scalar_lstm as a reference entry point, not as a required base class.
Entry-point names are consumer-facing identifiers and should remain stable and
unique within an environment.
See the normative factory and entry-point clauses and the changelog for version history.
Releases
Maintainers bump the version with bump-my-version and update the changelog in
the same commit. A human then creates and publishes the GitHub Release, which
creates the vX.Y.Z tag. The GitHub Actions workflow builds distributions with
uv build and publishes them through OIDC trusted publishing. Prereleases and
manual workflow dispatches target TestPyPI; published non-prereleases target
PyPI. Local publishing and hand-made tags are forbidden.
Metadata
Release files for hcx 0.1.3
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 |
|---|---|---|---|---|
| hcx-0.1.3.tar.gz | 8.6 kB | Without provenance | Details for hcx-0.1.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| hcx-0.1.3-py3-none-any.whl | Python 3 | none | any | Details for hcx-0.1.3-py3-none-any.whl |
Total release size: 20.4 kB
Release files / hcx-0.1.3.tar.gz
| Download URL | hcx-0.1.3.tar.gz |
|---|---|
| Size | 8.6 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ef3a55711046f789b467747bf2647c7fc855a68b1e89a0a786bd9cef5087908
|
|
BLAKE2b-256 checksum How to use checksums |
c1c1e8bb99a0639b6f56c3139ce655ac97808e27ddaca69033692f0ef911ec15
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.0
|
Release files / hcx-0.1.3-py3-none-any.whl
| Download URL | hcx-0.1.3-py3-none-any.whl |
|---|---|
| Size | 11.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
236d223d5e27b973775c065653cea7a5a05fa385c180f621d22c2c5211035f1d
|
|
BLAKE2b-256 checksum How to use checksums |
fe7cb464b2eefbce1583628319985d7793942a110c59f929d8d809bb4fbbe3a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
uv/0.9.0
|
Security for hcx 0.1.3
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.