taco-eo 0.8.2__tar.gz → 0.9.0__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.
Files changed (183) hide show
  1. {taco_eo-0.8.2 → taco_eo-0.9.0}/.gitignore +2 -0
  2. {taco_eo-0.8.2 → taco_eo-0.9.0}/PKG-INFO +2 -13
  3. {taco_eo-0.8.2 → taco_eo-0.9.0}/README.md +1 -12
  4. {taco_eo-0.8.2 → taco_eo-0.9.0}/examples/change_detection.py +1 -1
  5. {taco_eo-0.8.2 → taco_eo-0.9.0}/examples/geospatial.py +1 -2
  6. {taco_eo-0.8.2 → taco_eo-0.9.0}/examples/minimal.py +2 -3
  7. {taco_eo-0.8.2 → taco_eo-0.9.0}/examples/numpy_minimal.py +1 -1
  8. {taco_eo-0.8.2 → taco_eo-0.9.0}/examples/oceantaco_istac.py +1 -1
  9. {taco_eo-0.8.2 → taco_eo-0.9.0}/examples/partitioned.py +2 -2
  10. {taco_eo-0.8.2 → taco_eo-0.9.0}/examples/sequence.py +1 -1
  11. {taco_eo-0.8.2 → taco_eo-0.9.0}/examples/stac_segmentation.py +1 -1
  12. {taco_eo-0.8.2 → taco_eo-0.9.0}/examples/time_series.py +12 -3
  13. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/CMakeLists.txt +2 -4
  14. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/include/taco/taco.h +1 -13
  15. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/cache.hpp +5 -6
  16. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/capi.cpp +0 -30
  17. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/dataset.cpp +131 -44
  18. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/dataset.hpp +0 -1
  19. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/sql.cpp +131 -119
  20. {taco_eo-0.8.2 → taco_eo-0.9.0}/pyproject.toml +1 -2
  21. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/__init__.py +2 -0
  22. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/_graph.py +2 -5
  23. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/_repr.py +2 -5
  24. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/container/view.py +1 -3
  25. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/contract/collection.py +5 -14
  26. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/contract/contract.py +96 -74
  27. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/contract/naming.py +1 -0
  28. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/contract/sample.py +9 -3
  29. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/contract/schema.py +46 -6
  30. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/contract/structure.py +2 -2
  31. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/contract/types.py +34 -12
  32. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/extensions/rumi.py +1 -1
  33. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/metadata/_base.py +4 -0
  34. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/metadata/derived.py +72 -10
  35. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/metadata/spatiotemporal.py +8 -6
  36. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/reader/dataset.py +8 -31
  37. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/reader/inspect.py +13 -2
  38. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/reader/native.py +1 -23
  39. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/validate.py +81 -42
  40. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/writer/api.py +2 -5
  41. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/writer/archive.py +5 -2
  42. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/writer/base.py +10 -0
  43. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/writer/catalog.py +45 -2
  44. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/writer/export.py +110 -85
  45. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/writer/folder.py +22 -15
  46. taco_eo-0.9.0/taco/writer/identity.py +40 -0
  47. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/writer/metadata.py +18 -9
  48. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/writer/partition.py +2 -1
  49. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/conftest.py +5 -5
  50. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/datasets.py +36 -13
  51. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_collection.py +2 -6
  52. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_contract.py +54 -23
  53. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_core_reader.py +82 -24
  54. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_examples.py +2 -2
  55. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_export.py +23 -30
  56. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_extension_contract.py +98 -9
  57. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_extension_rumi.py +22 -11
  58. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_extension_spatiotemporal.py +14 -13
  59. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_metadata.py +42 -20
  60. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_reader.py +33 -14
  61. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_tacocat.py +33 -7
  62. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_types.py +39 -9
  63. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_validate.py +22 -0
  64. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_writer.py +63 -47
  65. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_writer_cases.py +2 -5
  66. taco_eo-0.8.2/native/core/src/manifest.cpp +0 -211
  67. taco_eo-0.8.2/native/core/src/manifest.hpp +0 -22
  68. taco_eo-0.8.2/taco/reader/manifest.py +0 -59
  69. taco_eo-0.8.2/tests/data/reader-resolution.json +0 -21
  70. taco_eo-0.8.2/tests/test_reader_conformance.py +0 -31
  71. taco_eo-0.8.2/tests/test_versioned.py +0 -293
  72. {taco_eo-0.8.2 → taco_eo-0.9.0}/LICENSE +0 -0
  73. {taco_eo-0.8.2 → taco_eo-0.9.0}/hatch_build.py +0 -0
  74. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/cache.cpp +0 -0
  75. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/cozip_index.cpp +0 -0
  76. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/cozip_index.hpp +0 -0
  77. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/error.hpp +0 -0
  78. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/json.cpp +0 -0
  79. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/json.hpp +0 -0
  80. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/paths.cpp +0 -0
  81. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/paths.hpp +0 -0
  82. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/progress.cpp +0 -0
  83. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/progress.hpp +0 -0
  84. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/sql.hpp +0 -0
  85. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/transport.cpp +0 -0
  86. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/core/src/transport.hpp +0 -0
  87. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/CMakeLists.txt +0 -0
  88. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/LICENSE +0 -0
  89. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/VERSION +0 -0
  90. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/cmake/karuConfig.cmake.in +0 -0
  91. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/include/karu/karu.h +0 -0
  92. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/include/karu/karu.hpp +0 -0
  93. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/aws_profile.cpp +0 -0
  94. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/aws_profile.hpp +0 -0
  95. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/azure.cpp +0 -0
  96. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/azure_credentials.cpp +0 -0
  97. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/azure_credentials.hpp +0 -0
  98. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/contract.hpp +0 -0
  99. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/credentials.cpp +0 -0
  100. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/credentials.hpp +0 -0
  101. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/crypto.cpp +0 -0
  102. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/crypto.hpp +0 -0
  103. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/gcs.cpp +0 -0
  104. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/gcs_credentials.cpp +0 -0
  105. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/gcs_credentials.hpp +0 -0
  106. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/http.cpp +0 -0
  107. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/hugging_face.cpp +0 -0
  108. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/registry.cpp +0 -0
  109. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/s3.cpp +0 -0
  110. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/s3_credentials.cpp +0 -0
  111. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/s3_credentials.hpp +0 -0
  112. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/s3_signing.cpp +0 -0
  113. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/s3_signing.hpp +0 -0
  114. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/source.cpp +0 -0
  115. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/source_credentials.cpp +0 -0
  116. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/source_credentials.hpp +0 -0
  117. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/url.cpp +0 -0
  118. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/backends/url.hpp +0 -0
  119. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/buffer.hpp +0 -0
  120. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/client.hpp +0 -0
  121. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/config.cpp +0 -0
  122. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/config.hpp +0 -0
  123. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/config_options.hpp +0 -0
  124. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/credential_cache.cpp +0 -0
  125. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/credential_cache.hpp +0 -0
  126. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/error.cpp +0 -0
  127. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/error.hpp +0 -0
  128. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/karu.cpp +0 -0
  129. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/locator.hpp +0 -0
  130. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/platform.cpp +0 -0
  131. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/platform.hpp +0 -0
  132. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/process.cpp +0 -0
  133. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/process.hpp +0 -0
  134. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/request.hpp +0 -0
  135. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/request_builder.cpp +0 -0
  136. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/request_builder.hpp +0 -0
  137. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/runtime/batch.cpp +0 -0
  138. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/runtime/batch.hpp +0 -0
  139. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/runtime/curl_types.hpp +0 -0
  140. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/runtime/deadline.hpp +0 -0
  141. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/runtime/engine.cpp +0 -0
  142. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/runtime/engine.hpp +0 -0
  143. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/runtime/http_response.cpp +0 -0
  144. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/runtime/http_response.hpp +0 -0
  145. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/runtime/planner.cpp +0 -0
  146. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/runtime/planner.hpp +0 -0
  147. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/runtime/transfer.hpp +0 -0
  148. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/runtime/transport.cpp +0 -0
  149. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/runtime/transport.hpp +0 -0
  150. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/text.hpp +0 -0
  151. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/uri.cpp +0 -0
  152. {taco_eo-0.8.2 → taco_eo-0.9.0}/native/extern/karu/src/uri.hpp +0 -0
  153. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/container/__init__.py +0 -0
  154. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/container/cozip.py +0 -0
  155. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/container/parquet.py +0 -0
  156. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/container/publish.py +0 -0
  157. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/contract/__init__.py +0 -0
  158. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/errors.py +0 -0
  159. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/extensions/__init__.py +0 -0
  160. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/extensions/spatiotemporal.py +0 -0
  161. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/metadata/__init__.py +0 -0
  162. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/metadata/asset.py +0 -0
  163. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/metadata/collection.py +0 -0
  164. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/metadata/data/admin/admin0.parquet +0 -0
  165. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/metadata/data/admin/admin1.parquet +0 -0
  166. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/metadata/data/admin/admin2.parquet +0 -0
  167. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/metadata/folder.py +0 -0
  168. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/metadata/sample.py +0 -0
  169. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/metadata/split.py +0 -0
  170. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/py.typed +0 -0
  171. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/reader/__init__.py +0 -0
  172. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/reader/api.py +0 -0
  173. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/reader/collection.py +0 -0
  174. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/reader/engine.py +0 -0
  175. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/reader/query.py +0 -0
  176. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/reader/source.py +0 -0
  177. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/writer/__init__.py +0 -0
  178. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/writer/progress.py +0 -0
  179. {taco_eo-0.8.2 → taco_eo-0.9.0}/taco/writer/staging.py +0 -0
  180. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/__init__.py +0 -0
  181. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_parquet.py +0 -0
  182. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_progress.py +0 -0
  183. {taco_eo-0.8.2 → taco_eo-0.9.0}/tests/test_publish.py +0 -0
@@ -41,3 +41,5 @@ autom4te.cache/
41
41
  create-julia-skeleton.sh
42
42
  _site/
43
43
  numpy_demo.zip
44
+
45
+ byot-workshop.ipynb
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: taco-eo
3
- Version: 0.8.2
3
+ Version: 0.9.0
4
4
  Summary: Python bindings to libtaco, the reference library for the TACO format.
5
5
  Project-URL: Homepage, https://asterisk.coop/taco
6
6
  Project-URL: Specification, https://asterisk.coop/taco/spec
@@ -78,17 +78,6 @@ targets = dataset.read(files="target.tif")
78
78
  train = dataset.sql("SELECT * FROM data WHERE \"ml:split\" = 'train'")
79
79
  ```
80
80
 
81
- Versioned dataset roots select their declared default release without listing
82
- remote storage. Use a release URL to open an immutable version directly.
83
-
84
- ```python
85
- dataset = taco.open_dataset("https://data.source.coop/major-tom/core-dem/")
86
- print(dataset.version)
87
- print(dataset.versions)
88
-
89
- previous = taco.open_dataset("https://data.source.coop/major-tom/core-dem/1.0.0/")
90
- ```
91
-
92
81
  `export()` writes a smaller dataset with the same contract. `samples` is a
93
82
  PyArrow-compatible table, normally selected from the `data` SQL relation.
94
83
  Keyword arguments replace fields of the collection, such
@@ -99,7 +88,7 @@ downloaded. Pass `overwrite=True` to replace an existing TACO output.
99
88
  ```python
100
89
  source = "https://data.source.coop/major-tom/core-dem/"
101
90
  dataset = taco.open_dataset(source)
102
- rows = dataset.sql("SELECT * FROM data ORDER BY sample_id LIMIT 10")
91
+ rows = dataset.sql('SELECT * FROM data ORDER BY "taco:sample_index" LIMIT 10')
103
92
  taco.export(
104
93
  source,
105
94
  "core-dem-sample.zip",
@@ -22,17 +22,6 @@ targets = dataset.read(files="target.tif")
22
22
  train = dataset.sql("SELECT * FROM data WHERE \"ml:split\" = 'train'")
23
23
  ```
24
24
 
25
- Versioned dataset roots select their declared default release without listing
26
- remote storage. Use a release URL to open an immutable version directly.
27
-
28
- ```python
29
- dataset = taco.open_dataset("https://data.source.coop/major-tom/core-dem/")
30
- print(dataset.version)
31
- print(dataset.versions)
32
-
33
- previous = taco.open_dataset("https://data.source.coop/major-tom/core-dem/1.0.0/")
34
- ```
35
-
36
25
  `export()` writes a smaller dataset with the same contract. `samples` is a
37
26
  PyArrow-compatible table, normally selected from the `data` SQL relation.
38
27
  Keyword arguments replace fields of the collection, such
@@ -43,7 +32,7 @@ downloaded. Pass `overwrite=True` to replace an existing TACO output.
43
32
  ```python
44
33
  source = "https://data.source.coop/major-tom/core-dem/"
45
34
  dataset = taco.open_dataset(source)
46
- rows = dataset.sql("SELECT * FROM data ORDER BY sample_id LIMIT 10")
35
+ rows = dataset.sql('SELECT * FROM data ORDER BY "taco:sample_index" LIMIT 10')
47
36
  taco.export(
48
37
  source,
49
38
  "core-dem-sample.zip",
@@ -32,7 +32,6 @@ contract = taco.Contract(
32
32
  collection = taco.Collection(
33
33
  contract=contract,
34
34
  id="change-detection",
35
- dataset_version="1.0.0",
36
35
  description="Paired observations and their change mask",
37
36
  licenses=["MIT"],
38
37
  providers=["Asterisk Labs"],
@@ -51,6 +50,7 @@ paths = {
51
50
  }
52
51
  assets = [taco.Asset(encode(array), path=path) for path, array in paths.items()]
53
52
  sample = taco.Sample(
53
+ id="scene-0001",
54
54
  assets=assets,
55
55
  metadata=taco.Metadata(ml=taco.metadata.sample.Split(split="train")),
56
56
  folders=[
@@ -19,7 +19,6 @@ contract = taco.Contract(
19
19
  collection = taco.Collection(
20
20
  contract=contract,
21
21
  id="peru-sites",
22
- dataset_version="1.0.0",
23
22
  description="Small geospatial dataset with derived MajorTOM cells",
24
23
  licenses=["MIT"],
25
24
  providers=["Asterisk Labs"],
@@ -36,7 +35,7 @@ with taco.open_writer(collection, "geospatial.zip", overwrite=True) as writer:
36
35
  time_start=datetime(2024, 1, index + 1, tzinfo=timezone.utc),
37
36
  )
38
37
  asset = taco.Asset(bytes([index + 1]) * 64, path="image.bin")
39
- writer.add(taco.Sample(assets=asset, metadata=taco.Metadata(stac=stac)))
38
+ writer.add(taco.Sample(id=f"scene-{index}", assets=asset, metadata=taco.Metadata(stac=stac)))
40
39
  writer.run()
41
40
 
42
41
  dataset = taco.open_dataset("geospatial.zip")
@@ -1,16 +1,15 @@
1
1
  import taco
2
2
 
3
3
  collection = taco.Collection(
4
- contract=taco.Contract(structure=None),
4
+ contract=taco.Contract(structure=["data.bin"]),
5
5
  id="minimal",
6
- dataset_version="1.0.0",
7
6
  description="Minimal TACO dataset",
8
7
  licenses=["MIT"],
9
8
  providers=["me"],
10
9
  tasks=["other"],
11
10
  )
12
11
  with taco.open_writer(collection, "minimal.zip", overwrite=True) as writer:
13
- writer.add(taco.Sample(assets=b"hello"))
12
+ writer.add(taco.Sample(id="hello", assets=b"hello"))
14
13
  writer.run()
15
14
 
16
15
  dataset = taco.open_dataset("minimal.zip")
@@ -23,7 +23,6 @@ contract = taco.Contract(
23
23
  collection = taco.Collection(
24
24
  contract=contract,
25
25
  id="numpy-demo",
26
- dataset_version="1.0.0",
27
26
  description="Small NumPy dataset",
28
27
  licenses=["MIT"],
29
28
  providers=["me"],
@@ -34,6 +33,7 @@ with taco.open_writer(collection, "numpy-demo.zip", overwrite=True) as writer:
34
33
  image = np.random.default_rng(index).random((3, 32, 32), dtype=np.float32)
35
34
  writer.add(
36
35
  taco.Sample(
36
+ id=f"chip-{index:03d}",
37
37
  metadata=taco.Metadata(ml=ML(split="train" if index < 8 else "test")),
38
38
  assets=[
39
39
  taco.Asset(encode(image), path="image.npy"),
@@ -98,7 +98,6 @@ contract = taco.Contract(
98
98
  collection = taco.Collection(
99
99
  contract=contract,
100
100
  id="oceantaco-istac",
101
- dataset_version="1.0.0",
102
101
  title="Synthetic SWOT and Argo collocations",
103
102
  description="Irregular ocean swaths with satellite predictors and collocated Argo profiles",
104
103
  licenses=["MIT"],
@@ -255,6 +254,7 @@ with taco.open_writer(collection, "oceantaco-istac.zip", overwrite=True) as writ
255
254
  )
256
255
  writer.add(
257
256
  taco.Sample(
257
+ id=f"swath-{index:04d}",
258
258
  assets=assets,
259
259
  folders=[
260
260
  taco.Folder(
@@ -1,13 +1,12 @@
1
1
  import taco
2
2
 
3
3
  contract = taco.Contract(
4
- structure=None,
4
+ structure=["data.bin"],
5
5
  metadata=taco.MetadataSchema(taco.Level("sample", ml=taco.metadata.sample.Split)),
6
6
  )
7
7
  collection = taco.Collection(
8
8
  contract=contract,
9
9
  id="partitioned",
10
- dataset_version="1.0.0",
11
10
  description="Dataset partitioned by training split",
12
11
  licenses=["MIT"],
13
12
  providers=["Asterisk Labs"],
@@ -23,6 +22,7 @@ with taco.open_writer(
23
22
  for index, split in enumerate(("train", "train", "validation", "test")):
24
23
  writer.add(
25
24
  taco.Sample(
25
+ id=f"sample-{index}",
26
26
  assets=f"sample-{index}".encode(),
27
27
  metadata=taco.Metadata(ml=taco.metadata.sample.Split(split=split)),
28
28
  )
@@ -20,7 +20,6 @@ contract = taco.Contract(
20
20
  collection = taco.Collection(
21
21
  contract=contract,
22
22
  id="image-sequence",
23
- dataset_version="1.0.0",
24
23
  description="Short image sequences with variable length",
25
24
  licenses=["MIT"],
26
25
  providers=["Asterisk Labs"],
@@ -36,6 +35,7 @@ with taco.open_writer(collection, "image-sequence.zip", overwrite=True) as write
36
35
  split = "test" if sample_index == 2 else "train"
37
36
  writer.add(
38
37
  taco.Sample(
38
+ id=f"sequence-{sample_index}",
39
39
  assets=assets,
40
40
  metadata=taco.Metadata(ml=taco.metadata.sample.Split(split=split)),
41
41
  )
@@ -62,7 +62,6 @@ contract = taco.Contract(
62
62
  collection = taco.Collection(
63
63
  contract=contract,
64
64
  id="stac-segmentation",
65
- dataset_version="1.0.0",
66
65
  title="Synthetic Sentinel-2 land-cover chips",
67
66
  description="Regular multispectral chips and dense land-cover labels",
68
67
  licenses=["MIT"],
@@ -170,6 +169,7 @@ with taco.open_writer(collection, "stac-segmentation.zip", overwrite=True) as wr
170
169
  ]
171
170
  writer.add(
172
171
  taco.Sample(
172
+ id=f"chip-{index:04d}",
173
173
  assets=assets,
174
174
  metadata=taco.Metadata(
175
175
  stac=stac,
@@ -34,7 +34,6 @@ contract = taco.Contract(
34
34
  collection = taco.Collection(
35
35
  contract=contract,
36
36
  id="time-series",
37
- dataset_version="1.0.0",
38
37
  description="Satellite observations collected through time",
39
38
  licenses=["MIT"],
40
39
  providers=["Asterisk Labs"],
@@ -54,13 +53,23 @@ with taco.open_writer(collection, "time-series.zip", overwrite=True) as writer:
54
53
  ),
55
54
  )
56
55
  assets.append(taco.Asset(encode(image), path=f"image{step}.npy", metadata=metadata))
57
- writer.add(taco.Sample(assets=assets, metadata=taco.Metadata(site=Site(name=f"site-{site_index}"))))
56
+ writer.add(
57
+ taco.Sample(
58
+ id=f"site-{site_index}",
59
+ assets=assets,
60
+ metadata=taco.Metadata(site=Site(name=f"site-{site_index}")),
61
+ )
62
+ )
58
63
  writer.run()
59
64
 
60
65
  dataset = taco.open_dataset("time-series.zip")
61
66
  table = taco.read(dataset)
62
67
  lengths = dict(
63
- zip(table.column("sample_id").to_pylist(), map(len, table.column("image::location").to_pylist()), strict=True)
68
+ zip(
69
+ table.column("taco:sample_index").to_pylist(),
70
+ map(len, table.column("image::location").to_pylist()),
71
+ strict=True,
72
+ )
64
73
  )
65
74
  assert lengths == {0: 3, 1: 5}
66
75
  assert dataset.sql("SELECT * FROM files").num_rows == 8
@@ -8,7 +8,7 @@ if(NOT TACO_API_VERSION_LINE)
8
8
  endif()
9
9
 
10
10
  project(taco
11
- VERSION 0.8.2
11
+ VERSION 0.9.0
12
12
  DESCRIPTION "libtaco, the reference library for the TACO format."
13
13
  LANGUAGES CXX C
14
14
  )
@@ -48,7 +48,6 @@ set(TACO_SOURCES
48
48
  src/cozip_index.cpp
49
49
  src/dataset.cpp
50
50
  src/json.cpp
51
- src/manifest.cpp
52
51
  src/paths.cpp
53
52
  src/progress.cpp
54
53
  src/sql.cpp
@@ -101,7 +100,6 @@ if(TACO_BUILD_TESTS)
101
100
  target_link_libraries(taco_tests PRIVATE taco_objects)
102
101
  target_include_directories(taco_tests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/src)
103
102
  target_compile_definitions(taco_tests PRIVATE
104
- TACO_TEST_DATA="${CMAKE_CURRENT_SOURCE_DIR}/tests/data"
105
- TACO_TEST_CONFORMANCE="${CMAKE_CURRENT_SOURCE_DIR}/../r/inst/conformance/reader-resolution.json")
103
+ TACO_TEST_DATA="${CMAKE_CURRENT_SOURCE_DIR}/tests/data")
106
104
  add_test(NAME core COMMAND taco_tests)
107
105
  endif()
@@ -22,7 +22,7 @@
22
22
  extern "C" {
23
23
  #endif
24
24
 
25
- #define TACO_API_VERSION 1
25
+ #define TACO_API_VERSION 2
26
26
 
27
27
  typedef enum {
28
28
  TACO_OK = 0,
@@ -91,18 +91,6 @@ TACO_API taco_status taco_sql(const taco_dataset* const* datasets, size_t count,
91
91
  // Profile of a CoZIP archive: "none", "flat", "taco" or "unknown:<n>".
92
92
  TACO_API taco_status taco_profile(const char* source, char** out_name);
93
93
 
94
- // Where a versioned manifest would be, or NULL when the source is a dataset.
95
- TACO_API taco_status taco_manifest_candidate(const char* source, char** out_candidate);
96
-
97
- // A version href resolved against the manifest that lists it.
98
- TACO_API taco_status taco_join_manifest_href(const char* candidate, const char* href,
99
- char** out_source);
100
-
101
- // Resolves a versioned root to its default version. The JSON object has
102
- // "source", "collection", "version", "versions" and "manifest"; the last
103
- // four are null or empty when the source is not versioned.
104
- TACO_API taco_status taco_resolve(const char* source, char** out_json);
105
-
106
94
  // A byte range of a local or remote object and the file it is copied to. A
107
95
  // zero length copies from offset to the end of the object.
108
96
  typedef struct {
@@ -5,10 +5,9 @@
5
5
  // METADATA/ and a taco-cache.json stamp. The label names the dataset for
6
6
  // people; the hash names the source for lookups.
7
7
  //
8
- // An entry is trusted once its stamp exists, so opening a cached dataset
9
- // makes no request. TACO_CACHE_REFRESH in the environment rebuilds the
10
- // entries it touches. TACO_CACHE_SIZE caps the cache in bytes; the least
11
- // recently opened entries go first.
8
+ // Cached remote metadata is revalidated against an origin-provided value.
9
+ // TACO_CACHE_REFRESH rebuilds every entry it touches. TACO_CACHE_SIZE caps
10
+ // the cache in bytes; the least recently opened entries go first.
12
11
 
13
12
  #include <cstdint>
14
13
  #include <filesystem>
@@ -23,8 +22,8 @@ namespace taco {
23
22
  struct CacheStamp {
24
23
  std::string source;
25
24
  std::string container;
26
- // How the entry stays valid: "trusted", or the size and modification
27
- // time of a local archive.
25
+ // How the entry stays valid: origin-reported remote sizes, or the size
26
+ // and modification time of a local archive.
28
27
  std::string key;
29
28
  std::uint64_t size = 0;
30
29
  std::string created;
@@ -3,7 +3,6 @@
3
3
  #include "cozip_index.hpp"
4
4
  #include "dataset.hpp"
5
5
  #include "error.hpp"
6
- #include "manifest.hpp"
7
6
  #include "progress.hpp"
8
7
  #include "sql.hpp"
9
8
  #include "transport.hpp"
@@ -170,35 +169,6 @@ taco_status taco_profile(const char* source, char** out_name) {
170
169
  });
171
170
  }
172
171
 
173
- taco_status taco_manifest_candidate(const char* source, char** out_candidate) {
174
- if (out_candidate)
175
- *out_candidate = nullptr;
176
- return guard([&] {
177
- require(source && out_candidate, "taco_manifest_candidate: source and out_candidate must not be NULL");
178
- if (const auto candidate = taco::manifest_candidate(source))
179
- *out_candidate = copy_string(*candidate);
180
- });
181
- }
182
-
183
- taco_status taco_join_manifest_href(const char* candidate, const char* href, char** out_source) {
184
- if (out_source)
185
- *out_source = nullptr;
186
- return guard([&] {
187
- require(candidate && href && out_source,
188
- "taco_join_manifest_href: candidate, href and out_source must not be NULL");
189
- *out_source = copy_string(taco::join_manifest_href(candidate, href));
190
- });
191
- }
192
-
193
- taco_status taco_resolve(const char* source, char** out_json) {
194
- if (out_json)
195
- *out_json = nullptr;
196
- return guard([&] {
197
- require(source && out_json, "taco_resolve: source and out_json must not be NULL");
198
- *out_json = copy_string(taco::resolve_dataset(source));
199
- });
200
- }
201
-
202
172
  taco_status taco_fetch(const taco_fetch_item* items, size_t count) {
203
173
  return guard([&] {
204
174
  require(items || count == 0, "taco_fetch: items must not be NULL");
@@ -11,6 +11,7 @@
11
11
  #include <karu/karu.h>
12
12
 
13
13
  #include <algorithm>
14
+ #include <charconv>
14
15
  #include <exception>
15
16
  #include <filesystem>
16
17
  #include <fstream>
@@ -42,6 +43,45 @@ std::size_t level_depth(std::string_view level) {
42
43
  return level == "sample" ? 0 : 1 + static_cast<std::size_t>(std::count(level.begin(), level.end(), '/'));
43
44
  }
44
45
 
46
+ void validate_structure_leaf(const std::string& declaration, const std::string& source) {
47
+ const auto star = declaration.find('*');
48
+ if (star == std::string::npos) {
49
+ if (declaration.find_first_of("[]") != std::string::npos)
50
+ fail("COLLECTION.json: malformed variable leaf '" + declaration + "': " + source);
51
+ return;
52
+ }
53
+
54
+ const auto open = declaration.find('[', star);
55
+ const auto comma = declaration.find(',', open == std::string::npos ? star : open);
56
+ const auto close = declaration.find(']', comma == std::string::npos ? star : comma);
57
+ const auto slash = declaration.rfind('/', star);
58
+ const auto basename = slash == std::string::npos ? 0 : slash + 1;
59
+ if (star == basename || declaration.find_first_of("*[]", basename) != star || open != star + 1 ||
60
+ comma == std::string::npos || close == std::string::npos ||
61
+ declaration.find_first_of("*[]", close + 1) != std::string::npos) {
62
+ fail("COLLECTION.json: malformed variable leaf '" + declaration + "': " + source);
63
+ }
64
+
65
+ const auto parse_bound = [&](std::string_view text) {
66
+ while (!text.empty() && text.front() == ' ')
67
+ text.remove_prefix(1);
68
+ while (!text.empty() && text.back() == ' ')
69
+ text.remove_suffix(1);
70
+ std::uint64_t value = 0;
71
+ const auto [end, error] = std::from_chars(text.data(), text.data() + text.size(), value);
72
+ if (text.empty() || error != std::errc() || end != text.data() + text.size())
73
+ fail("COLLECTION.json: malformed variable leaf '" + declaration + "': " + source);
74
+ return value;
75
+ };
76
+
77
+ const auto minimum = parse_bound(std::string_view(declaration).substr(open + 1, comma - open - 1));
78
+ const auto maximum = parse_bound(std::string_view(declaration).substr(comma + 1, close - comma - 1));
79
+ if (minimum < 1)
80
+ fail("COLLECTION.json: variable leaf '" + declaration + "' must require at least one file: " + source);
81
+ if (minimum > maximum)
82
+ fail("COLLECTION.json: variable leaf '" + declaration + "' has min > max: " + source);
83
+ }
84
+
45
85
  void sort_and_validate(std::vector<Level>& levels, const std::string& source) {
46
86
  if (levels.empty())
47
87
  fail("no METADATA Parquet files found: " + source);
@@ -78,12 +118,12 @@ std::string location_base(const std::string& path) {
78
118
  return canonical;
79
119
  }
80
120
 
81
- // A local archive is checked against its size and modification time, which
82
- // costs a stat. A remote one is trusted until TACO_CACHE_REFRESH rebuilds it,
83
- // because TACO versions are immutable.
121
+ // Local archives use size and modification time. Remote objects use the
122
+ // origin-reported content length. If the probe fails, opening fails instead
123
+ // of silently serving metadata that can no longer be validated.
84
124
  std::string cache_key(const std::string& source) {
85
125
  if (has_uri_scheme(source))
86
- return "trusted";
126
+ return "remote size " + std::to_string(object_size(source));
87
127
  std::error_code error;
88
128
  const auto path = local_path(source);
89
129
  const auto size = fs::file_size(path, error);
@@ -95,7 +135,22 @@ std::string cache_key(const std::string& source) {
95
135
  }
96
136
 
97
137
  std::string expected_key(const std::string& source) {
98
- return has_uri_scheme(source) ? "" : cache_key(source);
138
+ return cache_key(source);
139
+ }
140
+
141
+ std::string remote_sizes_key(const std::vector<std::uint64_t>& sizes) {
142
+ std::string key = "remote sizes";
143
+ for (const auto size : sizes)
144
+ key += " " + std::to_string(size);
145
+ return key;
146
+ }
147
+
148
+ std::string remote_sizes_key(const std::vector<std::string>& sources) {
149
+ std::vector<std::uint64_t> sizes;
150
+ sizes.reserve(sources.size());
151
+ for (const auto& source : sources)
152
+ sizes.push_back(object_size(source));
153
+ return remote_sizes_key(sizes);
99
154
  }
100
155
 
101
156
  std::optional<Container> parse_container(const std::string& name) {
@@ -106,11 +161,11 @@ std::optional<Container> parse_container(const std::string& name) {
106
161
  return std::nullopt;
107
162
  }
108
163
 
109
- CacheStamp make_stamp(const std::string& source, Container container) {
164
+ CacheStamp make_stamp(const std::string& source, Container container, const std::string& validation_source = {}) {
110
165
  CacheStamp stamp;
111
166
  stamp.source = source;
112
167
  stamp.container = container_name(container);
113
- stamp.key = cache_key(source);
168
+ stamp.key = cache_key(validation_source.empty() ? source : validation_source);
114
169
  return stamp;
115
170
  }
116
171
 
@@ -233,14 +288,12 @@ json::Value parse_collection(const std::string& text, const std::string& source)
233
288
  }
234
289
  }
235
290
 
236
- // <id>-<version>-<container>-<origin>: what people see in the cache.
291
+ // <id>-<container>-<origin>: what people see in the cache.
237
292
  std::string entry_label(const std::string& collection, Container container, const std::string& source) {
238
293
  const json::Value root = parse_collection(collection, source);
239
294
  const json::Value* id = root.find("id");
240
- const json::Value* version = root.find("dataset_version");
241
- return cache_label(id && id->is_string() ? id->string : "dataset") + "-" +
242
- cache_label(version && version->is_string() ? version->string : "0") + "-" + container_name(container) +
243
- "-" + cache_origin(source);
295
+ return cache_label(id && id->is_string() ? id->string : "dataset") + "-" + container_name(container) + "-" +
296
+ cache_origin(source);
244
297
  }
245
298
 
246
299
  // Object stores cannot list directories reliably. The Parquet files come from
@@ -248,17 +301,12 @@ std::string entry_label(const std::string& collection, Container container, cons
248
301
  Dataset open_uri_directory(const std::string& source, const std::string& cache_root) {
249
302
  const std::string directory = trim_trailing_slashes(without_query(source));
250
303
  const std::string location = remote_directory(directory);
304
+ const std::string collection_source = child_path(directory, collection_name);
251
305
  CacheEntry cache(cache_root, location);
252
- if (const auto stamp = cache.find({std::string(collection_name)}, "")) {
253
- const auto container = parse_container(stamp->container);
254
- if (container && *container != Container::zip)
255
- return cached_dataset(directory, *container,
256
- *container == Container::tacocat ? parent_path(location) : location, cache);
257
- }
258
306
 
259
307
  // COLLECTION.json is the directory index: it declares every metadata
260
308
  // level, so opening an object-store dataset never requires listing it.
261
- const std::string collection = read_object(child_path(directory, collection_name), collection_limit, "COLLECTION.json");
309
+ const std::string collection = read_object(collection_source, collection_limit, "COLLECTION.json");
262
310
  const json::Value root = parse_collection(collection, directory);
263
311
  const json::Value* metadata = root.find("taco:metadata");
264
312
  if (!metadata || !metadata->is_object())
@@ -276,19 +324,24 @@ Dataset open_uri_directory(const std::string& source, const std::string& cache_r
276
324
  levels.push_back(Level{name, child_path(parquet_directory, level_to_file(name))});
277
325
  sort_and_validate(levels, directory);
278
326
 
327
+ std::vector<std::uint64_t> validation_sizes = {object_size(collection_source)};
279
328
  std::vector<Range> ranges;
280
- for (const auto& level : levels)
281
- ranges.push_back(Range{level.origin, 0, object_size(level.origin)});
329
+ for (const auto& level : levels) {
330
+ const auto size = object_size(level.origin);
331
+ validation_sizes.push_back(size);
332
+ ranges.push_back(Range{level.origin, 0, size});
333
+ }
282
334
  const auto contents = download(ranges, metadata_phase(directory));
283
335
  std::vector<std::pair<std::string, std::string>> files = {{std::string(collection_name), collection}};
284
336
  for (std::size_t i = 0; i < levels.size(); ++i)
285
337
  files.emplace_back(std::string(metadata_prefix) + level_to_file(levels[i].name), contents[i]);
286
- cache.store(entry_label(collection, container, directory), files, make_stamp(directory, container));
338
+ auto stamp = make_stamp(directory, container, collection_source);
339
+ stamp.key = remote_sizes_key(validation_sizes);
340
+ cache.store(entry_label(collection, container, directory), files, std::move(stamp));
287
341
  return cached_dataset(directory, container, tacocat ? parent_path(location) : location, cache);
288
342
  }
289
343
 
290
- // A URI whose entry is already stored opens without a request, whatever
291
- // container it turned out to be.
344
+ // A cached URI is reused only after its origin object has been revalidated.
292
345
  std::optional<Dataset> cached_uri_dataset(const std::string& source, const std::string& cache_root) {
293
346
  const std::string directory = trim_trailing_slashes(without_query(source));
294
347
  const std::string location = remote_directory(directory);
@@ -298,13 +351,50 @@ std::optional<Dataset> cached_uri_dataset(const std::string& source, const std::
298
351
  const auto stamp = entry.find({std::string(collection_name)}, "");
299
352
  if (!stamp)
300
353
  continue;
301
- const auto container = parse_container(stamp->container);
302
- if (!container)
354
+ try {
355
+ const auto container = parse_container(stamp->container);
356
+ if (!container)
357
+ continue;
358
+ const std::string collection = read_local(local_path(entry.path(collection_name)));
359
+ const json::Value root = parse_collection(collection, directory);
360
+ const json::Value* metadata = root.find("taco:metadata");
361
+ if (!metadata || !metadata->is_object())
362
+ continue;
363
+ std::vector<std::string> files = {std::string(collection_name)};
364
+ std::vector<std::string> validation_sources;
365
+ if (*container == Container::zip) {
366
+ validation_sources.push_back(source);
367
+ } else {
368
+ validation_sources.push_back(child_path(directory, collection_name));
369
+ }
370
+ const std::string parquet_directory =
371
+ *container == Container::tacocat ? directory : child_path(directory, "METADATA");
372
+ std::vector<std::string> levels;
373
+ for (const auto& [name, value] : metadata->members)
374
+ levels.push_back(name);
375
+ std::sort(levels.begin(), levels.end(), [](const auto& left, const auto& right) {
376
+ const auto left_depth = level_depth(left);
377
+ const auto right_depth = level_depth(right);
378
+ return left_depth != right_depth ? left_depth < right_depth : left < right;
379
+ });
380
+ for (const auto& level : levels) {
381
+ files.push_back(std::string(metadata_prefix) + level_to_file(level));
382
+ if (*container != Container::zip)
383
+ validation_sources.push_back(child_path(parquet_directory, level_to_file(level)));
384
+ }
385
+ const std::string key = *container == Container::zip ? expected_key(source)
386
+ : remote_sizes_key(validation_sources);
387
+ if (!entry.find(files, key))
388
+ continue;
389
+ if (*container == Container::zip)
390
+ return cached_dataset(source, Container::zip, location_base(source), entry);
391
+ return cached_dataset(directory, *container,
392
+ *container == Container::tacocat ? parent_path(location) : location, entry);
393
+ } catch (const Error&) {
394
+ // A stale entry may name metadata that no longer exists. Treat any
395
+ // failed validation as a miss and rebuild it from COLLECTION.json.
303
396
  continue;
304
- if (*container == Container::zip)
305
- return cached_dataset(source, Container::zip, location_base(source), entry);
306
- return cached_dataset(directory, *container,
307
- *container == Container::tacocat ? parent_path(location) : location, entry);
397
+ }
308
398
  }
309
399
  return std::nullopt;
310
400
  }
@@ -338,16 +428,13 @@ Contract read_contract(const Dataset& dataset) {
338
428
  const json::Value* structure = root.find("taco:structure");
339
429
  if (!structure)
340
430
  fail("COLLECTION.json has no taco:structure key: " + source);
341
- // TACO spec 5.2: null means every sample is a single file.
342
- contract.null_structure = structure->is_null();
343
- if (!contract.null_structure) {
344
- if (!structure->is_array())
345
- fail("COLLECTION.json: taco:structure must be an array or null: " + source);
346
- for (const auto& item : structure->items) {
347
- if (!item.is_string())
348
- fail("COLLECTION.json: taco:structure must contain strings: " + source);
349
- contract.structure.push_back(item.string);
350
- }
431
+ if (!structure->is_array() || structure->items.empty())
432
+ fail("COLLECTION.json: taco:structure must be a non-empty array: " + source);
433
+ for (const auto& item : structure->items) {
434
+ if (!item.is_string())
435
+ fail("COLLECTION.json: taco:structure must contain strings: " + source);
436
+ validate_structure_leaf(item.string, source);
437
+ contract.structure.push_back(item.string);
351
438
  }
352
439
 
353
440
  // taco:metadata names the user columns of every level. The reader needs
@@ -369,8 +456,8 @@ Contract read_contract(const Dataset& dataset) {
369
456
  }
370
457
  if (contract.fields.size() != dataset.level_names.size())
371
458
  fail("COLLECTION.json metadata levels do not match its Parquet files: " + source);
372
- if (contract.null_structure != (dataset.level_names.size() == 1))
373
- fail("COLLECTION.json structure does not match its metadata levels: " + source);
459
+ if (dataset.level_names.size() < 2)
460
+ fail("COLLECTION.json structure requires sample and children metadata levels: " + source);
374
461
 
375
462
  if (const json::Value* derived = root.find("taco:derived")) {
376
463
  if (!derived->is_object())
@@ -460,8 +547,8 @@ Dataset open_dataset(const std::string& source, const std::string& cache_dir) {
460
547
  Dataset dataset;
461
548
  std::error_code error;
462
549
  if (has_uri_scheme(source)) {
463
- // A complete cache entry settles the container type without network
464
- // access. Otherwise use URI shape first and probe only ambiguous URLs.
550
+ // A complete cache entry settles the container type after revalidation.
551
+ // Otherwise use URI shape first and probe only ambiguous URLs.
465
552
  if (auto cached = cached_uri_dataset(source, cache_root)) {
466
553
  cached->contract = read_contract(*cached);
467
554
  return *cached;