envlib 0.1.5__tar.gz → 0.1.7__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: envlib
3
- Version: 0.1.5
3
+ Version: 0.1.7
4
4
  Summary: The environmental library
5
5
  Project-URL: Documentation, https://envlib.github.io/envlib/
6
6
  Project-URL: Source, https://github.com/envlib/envlib
@@ -9,8 +9,8 @@ License-File: LICENSE
9
9
  Classifier: Programming Language :: Python :: 3 :: Only
10
10
  Requires-Python: >=3.10
11
11
  Requires-Dist: booklet>=0.12.6
12
- Requires-Dist: cfdb>=0.9.6
13
- Requires-Dist: ebooklet>=0.10.3
12
+ Requires-Dist: cfdb>=0.10.0
13
+ Requires-Dist: ebooklet>=0.10.5
14
14
  Requires-Dist: pyproj
15
15
  Requires-Dist: shapely>=2.0
16
16
  Requires-Dist: urllib3
@@ -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.5'
7
+ __version__ = '0.1.7'
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
- with cfdb.open_dataset(local_cfdb_path) as ds:
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
@@ -16,8 +16,12 @@ dependencies = [
16
16
  # file fails to open at all. No runtime guard accompanies this one, deliberately -- unlike
17
17
  # the packed-encoder floor in envlib-ingest-base, an older cfdb cannot silently mis-handle a
18
18
  # forecast dataset; it raises TypeError before touching data.
19
- "cfdb>=0.9.6",
20
- "ebooklet>=0.10.3",
19
+ # >=0.10.0: cfdb 0.10 writes new datasets with byte-shuffled compression (zstd_shuffle), which an
20
+ # older cfdb refuses at open with a bare "Invalid enum value 'zstd_shuffle'" naming no remedy.
21
+ # Readers must be able to open anything a current producer publishes, so envlib floors the
22
+ # version that can. (It needs no other 0.10 feature.)
23
+ "cfdb>=0.10.0",
24
+ "ebooklet>=0.10.5",
21
25
  "booklet>=0.12.6",
22
26
  "pyproj",
23
27
  "shapely>=2.0",
File without changes
File without changes
File without changes
File without changes