|
8 | 8 | import sys
|
9 | 9 | import uuid
|
10 | 10 | from collections.abc import Callable
|
| 11 | +from functools import cache |
11 | 12 | from importlib.resources import open_text
|
12 | 13 | from pathlib import Path
|
13 | 14 | from string import Template
|
|
18 | 19 | from returns.maybe import Maybe
|
19 | 20 | from rich.prompt import Confirm, Prompt
|
20 | 21 |
|
21 |
| -from nsidc.metgen import aws, config, constants, netcdf_reader |
| 22 | +from nsidc.metgen import aws, config, constants |
22 | 23 |
|
23 | 24 | # -------------------------------------------------------------------
|
24 | 25 | CONSOLE_FORMAT = "%(message)s"
|
@@ -186,7 +187,6 @@ class Collection:
|
186 | 187 |
|
187 | 188 | auth_id: str
|
188 | 189 | version: int
|
189 |
| - data_reader: Callable[[str], dict] |
190 | 190 |
|
191 | 191 |
|
192 | 192 | @dataclasses.dataclass
|
@@ -231,15 +231,7 @@ def process(configuration: config.Config) -> None:
|
231 | 231 | """
|
232 | 232 | Process all Granules and record the results and summary.
|
233 | 233 | """
|
234 |
| - # TODO: |
235 |
| - # Do any prep actions, like mkdir, etc |
236 |
| - # Get real collection information from CMR |
237 |
| - # Determine data reader based on actual data file characteristics (e.g. suffix) |
238 |
| - configuration.collection = Collection( |
239 |
| - configuration.auth_id, |
240 |
| - configuration.version, |
241 |
| - netcdf_reader.extract_metadata |
242 |
| - ) |
| 234 | + # TODO: Do any prep actions, like mkdir, etc |
243 | 235 |
|
244 | 236 | # Ordered list of operations to perform on each granule
|
245 | 237 | operations = [
|
@@ -343,12 +335,21 @@ def null_operation(configuration: config.Config, granule: Granule) -> Granule:
|
343 | 335 | return granule
|
344 | 336 |
|
345 | 337 |
|
| 338 | +@cache |
| 339 | +def retrieve_collection(auth_id: str, version: int): |
| 340 | + # ummc_from_cmr = talk_to_cmr(configuration.auth_id, configuration.version) |
| 341 | + # pull out fields from UMM-C response and use to create collection object |
| 342 | + # with more than just auth_id and version number. |
| 343 | + return Collection(auth_id, version) |
| 344 | + |
| 345 | + |
346 | 346 | def granule_collection(configuration: config.Config, granule: Granule) -> Granule:
|
347 | 347 | """
|
348 |
| - Associate the Collection with the Granule. |
| 348 | + Associate collection information with the Granule. |
349 | 349 | """
|
350 | 350 | return dataclasses.replace(
|
351 |
| - granule, collection=configuration.collection |
| 351 | + granule, |
| 352 | + collection=retrieve_collection(configuration.auth_id, configuration.version), |
352 | 353 | )
|
353 | 354 |
|
354 | 355 |
|
@@ -399,7 +400,7 @@ def create_ummg(configuration: config.Config, granule: Granule) -> Granule:
|
399 | 400 | # }
|
400 | 401 | metadata_details = {}
|
401 | 402 | for data_file in granule.data_filenames:
|
402 |
| - metadata_details[data_file] = granule.collection.data_reader(data_file) |
| 403 | + metadata_details[data_file] = configuration.data_reader(data_file) |
403 | 404 |
|
404 | 405 | # Collapse information about (possibly) multiple files into a granule summary.
|
405 | 406 | summary = metadata_summary(metadata_details)
|
|
0 commit comments