envlib 0.1.5__tar.gz → 0.1.6__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {envlib-0.1.5 → envlib-0.1.6}/PKG-INFO +1 -1
- {envlib-0.1.5 → envlib-0.1.6}/envlib/__init__.py +3 -2
- {envlib-0.1.5 → envlib-0.1.6}/envlib/catalogue.py +45 -2
- {envlib-0.1.5 → envlib-0.1.6}/.gitignore +0 -0
- {envlib-0.1.5 → envlib-0.1.6}/LICENSE +0 -0
- {envlib-0.1.5 → envlib-0.1.6}/README.md +0 -0
- {envlib-0.1.5 → envlib-0.1.6}/envlib/metadata.py +0 -0
- {envlib-0.1.5 → envlib-0.1.6}/envlib/vocabularies/__init__.py +0 -0
- {envlib-0.1.5 → envlib-0.1.6}/envlib/vocabularies/aggregation_statistic.json +0 -0
- {envlib-0.1.5 → envlib-0.1.6}/envlib/vocabularies/feature.json +0 -0
- {envlib-0.1.5 → envlib-0.1.6}/envlib/vocabularies/frequency_interval.json +0 -0
- {envlib-0.1.5 → envlib-0.1.6}/envlib/vocabularies/license.json +0 -0
- {envlib-0.1.5 → envlib-0.1.6}/envlib/vocabularies/method.json +0 -0
- {envlib-0.1.5 → envlib-0.1.6}/envlib/vocabularies/processing_level.json +0 -0
- {envlib-0.1.5 → envlib-0.1.6}/envlib/vocabularies/standard_name.json +0 -0
- {envlib-0.1.5 → envlib-0.1.6}/envlib/vocabularies/variable.json +0 -0
- {envlib-0.1.5 → envlib-0.1.6}/pyproject.toml +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"""envlib: a distributed database and catalogue for environmental data."""
|
|
2
2
|
|
|
3
3
|
from envlib import vocabularies
|
|
4
|
-
from envlib.catalogue import Catalogue, DatasetRef
|
|
4
|
+
from envlib.catalogue import Catalogue, DatasetRef, validate_dataset
|
|
5
5
|
from envlib.metadata import Metadata, ValidationError, canonical_station_point, compute_station_id
|
|
6
6
|
|
|
7
|
-
__version__ = '0.1.
|
|
7
|
+
__version__ = '0.1.6'
|
|
8
8
|
|
|
9
9
|
__all__ = [
|
|
10
10
|
'Catalogue',
|
|
@@ -13,5 +13,6 @@ __all__ = [
|
|
|
13
13
|
'ValidationError',
|
|
14
14
|
'canonical_station_point',
|
|
15
15
|
'compute_station_id',
|
|
16
|
+
'validate_dataset',
|
|
16
17
|
'vocabularies',
|
|
17
18
|
]
|
|
@@ -617,6 +617,47 @@ def _apply_derived_attrs(ds, result: dict) -> bool:
|
|
|
617
617
|
return changed
|
|
618
618
|
|
|
619
619
|
|
|
620
|
+
###################################################
|
|
621
|
+
# Public validation (no catalogue, no remote)
|
|
622
|
+
|
|
623
|
+
|
|
624
|
+
def validate_dataset(dataset, *, validate_cv: bool = True) -> dict:
|
|
625
|
+
"""Validate a cfdb dataset against envlib's requirements. No RCG, no S3, no network.
|
|
626
|
+
|
|
627
|
+
This is the catalogue's own validation, exposed for producers that build envlib-shaped
|
|
628
|
+
datasets WITHOUT publishing them to a commons -- a private ``EDataset`` archive, say. Every
|
|
629
|
+
structural guard the catalogue applies lives in :func:`_validate_dataset`, so a dataset that
|
|
630
|
+
never reaches :meth:`Catalogue.publish` would otherwise never be checked at all: the
|
|
631
|
+
``method``/``dataset_type`` cross-checks, the time-range extraction, and -- the one that
|
|
632
|
+
usually matters -- ``_check_stations``, which recomputes every ``station_id`` from the
|
|
633
|
+
geometry stored beside it.
|
|
634
|
+
|
|
635
|
+
``Catalogue`` cannot serve that need: constructing one requires a public RCG and performs a
|
|
636
|
+
network refresh, neither of which a local build has or wants.
|
|
637
|
+
|
|
638
|
+
Args:
|
|
639
|
+
dataset: a path to a local cfdb file, or an ALREADY-OPEN cfdb ``Dataset``/``EDataset``.
|
|
640
|
+
Prefer passing the open object when you have one -- reopening a file that is linked
|
|
641
|
+
to a remote starts a second session against it, and for an ``EDataset`` the open
|
|
642
|
+
object also pulls transparently, so extents are read from the whole dataset rather
|
|
643
|
+
than from whatever chunks happen to be local.
|
|
644
|
+
validate_cv: check controlled-vocabulary membership. Leave True for a first validation;
|
|
645
|
+
False re-reads already-registered metadata without re-checking vocabularies (the
|
|
646
|
+
validation-on-change-only rule -- vocabulary drift must never orphan a dataset that
|
|
647
|
+
was valid when it was written).
|
|
648
|
+
|
|
649
|
+
Returns:
|
|
650
|
+
``{'metadata', 'dataset_version_id', 'dataset_id', 'state', 'standard_name'}``.
|
|
651
|
+
|
|
652
|
+
Raises:
|
|
653
|
+
ValidationError: on any failure. Never modifies the dataset.
|
|
654
|
+
"""
|
|
655
|
+
if isinstance(dataset, (str, os.PathLike)):
|
|
656
|
+
with cfdb.open_dataset(str(dataset)) as ds:
|
|
657
|
+
return _validate_dataset(ds, validate_cv=validate_cv)
|
|
658
|
+
return _validate_dataset(dataset, validate_cv=validate_cv)
|
|
659
|
+
|
|
660
|
+
|
|
620
661
|
###################################################
|
|
621
662
|
# DatasetRef
|
|
622
663
|
|
|
@@ -941,9 +982,11 @@ class Catalogue:
|
|
|
941
982
|
|
|
942
983
|
Returns a summary dict ({'metadata', 'dataset_version_id', 'dataset_id', 'state',
|
|
943
984
|
'standard_name'}); raises ValidationError on invalid input.
|
|
985
|
+
|
|
986
|
+
Thin wrapper over the module-level :func:`validate_dataset`, which needs no Catalogue
|
|
987
|
+
and no network -- prefer that one when you are not publishing.
|
|
944
988
|
"""
|
|
945
|
-
|
|
946
|
-
return _validate_dataset(ds, validate_cv=True)
|
|
989
|
+
return validate_dataset(local_cfdb_path)
|
|
947
990
|
|
|
948
991
|
def publish(
|
|
949
992
|
self, local_cfdb_path, remote_conn, rcg_remote_conn, num_groups=None, verify_objects: bool = True, **open_kwargs
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|