Skip to main content

esgf-core-models

The shared data definitions for the ESGF core architecture, as a small standalone package.

ESGF’s core services (publishers, consumers, and the services that process their events) pass STAC items around as Kafka messages. For those services to interoperate, they all need to agree on what a message, a permission or an error looks like. These Pydantic models and exceptions are that agreement.

They were originally part of esgf-core-utils, which also contains a Kafka producer and consumer, STAC validation and settings. Using the models from there means installing all of those dependencies too. This package contains only the models, so a project that has its own Kafka client, or none at all, can still use the same definitions without the extra weight. Its dependencies are pydantic, stac-pydantic and stac-fastapi.extensions.

Install

pip install esgf-core-models

Requires Python 3.12 or newer.

Documentation

The models are documented in the esgf-core-utils API reference. Only the modules below are in this package. The consumer, producer, message_processor, validation and settings pages describe code that stays in esgf-core-utils.

Replace esgf_core_utils.models with esgf_core_models in the import paths shown there.

This package

Reference page

esgf_core_models.kafka.events

events

esgf_core_models.kafka.config

config

esgf_core_models.auth

auth

esgf_core_models.exceptions

exceptions

esgf_core_models.aggregation_assets

aggregation_assets

Examples

Parse a Kafka event. KafkaEvent picks the payload type from method (POST, PUT or PATCH):

from esgf_core_models.kafka.events import KafkaEvent, PatchPayload

event = KafkaEvent.model_validate_json(message_value)

if isinstance(event.data.payload, PatchPayload):
    print(event.data.payload.item_id, event.data.payload.patch)

Build Kafka client settings. Fields accept either the Python name or the Kafka property name:

from esgf_core_models.kafka.config import KafkaConsumerConfig

config = KafkaConsumerConfig(
    **{
        "bootstrap.servers": "kafka.example.org:9093",
        "sasl.username": "user",
        "sasl.password": "secret",
        "group.id": "my-consumer",
    }
)
# Pass the Kafka property names to confluent-kafka (or your own client):
client_config = config.model_dump(by_alias=True, exclude_none=True)

Check that a publisher may act on a project and its asset hosts. Entitlement strings are matched against your own regular expression, which must define the named groups type (project or node), id and role:

from esgf_core_models.auth import Authorizer
from esgf_core_models.exceptions import AuthorizationException
from esgf_core_models.kafka.events import RequesterData

authorizer = Authorizer(
    requester_data=RequesterData(client_id="c", iss="https://idp", sub="u"),
    regex=r"^(?P<type>project|node):(?P<id>[^:]+):(?P<role>[A-Z]+)$",
)
authorizer.add(["project:CMIP6:CREATE", "node:data.example.org:CREATE"])

try:
    authorizer.authorize(
        collection_id="CMIP6",
        item=item,  # an stac_pydantic Item
        role="CREATE",
        request_id="req-1",
        event_id="evt-1",
    )
except AuthorizationException as exc:
    print(exc.rfc945response())  # RFC 9457 problem details

Return RFC 9457 problem details from any of the exceptions:

from esgf_core_models.exceptions import ItemDoesNotExistException

exc = ItemDoesNotExistException("CMIP6", "some-item-id", instance="req-1:evt-1")
exc.rfc945response()

Metadata

Release files for esgf-core-models 0.1.0

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

Source distribution (sdist)

Source distribution for esgf-core-models 0.1.0
File Size Uploaded Provenance Actions
esgf_core_models-0.1.0.tar.gz 18.2 kB Without provenance Details for esgf_core_models-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for esgf-core-models 0.1.0
File Interpreter ABI Platform Actions
esgf_core_models-0.1.0-py3-none-any.whl Python 3 none any Details for esgf_core_models-0.1.0-py3-none-any.whl

Total release size: 29.0 kB

Release files / esgf_core_models-0.1.0.tar.gz

Download URL esgf_core_models-0.1.0.tar.gz
Size 18.2 kB
Tags Source
SHA-256 checksum
How to use checksums
c20245749b606f84e5e3924e1fd0dfaef337ef80ca08c612f600f730bab149d4
BLAKE2b-256 checksum
How to use checksums
9fdd9f91742b5011de617dcd46a3faacb96845d8eca6eed41003ccba8d0b2d05
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / esgf_core_models-0.1.0-py3-none-any.whl

Download URL esgf_core_models-0.1.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0964e5fab6cb8143ba49c95d3be903d369d5066eb6a02c32a83b74cc5ba6024d
BLAKE2b-256 checksum
How to use checksums
818bf8508001ddca1dd3f425806fb7a3bce84f09ae767ba6a12160e9da8409fe
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Security for esgf-core-models 0.1.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.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No 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