taco-eo 0.8.0__tar.gz → 0.8.2__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 (182) hide show
  1. {taco_eo-0.8.0 → taco_eo-0.8.2}/PKG-INFO +2 -2
  2. {taco_eo-0.8.0 → taco_eo-0.8.2}/examples/time_series.py +3 -1
  3. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/CMakeLists.txt +2 -2
  4. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/manifest.cpp +1 -1
  5. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/sql.cpp +58 -16
  6. {taco_eo-0.8.0 → taco_eo-0.8.2}/pyproject.toml +2 -2
  7. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/_repr.py +2 -1
  8. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/contract/collection.py +6 -5
  9. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/metadata/derived.py +129 -54
  10. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/reader/dataset.py +36 -11
  11. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/validate.py +1 -1
  12. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_collection.py +7 -0
  13. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_core_reader.py +42 -12
  14. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_extension_rumi.py +42 -0
  15. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_extension_spatiotemporal.py +2 -2
  16. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_metadata.py +71 -27
  17. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_reader.py +3 -3
  18. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_tacocat.py +1 -1
  19. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_writer.py +20 -0
  20. {taco_eo-0.8.0 → taco_eo-0.8.2}/.gitignore +0 -0
  21. {taco_eo-0.8.0 → taco_eo-0.8.2}/LICENSE +0 -0
  22. {taco_eo-0.8.0 → taco_eo-0.8.2}/README.md +0 -0
  23. {taco_eo-0.8.0 → taco_eo-0.8.2}/examples/change_detection.py +0 -0
  24. {taco_eo-0.8.0 → taco_eo-0.8.2}/examples/geospatial.py +0 -0
  25. {taco_eo-0.8.0 → taco_eo-0.8.2}/examples/minimal.py +0 -0
  26. {taco_eo-0.8.0 → taco_eo-0.8.2}/examples/numpy_minimal.py +0 -0
  27. {taco_eo-0.8.0 → taco_eo-0.8.2}/examples/oceantaco_istac.py +0 -0
  28. {taco_eo-0.8.0 → taco_eo-0.8.2}/examples/partitioned.py +0 -0
  29. {taco_eo-0.8.0 → taco_eo-0.8.2}/examples/sequence.py +0 -0
  30. {taco_eo-0.8.0 → taco_eo-0.8.2}/examples/stac_segmentation.py +0 -0
  31. {taco_eo-0.8.0 → taco_eo-0.8.2}/hatch_build.py +0 -0
  32. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/include/taco/taco.h +0 -0
  33. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/cache.cpp +0 -0
  34. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/cache.hpp +0 -0
  35. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/capi.cpp +0 -0
  36. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/cozip_index.cpp +0 -0
  37. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/cozip_index.hpp +0 -0
  38. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/dataset.cpp +0 -0
  39. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/dataset.hpp +0 -0
  40. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/error.hpp +0 -0
  41. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/json.cpp +0 -0
  42. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/json.hpp +0 -0
  43. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/manifest.hpp +0 -0
  44. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/paths.cpp +0 -0
  45. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/paths.hpp +0 -0
  46. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/progress.cpp +0 -0
  47. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/progress.hpp +0 -0
  48. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/sql.hpp +0 -0
  49. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/transport.cpp +0 -0
  50. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/core/src/transport.hpp +0 -0
  51. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/CMakeLists.txt +0 -0
  52. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/LICENSE +0 -0
  53. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/VERSION +0 -0
  54. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/cmake/karuConfig.cmake.in +0 -0
  55. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/include/karu/karu.h +0 -0
  56. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/include/karu/karu.hpp +0 -0
  57. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/aws_profile.cpp +0 -0
  58. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/aws_profile.hpp +0 -0
  59. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/azure.cpp +0 -0
  60. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/azure_credentials.cpp +0 -0
  61. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/azure_credentials.hpp +0 -0
  62. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/contract.hpp +0 -0
  63. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/credentials.cpp +0 -0
  64. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/credentials.hpp +0 -0
  65. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/crypto.cpp +0 -0
  66. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/crypto.hpp +0 -0
  67. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/gcs.cpp +0 -0
  68. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/gcs_credentials.cpp +0 -0
  69. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/gcs_credentials.hpp +0 -0
  70. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/http.cpp +0 -0
  71. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/hugging_face.cpp +0 -0
  72. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/registry.cpp +0 -0
  73. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/s3.cpp +0 -0
  74. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/s3_credentials.cpp +0 -0
  75. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/s3_credentials.hpp +0 -0
  76. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/s3_signing.cpp +0 -0
  77. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/s3_signing.hpp +0 -0
  78. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/source.cpp +0 -0
  79. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/source_credentials.cpp +0 -0
  80. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/source_credentials.hpp +0 -0
  81. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/url.cpp +0 -0
  82. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/backends/url.hpp +0 -0
  83. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/buffer.hpp +0 -0
  84. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/client.hpp +0 -0
  85. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/config.cpp +0 -0
  86. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/config.hpp +0 -0
  87. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/config_options.hpp +0 -0
  88. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/credential_cache.cpp +0 -0
  89. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/credential_cache.hpp +0 -0
  90. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/error.cpp +0 -0
  91. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/error.hpp +0 -0
  92. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/karu.cpp +0 -0
  93. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/locator.hpp +0 -0
  94. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/platform.cpp +0 -0
  95. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/platform.hpp +0 -0
  96. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/process.cpp +0 -0
  97. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/process.hpp +0 -0
  98. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/request.hpp +0 -0
  99. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/request_builder.cpp +0 -0
  100. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/request_builder.hpp +0 -0
  101. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/runtime/batch.cpp +0 -0
  102. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/runtime/batch.hpp +0 -0
  103. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/runtime/curl_types.hpp +0 -0
  104. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/runtime/deadline.hpp +0 -0
  105. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/runtime/engine.cpp +0 -0
  106. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/runtime/engine.hpp +0 -0
  107. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/runtime/http_response.cpp +0 -0
  108. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/runtime/http_response.hpp +0 -0
  109. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/runtime/planner.cpp +0 -0
  110. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/runtime/planner.hpp +0 -0
  111. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/runtime/transfer.hpp +0 -0
  112. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/runtime/transport.cpp +0 -0
  113. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/runtime/transport.hpp +0 -0
  114. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/text.hpp +0 -0
  115. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/uri.cpp +0 -0
  116. {taco_eo-0.8.0 → taco_eo-0.8.2}/native/extern/karu/src/uri.hpp +0 -0
  117. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/__init__.py +0 -0
  118. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/_graph.py +0 -0
  119. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/container/__init__.py +0 -0
  120. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/container/cozip.py +0 -0
  121. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/container/parquet.py +0 -0
  122. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/container/publish.py +0 -0
  123. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/container/view.py +0 -0
  124. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/contract/__init__.py +0 -0
  125. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/contract/contract.py +0 -0
  126. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/contract/naming.py +0 -0
  127. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/contract/sample.py +0 -0
  128. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/contract/schema.py +0 -0
  129. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/contract/structure.py +0 -0
  130. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/contract/types.py +0 -0
  131. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/errors.py +0 -0
  132. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/extensions/__init__.py +0 -0
  133. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/extensions/rumi.py +0 -0
  134. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/extensions/spatiotemporal.py +0 -0
  135. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/metadata/__init__.py +0 -0
  136. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/metadata/_base.py +0 -0
  137. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/metadata/asset.py +0 -0
  138. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/metadata/collection.py +0 -0
  139. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/metadata/data/admin/admin0.parquet +0 -0
  140. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/metadata/data/admin/admin1.parquet +0 -0
  141. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/metadata/data/admin/admin2.parquet +0 -0
  142. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/metadata/folder.py +0 -0
  143. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/metadata/sample.py +0 -0
  144. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/metadata/spatiotemporal.py +0 -0
  145. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/metadata/split.py +0 -0
  146. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/py.typed +0 -0
  147. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/reader/__init__.py +0 -0
  148. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/reader/api.py +0 -0
  149. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/reader/collection.py +0 -0
  150. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/reader/engine.py +0 -0
  151. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/reader/inspect.py +0 -0
  152. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/reader/manifest.py +0 -0
  153. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/reader/native.py +0 -0
  154. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/reader/query.py +0 -0
  155. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/reader/source.py +0 -0
  156. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/writer/__init__.py +0 -0
  157. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/writer/api.py +0 -0
  158. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/writer/archive.py +0 -0
  159. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/writer/base.py +0 -0
  160. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/writer/catalog.py +0 -0
  161. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/writer/export.py +0 -0
  162. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/writer/folder.py +0 -0
  163. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/writer/metadata.py +0 -0
  164. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/writer/partition.py +0 -0
  165. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/writer/progress.py +0 -0
  166. {taco_eo-0.8.0 → taco_eo-0.8.2}/taco/writer/staging.py +0 -0
  167. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/__init__.py +0 -0
  168. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/conftest.py +0 -0
  169. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/data/reader-resolution.json +0 -0
  170. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/datasets.py +0 -0
  171. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_contract.py +0 -0
  172. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_examples.py +0 -0
  173. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_export.py +0 -0
  174. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_extension_contract.py +0 -0
  175. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_parquet.py +0 -0
  176. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_progress.py +0 -0
  177. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_publish.py +0 -0
  178. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_reader_conformance.py +0 -0
  179. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_types.py +0 -0
  180. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_validate.py +0 -0
  181. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_versioned.py +0 -0
  182. {taco_eo-0.8.0 → taco_eo-0.8.2}/tests/test_writer_cases.py +0 -0
@@ -1,7 +1,7 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: taco-eo
3
- Version: 0.8.0
4
- Summary: Read and write TACO datasets in Python.
3
+ Version: 0.8.2
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
7
7
  Project-URL: Repository, https://github.com/asterisk-labs/taco
@@ -59,7 +59,9 @@ with taco.open_writer(collection, "time-series.zip", overwrite=True) as writer:
59
59
 
60
60
  dataset = taco.open_dataset("time-series.zip")
61
61
  table = taco.read(dataset)
62
- lengths = dict(zip(table.column("sample_id").to_pylist(), map(len, table.column("image").to_pylist()), strict=True))
62
+ lengths = dict(
63
+ zip(table.column("sample_id").to_pylist(), map(len, table.column("image::location").to_pylist()), strict=True)
64
+ )
63
65
  assert lengths == {0: 3, 1: 5}
64
66
  assert dataset.sql("SELECT * FROM files").num_rows == 8
65
67
  assert taco.validate("time-series.zip").ok
@@ -8,8 +8,8 @@ if(NOT TACO_API_VERSION_LINE)
8
8
  endif()
9
9
 
10
10
  project(taco
11
- VERSION 0.8.0
12
- DESCRIPTION "Native TACO reader shared by the Python, R and Julia packages"
11
+ VERSION 0.8.2
12
+ DESCRIPTION "libtaco, the reference library for the TACO format."
13
13
  LANGUAGES CXX C
14
14
  )
15
15
 
@@ -66,7 +66,7 @@ void validate_collection(const json::Value& collection, const std::string& versi
66
66
  const std::string prefix = "version '" + version + "' embeds an invalid collection: ";
67
67
  std::string missing;
68
68
  for (const char* key : {"taco:version", "id", "dataset_version", "description", "licenses", "providers",
69
- "tasks", "taco:structure", "taco:metadata"}) {
69
+ "taco:structure", "taco:metadata"}) {
70
70
  if (!collection.find(key))
71
71
  missing += (missing.empty() ? "" : ", ") + std::string(key);
72
72
  }
@@ -20,6 +20,9 @@ constexpr const char* id_size = "internal:size";
20
20
  constexpr const char* id_source = "internal:source_file";
21
21
  constexpr const char* location_column = "taco:location";
22
22
  constexpr const char* flat_location_column = "cozip:location";
23
+ // Rumi assets are read statelessly with their header, so a wide read carries
24
+ // it next to the location of every leaf whose level declares it.
25
+ constexpr const char* header_field = "rumi:header";
23
26
  constexpr const char* data_directory = "DATA";
24
27
 
25
28
  std::string regex_escape(std::string_view value) {
@@ -56,6 +59,13 @@ Leaf parse_leaf(const std::string& declaration) {
56
59
  return leaf;
57
60
  }
58
61
 
62
+ // The metadata level that holds the rows of a leaf: its folder under children.
63
+ std::string leaf_level(const Leaf& leaf) {
64
+ const auto& path = leaf.variable ? leaf.prefix : leaf.declaration;
65
+ const auto slash = path.rfind('/');
66
+ return slash == std::string::npos ? "children" : "children/" + path.substr(0, slash);
67
+ }
68
+
59
69
  std::string output_name(const Leaf& leaf) {
60
70
  auto name = leaf.variable ? leaf.prefix : leaf.declaration;
61
71
  std::string out;
@@ -117,7 +127,11 @@ class QueryBuilder {
117
127
  out += ", " + alias(0) + ".*" + exclude_list(0);
118
128
  for (const auto& leaf : leaves) {
119
129
  out += leaf.variable ? ", NULL::VARCHAR[] AS " : ", NULL::VARCHAR AS ";
120
- out += sql_identifier(output_name(leaf));
130
+ out += sql_identifier(location_name(leaf));
131
+ if (has_header(leaf)) {
132
+ out += leaf.variable ? ", NULL::BLOB[] AS " : ", NULL::BLOB AS ";
133
+ out += sql_identifier(header_name(leaf));
134
+ }
121
135
  }
122
136
  out += " FROM (SELECT " + metadata_projection() + " FROM read_parquet(" +
123
137
  sql_literal(dataset_.level_paths[0]) + ")) AS " + alias(0);
@@ -136,18 +150,9 @@ class QueryBuilder {
136
150
  if (tacocat_)
137
151
  out += ", source_file";
138
152
  for (const auto& leaf : leaves) {
139
- if (leaf.variable) {
140
- // TACO spec 5.2: the index has no leading zeros, so img01.tif is
141
- // not an instance of img*[a,b].tif.
142
- const auto pattern = variable_pattern(leaf);
143
- out += ", list(" + sql_identifier(location_column) +
144
- " ORDER BY TRY_CAST(regexp_extract(path, " + sql_literal(pattern) +
145
- ", 1) AS BIGINT)) FILTER (WHERE regexp_matches(path, " + sql_literal(pattern) +
146
- ")) AS " + sql_identifier(output_name(leaf));
147
- } else {
148
- out += ", MAX(CASE WHEN path = " + sql_literal(leaf.declaration) + " THEN " +
149
- sql_identifier(location_column) + " END) AS " + sql_identifier(output_name(leaf));
150
- }
153
+ out += pivot_column(leaf, location_column, location_name(leaf));
154
+ if (has_header(leaf))
155
+ out += pivot_column(leaf, header_field, header_name(leaf));
151
156
  }
152
157
  out += " FROM flat GROUP BY ALL)";
153
158
 
@@ -156,11 +161,18 @@ class QueryBuilder {
156
161
  out += ", " + alias(0) + "." + sql_identifier(id_source) + " AS source_file";
157
162
  out += ", " + alias(0) + ".*" + exclude_list(0);
158
163
  for (const auto& leaf : leaves) {
159
- const auto name = output_name(leaf);
164
+ const auto location = location_name(leaf);
165
+ if (leaf.variable)
166
+ out += ", COALESCE(p." + sql_identifier(location) + ", []::VARCHAR[]) AS " + sql_identifier(location);
167
+ else
168
+ out += ", p." + sql_identifier(location);
169
+ if (!has_header(leaf))
170
+ continue;
171
+ const auto header = header_name(leaf);
160
172
  if (leaf.variable)
161
- out += ", COALESCE(p." + sql_identifier(name) + ", []::VARCHAR[]) AS " + sql_identifier(name);
173
+ out += ", COALESCE(p." + sql_identifier(header) + ", []::BLOB[]) AS " + sql_identifier(header);
162
174
  else
163
- out += ", p." + sql_identifier(name);
175
+ out += ", p." + sql_identifier(header);
164
176
  }
165
177
  out += " FROM " + alias(0) + " LEFT JOIN pivoted p ON p.sample_id = " + alias(0) + "." +
166
178
  sql_identifier(id_current);
@@ -175,6 +187,31 @@ class QueryBuilder {
175
187
  private:
176
188
  static std::string alias(std::size_t level) { return "l" + std::to_string(level); }
177
189
 
190
+ // Metadata fields contain exactly one ':'. The double separator keeps
191
+ // generated columns outside that namespace without hiding the leaf name.
192
+ static std::string location_name(const Leaf& leaf) { return output_name(leaf) + "::location"; }
193
+ static std::string header_name(const Leaf& leaf) { return output_name(leaf) + "::header"; }
194
+
195
+ [[nodiscard]] bool has_header(const Leaf& leaf) const {
196
+ const auto* fields = dataset_.contract.fields_of(leaf_level(leaf));
197
+ return fields && std::find(fields->begin(), fields->end(), header_field) != fields->end();
198
+ }
199
+
200
+ // One pivoted value of a leaf: the value itself, or the list of a
201
+ // variable sequence ordered by its numeric index.
202
+ static std::string pivot_column(const Leaf& leaf, const std::string& column, const std::string& name) {
203
+ if (!leaf.variable) {
204
+ return ", MAX(CASE WHEN path = " + sql_literal(leaf.declaration) + " THEN " + sql_identifier(column) +
205
+ " END) AS " + sql_identifier(name);
206
+ }
207
+ // TACO spec 5.2: the index has no leading zeros, so img01.tif is not an
208
+ // instance of img*[a,b].tif.
209
+ const auto pattern = variable_pattern(leaf);
210
+ return ", list(" + sql_identifier(column) + " ORDER BY TRY_CAST(regexp_extract(path, " + sql_literal(pattern) +
211
+ ", 1) AS BIGINT)) FILTER (WHERE regexp_matches(path, " + sql_literal(pattern) + ")) AS " +
212
+ sql_identifier(name);
213
+ }
214
+
178
215
  static std::string metadata_projection() {
179
216
  return "COLUMNS(lambda c: c != " + sql_literal(flat_location_column) + " AND c != " +
180
217
  sql_literal(location_column) + ")";
@@ -374,6 +411,11 @@ class QueryBuilder {
374
411
  out += ", " + path_expression(level) + " AS path";
375
412
  if (identity_only || options_.location)
376
413
  out += ", " + location_expression(level) + " AS " + sql_identifier(location_column);
414
+ if (identity_only) {
415
+ const auto* fields = dataset_.contract.fields_of(dataset_.level_names[level]);
416
+ if (fields && std::find(fields->begin(), fields->end(), header_field) != fields->end())
417
+ out += ", " + alias(level) + "." + sql_identifier(header_field);
418
+ }
377
419
  if (!identity_only)
378
420
  out += ancestor_projection(level);
379
421
  out += " FROM " + alias(level) + join_chain(level);
@@ -9,8 +9,8 @@ build-backend = "hatchling.build"
9
9
 
10
10
  [project]
11
11
  name = "taco-eo"
12
- version = "0.8.0"
13
- description = "Read and write TACO datasets in Python."
12
+ version = "0.8.2"
13
+ description = "Python bindings to libtaco, the reference library for the TACO format."
14
14
  readme = "README.md"
15
15
  license = "MIT"
16
16
  license-files = ["LICENSE"]
@@ -224,10 +224,11 @@ def _collection(dataset: Dataset) -> str:
224
224
  rows: list[tuple[str, Any]] = [
225
225
  ("id", collection.id),
226
226
  ("version", collection.dataset_version),
227
- ("tasks", list(collection.tasks)),
228
227
  ("licenses", list(collection.licenses)),
229
228
  ("providers", [provider.name for provider in collection.providers]),
230
229
  ]
230
+ if collection.tasks is not None:
231
+ rows.insert(2, ("tasks", list(collection.tasks)))
231
232
  if collection.extent is not None:
232
233
  rows.append(("extent", collection.extent.to_dict()))
233
234
  if collection.metadata is not None:
@@ -270,7 +270,7 @@ class Collection:
270
270
  description: str
271
271
  licenses: tuple[str, ...]
272
272
  providers: tuple[Provider, ...]
273
- tasks: tuple[str, ...]
273
+ tasks: tuple[str, ...] | None = None
274
274
  metadata: CollectionMetadata | None = None
275
275
  title: str | None = None
276
276
  curators: tuple[Curator, ...] | None = None
@@ -288,7 +288,8 @@ class Collection:
288
288
  if not isinstance(self.description, str) or not self.description.strip():
289
289
  raise CollectionError("collection description is required")
290
290
  object.__setattr__(self, "licenses", _string_list(self.licenses, name="licenses", required=True))
291
- object.__setattr__(self, "tasks", _string_list(self.tasks, name="tasks", required=True))
291
+ if self.tasks is not None:
292
+ object.__setattr__(self, "tasks", _string_list(self.tasks, name="tasks", required=True))
292
293
  if isinstance(self.providers, (str, Mapping, Provider)) or not isinstance(self.providers, Sequence):
293
294
  raise CollectionError("providers must be a list")
294
295
  if not self.providers:
@@ -324,9 +325,10 @@ class Collection:
324
325
  "description": self.description,
325
326
  "licenses": list(self.licenses),
326
327
  "providers": [provider.to_dict() for provider in self.providers],
327
- "tasks": list(self.tasks),
328
328
  **self.contract.to_dict(),
329
329
  }
330
+ if self.tasks is not None:
331
+ data["tasks"] = list(self.tasks)
330
332
  if self.title is not None:
331
333
  data["title"] = self.title
332
334
  if self.curators is not None:
@@ -356,7 +358,6 @@ class Collection:
356
358
  "description",
357
359
  "licenses",
358
360
  "providers",
359
- "tasks",
360
361
  "taco:structure",
361
362
  "taco:metadata",
362
363
  )
@@ -389,7 +390,7 @@ class Collection:
389
390
  description=data["description"],
390
391
  licenses=data["licenses"],
391
392
  providers=tuple(Provider.from_any(value) for value in providers),
392
- tasks=data["tasks"],
393
+ tasks=data.get("tasks"),
393
394
  metadata=CollectionMetadata.from_flat(extra) if extra else None,
394
395
  title=data.get("title"),
395
396
  curators=None if curators is None else tuple(Curator.from_any(value) for value in curators),
@@ -2,6 +2,7 @@ from __future__ import annotations
2
2
 
3
3
  import math
4
4
  import re
5
+ import time
5
6
  from collections.abc import Mapping, Sequence
6
7
  from concurrent.futures import ThreadPoolExecutor
7
8
  from dataclasses import dataclass
@@ -133,7 +134,7 @@ class MajorTOM(DerivedMetadata):
133
134
  indexes[indexes < 0] = row_lons.size - 1
134
135
  column_indexes[selected] = indexes
135
136
 
136
- distance = f"{int(self.dist_km):04d}km"
137
+ distance = f"MT{int(self.dist_km)}km"
137
138
  codes = [
138
139
  self.sep.join(
139
140
  (
@@ -172,6 +173,35 @@ def _admin_names(level: int) -> dict[int, str]:
172
173
  return dict(zip(codes.to_pylist(), names.to_pylist(), strict=True))
173
174
 
174
175
 
176
+ _OCEAN_CODE = 65535
177
+
178
+
179
+ @dataclass(frozen=True)
180
+ class _Product:
181
+ asset: str
182
+ description: str
183
+ band: str | None = None
184
+ mosaic: bool = False
185
+ reducer: str = "mean"
186
+ scale: float = 1.0
187
+ offset: float = 0.0
188
+ fill: float | None = None
189
+
190
+ def convert(self, value: Any) -> float | None:
191
+ if value is None:
192
+ return None
193
+ return float(value) * self.scale + self.offset
194
+
195
+
196
+ def _get_info(request: Any) -> Any:
197
+ for delay in (1, 2, 4, 8):
198
+ try:
199
+ return request.getInfo()
200
+ except Exception:
201
+ time.sleep(delay)
202
+ return request.getInfo()
203
+
204
+
175
205
  @dataclass(frozen=True, init=False)
176
206
  class GeoEnrich(DerivedMetadata):
177
207
  """Fetch selected Earth Engine variables and resolve administrative names."""
@@ -184,51 +214,91 @@ class GeoEnrich(DerivedMetadata):
184
214
  batch_size: int
185
215
  max_concurrency: int
186
216
  centroid: str
187
- _PRODUCTS: ClassVar[dict[str, tuple[str, str | None, bool, str, int]]] = {
188
- "elevation": ("projects/sat-io/open-datasets/GLO-30", None, True, "mean", 0),
189
- "cisi": ("projects/sat-io/open-datasets/CISI/global_CISI", None, False, "mean", 0),
190
- "precipitation": ("projects/ee-csaybar-real/assets/precipitation", None, False, "mean", 0),
191
- "temperature": ("projects/ee-csaybar-real/assets/temperature", None, False, "mean", 0),
192
- "soil_clay": ("OpenLandMap/SOL/SOL_CLAY-WFRACTION_USDA-3A1A1A_M/v02", "b0", False, "mean", 0),
193
- "soil_sand": ("OpenLandMap/SOL/SOL_SAND-WFRACTION_USDA-3A1A1A_M/v02", "b0", False, "mean", 0),
194
- "soil_carbon": ("OpenLandMap/SOL/SOL_ORGANIC-CARBON_USDA-6A1C_M/v02", "b0", False, "mean", 0),
195
- "soil_bulk_density": ("OpenLandMap/SOL/SOL_BULKDENS-FINEEARTH_USDA-4A1H_M/v02", "b0", False, "mean", 0),
196
- "soil_ph": ("OpenLandMap/SOL/SOL_PH-H2O_USDA-4C1A2A_M/v02", "b0", False, "mean", 0),
197
- "gdp": (
217
+ _PRODUCTS: ClassVar[dict[str, _Product]] = {
218
+ "elevation": _Product(
219
+ "projects/sat-io/open-datasets/GLO-30",
220
+ "Elevation in metres (Copernicus GLO-30 DEM)",
221
+ mosaic=True,
222
+ ),
223
+ "cisi": _Product(
224
+ "projects/sat-io/open-datasets/CISI/global_CISI",
225
+ "Critical Infrastructure Spatial Index, 0 to 1 (Nirandjan et al. 2022)",
226
+ ),
227
+ # ERA5 monthly climatologies for 1979-01 to 2020-06, precomputed once and stored in metres and kelvin.
228
+ "precipitation": _Product(
229
+ "projects/ee-csaybar-real/assets/precipitation",
230
+ "Mean annual precipitation in mm per year (ERA5, 1979 to 2020)",
231
+ scale=1000.0,
232
+ ),
233
+ "temperature": _Product(
234
+ "projects/ee-csaybar-real/assets/temperature",
235
+ "Mean annual 2 m air temperature in degrees Celsius (ERA5, 1979 to 2020)",
236
+ offset=-273.15,
237
+ ),
238
+ # OpenLandMap stores scaled integers; the factors are gee:scale in the catalog.
239
+ "soil_clay": _Product(
240
+ "OpenLandMap/SOL/SOL_CLAY-WFRACTION_USDA-3A1A1A_M/v02",
241
+ "Clay content at 0 cm depth in percent by weight (OpenLandMap)",
242
+ band="b0",
243
+ ),
244
+ "soil_sand": _Product(
245
+ "OpenLandMap/SOL/SOL_SAND-WFRACTION_USDA-3A1A1A_M/v02",
246
+ "Sand content at 0 cm depth in percent by weight (OpenLandMap)",
247
+ band="b0",
248
+ ),
249
+ "soil_carbon": _Product(
250
+ "OpenLandMap/SOL/SOL_ORGANIC-CARBON_USDA-6A1C_M/v02",
251
+ "Soil organic carbon at 0 cm depth in g/kg (OpenLandMap)",
252
+ band="b0",
253
+ scale=5.0,
254
+ ),
255
+ "soil_bulk_density": _Product(
256
+ "OpenLandMap/SOL/SOL_BULKDENS-FINEEARTH_USDA-4A1H_M/v02",
257
+ "Fine earth bulk density at 0 cm depth in kg/m3 (OpenLandMap)",
258
+ band="b0",
259
+ scale=10.0,
260
+ ),
261
+ "soil_ph": _Product(
262
+ "OpenLandMap/SOL/SOL_PH-H2O_USDA-4C1A2A_M/v02",
263
+ "Soil pH in water at 0 cm depth (OpenLandMap)",
264
+ band="b0",
265
+ scale=0.1,
266
+ ),
267
+ "gdp": _Product(
198
268
  "projects/sat-io/open-datasets/GRIDDED_HDI_GDP/total_gdp_perCapita_1990_2022_5arcmin",
199
- "PPP_2022",
200
- False,
201
- "mean",
202
- 0,
269
+ "Total GDP for 2022 in 2017 international dollars, PPP (Kummu et al. 2025)",
270
+ band="PPP_2022",
203
271
  ),
204
- "human_modification": (
205
- "projects/sat-io/open-datasets/GHM/HM_1990_2020_OVERALL_300M",
206
- "constant",
207
- True,
208
- "mean",
209
- 0,
272
+ "human_modification": _Product(
273
+ "projects/sat-io/open-datasets/GHM/HM_1990_2020_OVERALL_300M/HMv20240801_2020c_AA_300",
274
+ "Human modification index for 2020, 0 to 1 (GHM v3, Theobald et al. 2025)",
275
+ band="constant",
276
+ ),
277
+ # GPW masks water and Antarctica. Nobody lives there, so masked pixels become 0 rather than null.
278
+ "population": _Product(
279
+ "CIESIN/GPWv411/GPW_Population_Density/gpw_v4_population_density_rev11_2020_30_sec",
280
+ "Population density in people per km2, 0 over water and Antarctica (GPW v4.11, 2020)",
281
+ band="population_density",
282
+ fill=0.0,
283
+ ),
284
+ "admin_countries": _Product(
285
+ "projects/ee-csaybar-real/assets/admin0",
286
+ "Country name at the centroid, or Ocean/Sea/Lakes",
287
+ reducer="mode",
288
+ fill=_OCEAN_CODE,
289
+ ),
290
+ "admin_states": _Product(
291
+ "projects/ee-csaybar-real/assets/admin1",
292
+ "State or province name at the centroid",
293
+ reducer="mode",
294
+ fill=_OCEAN_CODE,
295
+ ),
296
+ "admin_districts": _Product(
297
+ "projects/ee-csaybar-real/assets/admin2",
298
+ "District or county name at the centroid",
299
+ reducer="mode",
300
+ fill=_OCEAN_CODE,
210
301
  ),
211
- "population": ("projects/sat-io/open-datasets/hrsl/hrslpop", None, True, "mean", 0),
212
- "admin_countries": ("projects/ee-csaybar-real/assets/admin0", None, False, "mode", 65535),
213
- "admin_states": ("projects/ee-csaybar-real/assets/admin1", None, False, "mode", 65535),
214
- "admin_districts": ("projects/ee-csaybar-real/assets/admin2", None, False, "mode", 65535),
215
- }
216
- _DESCRIPTIONS: ClassVar[dict[str, str]] = {
217
- "elevation": "Mean elevation in metres (GLO-30 DEM)",
218
- "cisi": "Mean Critical Infrastructure Spatial Index",
219
- "precipitation": "Mean annual precipitation in millimetres",
220
- "temperature": "Mean annual temperature in degrees Celsius",
221
- "soil_clay": "Surface soil clay content",
222
- "soil_sand": "Surface soil sand content",
223
- "soil_carbon": "Surface soil organic carbon content",
224
- "soil_bulk_density": "Surface soil bulk density",
225
- "soil_ph": "Surface soil pH",
226
- "gdp": "GDP per capita in PPP 2022 USD",
227
- "human_modification": "Global human modification index",
228
- "population": "Population density from HRSL",
229
- "admin_countries": "Country name at the centroid",
230
- "admin_states": "State or province name at the centroid",
231
- "admin_districts": "District or county name at the centroid",
232
302
  }
233
303
 
234
304
  def __init__(
@@ -272,8 +342,8 @@ class GeoEnrich(DerivedMetadata):
272
342
  pa.field(
273
343
  name,
274
344
  pa.string() if name.startswith("admin_") else pa.float32(),
275
- nullable=False,
276
- metadata={b"description": self._DESCRIPTIONS[name].encode()},
345
+ nullable=not name.startswith("admin_"),
346
+ metadata={b"description": self._PRODUCTS[name].description.encode()},
277
347
  )
278
348
  for name in self.variables
279
349
  )
@@ -306,16 +376,17 @@ class GeoEnrich(DerivedMetadata):
306
376
  points.sort(key=lambda point: _morton_key(point[1], point[2]))
307
377
  groups: dict[str, list[tuple[str, Any]]] = {"mean": [], "mode": []}
308
378
  for name in self.variables:
309
- path, band, image_collection, reducer, unmask = self._PRODUCTS[name]
310
- image = ee.ImageCollection(path).mosaic() if image_collection else ee.Image(path)
311
- image = image.unmask(unmask)
312
- if band is not None:
313
- image = image.select(band)
314
- groups[reducer].append((name, image.rename(name)))
379
+ product = self._PRODUCTS[name]
380
+ image = ee.ImageCollection(product.asset).mosaic() if product.mosaic else ee.Image(product.asset)
381
+ if product.fill is not None:
382
+ image = image.unmask(product.fill)
383
+ if product.band is not None:
384
+ image = image.select(product.band)
385
+ groups[product.reducer].append((name, image.rename(name)))
315
386
  groups = {name: products for name, products in groups.items() if products}
316
387
  chunks = [points[start : start + self.batch_size] for start in range(0, count, self.batch_size)]
317
388
  result: dict[str, list[Any]] = {
318
- name: (["Ocean/Sea/Lakes"] * count if name.startswith("admin_") else [0.0] * count)
389
+ name: (["Ocean/Sea/Lakes"] * count if name.startswith("admin_") else [None] * count)
319
390
  for name in self.variables
320
391
  }
321
392
 
@@ -326,7 +397,10 @@ class GeoEnrich(DerivedMetadata):
326
397
  for reducer, products in groups.items():
327
398
  image = ee.Image([product[1] for product in products])
328
399
  operation = ee.Reducer.mean() if reducer == "mean" else ee.Reducer.mode()
329
- response = image.reduceRegions(collection=collection, reducer=operation, scale=self.scale_m).getInfo()
400
+ # A fixed grid keeps each value independent of which other variables are requested.
401
+ response = _get_info(
402
+ image.reduceRegions(collection=collection, reducer=operation, scale=self.scale_m, crs="EPSG:4326")
403
+ )
330
404
  for feature in response.get("features", []):
331
405
  properties = feature.get("properties", {})
332
406
  index = properties.get("taco_index")
@@ -347,7 +421,8 @@ class GeoEnrich(DerivedMetadata):
347
421
  "Ocean/Sea/Lakes" if value is None else _admin_names(level).get(int(value)) or "Unknown"
348
422
  )
349
423
  else:
350
- result[name][index] = float(np.float32(0 if value is None else value))
424
+ converted = self._PRODUCTS[name].convert(value)
425
+ result[name][index] = None if converted is None else float(np.float32(converted))
351
426
  return result
352
427
 
353
428
 
@@ -6,7 +6,8 @@ from collections.abc import Sequence
6
6
  import pyarrow as pa
7
7
 
8
8
  from ..contract.collection import Collection
9
- from ..contract.contract import Contract
9
+ from ..contract.contract import CHILDREN_LEVEL, Contract
10
+ from ..contract.structure import Leaf
10
11
  from ..errors import CollectionError, ContainerError
11
12
  from . import engine, native
12
13
  from .collection import merge_collections
@@ -23,11 +24,31 @@ def _literal(value: str) -> str:
23
24
  return "'" + value.replace("'", "''") + "'"
24
25
 
25
26
 
27
+ # Rumi assets are read statelessly with their header, so a wide read carries it
28
+ # next to the location of every leaf whose level declares it.
29
+ _HEADER_FIELD = "rumi:header"
30
+
31
+
26
32
  def _output_name(declaration: str, *, variable: bool) -> str:
27
33
  name = declaration.partition("*")[0] if variable else declaration
28
34
  return name.replace("/", "__")
29
35
 
30
36
 
37
+ def _has_header(contract: Contract, leaf: Leaf) -> bool:
38
+ level = "/".join((CHILDREN_LEVEL, *leaf.folder))
39
+ return _HEADER_FIELD in contract.metadata.get(level, {})
40
+
41
+
42
+ def _wide_columns(contract: Contract, leaf: Leaf) -> list[tuple[str, str]]:
43
+ # Metadata fields contain exactly one ':', so the double separator cannot
44
+ # collide with user metadata.
45
+ name = _output_name(leaf.declaration, variable=leaf.variable)
46
+ columns = [("taco:location", f"{name}::location")]
47
+ if _has_header(contract, leaf):
48
+ columns.append((_HEADER_FIELD, f"{name}::header"))
49
+ return columns
50
+
51
+
31
52
  class Dataset:
32
53
  def __init__(self, source: Source) -> None:
33
54
  resolution = resolve_dataset(source)
@@ -96,24 +117,28 @@ class Dataset:
96
117
  file_columns: list[str] = []
97
118
  filters: list[str] = []
98
119
  for leaf in leaves:
99
- output = _identifier(_output_name(leaf.declaration, variable=leaf.variable))
100
120
  if leaf.variable:
101
121
  assert leaf.prefix is not None
102
122
  path_prefix = "/".join((*leaf.folder, leaf.prefix))
103
123
  pattern = "^" + re.escape(path_prefix) + r"(0|[1-9][0-9]*)" + re.escape(leaf.suffix) + "$"
104
124
  match = f"regexp_matches(f.path, {_literal(pattern)})"
105
125
  filters.append(f"regexp_matches(path, {_literal(pattern)})")
106
- aggregates.append(
107
- f'list(f."taco:location" ORDER BY '
108
- f"TRY_CAST(regexp_extract(f.path, {_literal(pattern)}, 1) AS BIGINT)) "
109
- f"FILTER (WHERE {match}) AS {output}"
110
- )
111
- file_columns.append(f"COALESCE(v.{output}, []::VARCHAR[]) AS {output}")
126
+ for source, name in _wide_columns(self.contract, leaf):
127
+ output = _identifier(name)
128
+ empty = "[]::BLOB[]" if source == _HEADER_FIELD else "[]::VARCHAR[]"
129
+ aggregates.append(
130
+ f"list(f.{_identifier(source)} ORDER BY "
131
+ f"TRY_CAST(regexp_extract(f.path, {_literal(pattern)}, 1) AS BIGINT)) "
132
+ f"FILTER (WHERE {match}) AS {output}"
133
+ )
134
+ file_columns.append(f"COALESCE(v.{output}, {empty}) AS {output}")
112
135
  else:
113
136
  path = _literal(leaf.declaration)
114
137
  filters.append(f"path = {path}")
115
- aggregates.append(f'MAX(f."taco:location") FILTER (WHERE f.path = {path}) AS {output}')
116
- file_columns.append(f"v.{output} AS {output}")
138
+ for source, name in _wide_columns(self.contract, leaf):
139
+ output = _identifier(name)
140
+ aggregates.append(f"MAX(f.{_identifier(source)}) FILTER (WHERE f.path = {path}) AS {output}")
141
+ file_columns.append(f"v.{output} AS {output}")
117
142
 
118
143
  selected_files = " OR ".join(filters)
119
144
  group = ", ".join(f"f.{_identifier(name)}" for name in keys)
@@ -131,7 +156,7 @@ class Dataset:
131
156
  wide_without_locations = native.sql(opened, idx=None, level=None, pivoted=True, files=None, location=False)
132
157
  flat = native.sql(opened, idx=None, level=None, pivoted=False, files=None, location=True)
133
158
 
134
- file_columns = [_output_name(leaf.declaration, variable=leaf.variable) for leaf in self.contract.leaves]
159
+ file_columns = [name for leaf in self.contract.leaves for _, name in _wide_columns(self.contract, leaf)]
135
160
  data = wide_without_locations
136
161
  if file_columns:
137
162
  excluded = ", ".join(_identifier(name) for name in file_columns)
@@ -123,7 +123,7 @@ def _check_collection(dataset: DatasetView, collector: _Collector) -> None:
123
123
  collection = dataset.collection
124
124
  if dataset.container != "tacocat" and collection.sources is not None:
125
125
  collector.error("sources", "taco:sources is only valid in TACOCAT")
126
- unknown = [task for task in collection.tasks if task not in KNOWN_TASKS]
126
+ unknown = [task for task in collection.tasks or () if task not in KNOWN_TASKS]
127
127
  if unknown:
128
128
  collector.warning("tasks", f"unrecognized task types {unknown}")
129
129
 
@@ -63,6 +63,13 @@ def test_dataset_version_must_be_semver(collection: taco.Collection, version: st
63
63
  collection.replace(dataset_version=version)
64
64
 
65
65
 
66
+ def test_tasks_are_optional(collection: taco.Collection) -> None:
67
+ untasked = collection.replace(tasks=None)
68
+ data = untasked.to_dict()
69
+ assert "tasks" not in data
70
+ assert taco.Collection.from_dict(json.loads(json.dumps(data))).tasks is None
71
+
72
+
66
73
  def test_reader_rejects_wrong_spec_version(collection: taco.Collection) -> None:
67
74
  data = collection.to_dict()
68
75
  data["taco:version"] = "2.0.0"