|
34 | 34 | from datetime import datetime |
35 | 35 | from typing import Optional, Union |
36 | 36 |
|
| 37 | +from satpy.node import MissingDependencies |
| 38 | + |
37 | 39 | # isort: off |
38 | 40 | # hdf5plugin must be imported before h5py and xarray or it won't be available |
39 | 41 | # Used by the FCI reader |
@@ -368,7 +370,11 @@ def _run_processing(self): |
368 | 370 | persist_geolocation = not arg_parser._reader_args.pop("no_persist_geolocation", False) |
369 | 371 | if not products: |
370 | 372 | return -1 |
371 | | - scn.load(products, **load_args, generate=False) |
| 373 | + try: |
| 374 | + scn.load(products, **load_args, generate=False) |
| 375 | + except KeyError as dep_key_error: |
| 376 | + _handle_missing_deps_keyerror(dep_key_error) |
| 377 | + return -1 |
372 | 378 | if persist_geolocation: |
373 | 379 | scn = _persist_swath_definition_in_scene(scn) |
374 | 380 | scn.generate_possible_composites(True) |
@@ -476,6 +482,25 @@ def _set_preferred_chunk_size(preferred_chunk_size: int) -> Iterator[None]: |
476 | 482 | yield |
477 | 483 |
|
478 | 484 |
|
| 485 | +def _handle_missing_deps_keyerror(dep_key_error: KeyError) -> None: |
| 486 | + miss_dep_exc = getattr(dep_key_error, "__context__", None) |
| 487 | + if not isinstance(miss_dep_exc, MissingDependencies): |
| 488 | + raise |
| 489 | + flat_queries = sorted(set(data_query for dep_set in miss_dep_exc.missing_dependencies for data_query in dep_set)) |
| 490 | + flat_queries_dicts = [dq.to_dict() for dq in flat_queries] |
| 491 | + plural_s = "s" if len(flat_queries_dicts) > 1 else "" |
| 492 | + LOG.error( |
| 493 | + "Unknown product{} requested:\n\t{}".format( |
| 494 | + plural_s, |
| 495 | + "\n\t".join( |
| 496 | + (dq_dict["name"] if len(dq_dict) == 1 and "name" in dq_dict else repr(dq_dict)) |
| 497 | + for dq_dict in flat_queries_dicts |
| 498 | + ), |
| 499 | + ) |
| 500 | + ) |
| 501 | + LOG.debug("Unknown product requested", exc_info=True) |
| 502 | + |
| 503 | + |
479 | 504 | def _persist_swath_definition_in_scene(scn: Scene) -> None: |
480 | 505 | to_persist_swath_defs = _swaths_to_persist(scn) |
481 | 506 | if not to_persist_swath_defs: |
|
0 commit comments