Skip to main content

marinerg-schema

The MARINERG-i dataset metadata model, as a Python package.

marinerg_dataset.linkml.yaml, written in LinkML, defines the dataset fields and their controlled vocabularies. The CKAN catalogue's form and validators, and the facility client's checks, all take their fields and values from it. It's a package so that each of them uses the same version instead of a copy.

Install

pip install marinerg-schema

Use

from marinerg_schema import (
    check,
    concept_uri,
    dataset_slots,
    permitted_values,
    slot,
    value_titles,
)
from marinerg_schema.ckan import field_names

# frozenset({'L0', 'L1', 'L2', 'L3', 'L4'})
permitted_values("processing_level")
# 'http://vocab.nerc.ac.uk/collection/EPL/current/L1/'
concept_uri("processing_level", "L1")
# {'L0': 'L0 — Raw', ...}, for a form's choices
value_titles("ProcessingLevelEnum")
# The slot's range, constraints and RDF predicate
slot("device_trl")
# ValueError: Must be at most 9: '12'
check("device_trl", "12")
# The model's fields, in model order
dataset_slots()
# The keys a CKAN dataset takes at the top level
field_names()

The measured-parameter vocabulary says what a data channel measures. A facility template names each channel's parameter by its code:

from marinerg_schema import parameter, parameters

parameter("wind_speed").unit  # 'm s-1', as UDUNITS
parameter("wind_speed").cf_standard_name  # 'wind_speed'
parameter("roll").cf_standard_name  # None: no verified CF name

A CF or NERC mapping is filled only where the term was checked to exist. Lab and device quantities, such as mooring-line tension, often have none yet.

registry_path() returns the generated registry YAML for consumers that want a file rather than the API. vocab_path() returns our own vocabulary as SKOS Turtle: every term under https://vocab.marinerg-i.eu/, with its label, definition and close matches.

Consumers

Repo What it takes
ckanext-marinerg Vocabularies, titles and constraints for its form, validators and RDF export
marinerg-data Vocabularies to check a dataset before a DOI is minted, and the CKAN field list

Predecessor

This model follows on from MaRINET2's 2020 metadata schemas, at github.com/Marinet2/metadata-schema and FAIRsharing bsg-s001497. This package replaces its dataset schema. marinerg-data's run manifest replaces its datastream schema. "Marinet2 NetCDF 0.1" is still an allowed value in the conventions list.

The MaRINET2 repository still reads as current. Only its owners can add a notice there, or link this model from its FAIRsharing record.

Change the model

Edit the LinkML file, then regenerate the registry and the SKOS vocabulary. Never edit either by hand. The tests fail if they differ from the model.

uv run python -m marinerg_schema
uv run python -m marinerg_schema --check

Give every value a title, which forms show, and a meaning, its concept URI. Write NERC CURIEs with their trailing slash, such as nerc_epl:L1/, because NERC's concept URIs end in one. A value of our own also needs a description, which becomes its SKOS definition.

The package reads the model without LinkML, so it installs anywhere CKAN does. The tests run linkml-lint and check the package's reading against LinkML's own.

After a vocabulary change, cut a release, then move the pin in each consumer. The model's version is the package's.

Develop

uv sync --group dev
uv run tox

uv run tox runs the format check, lint, type check and tests, as CI does.

The package supports Python 3.10, because CKAN 2.11 runs on it. Ruff targets 3.10 for the same reason.

Release

Open the newest pipeline for main and press the play button on release patch, minor or major. The release pipeline publishes to PyPI, then tags the commit and creates the GitLab release.

Licence

Copyright ICHEC. MIT. See LICENSE.

Metadata

Release files for marinerg-schema 0.5.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 marinerg-schema 0.5.0
File Size Uploaded
marinerg_schema-0.5.0.tar.gz 34.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for marinerg-schema 0.5.0
File Interpreter ABI Platform
marinerg_schema-0.5.0-py3-none-any.whl Python 3 none any Details

Total release size: 65.0 kB

Release files / marinerg_schema-0.5.0.tar.gz

Download URL marinerg_schema-0.5.0.tar.gz
Size 34.0 kB
Tags Source
SHA-256 checksum
How to use checksums
ae8882f6ff27a9a45f857773587f4b62db5bd34a39dc242e642e9b9c78c30047
BLAKE2b-256 checksum
How to use checksums
da12209029a58e347fa5477496985fc45d4d0d7006a433a238a5c70946614333
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / marinerg_schema-0.5.0-py3-none-any.whl

Download URL marinerg_schema-0.5.0-py3-none-any.whl
Size 31.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
414613e12f3083ec95b93328e721f836a39284788ed9c4bcef08e86a4d621d99
BLAKE2b-256 checksum
How to use checksums
f4b9be3a2697bfdecb54b3d6b9aacc85ef0351bf3db358678f0b249d25c8df3a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

0.6.0

2 release files

This release

0.5.0 This release

2 release files

0.4.0

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.0

2 release files

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