Skip to content

Commit

Permalink
Merge pull request #548 from pangeo-forge/combine-fragments-debug-log…
Browse files Browse the repository at this point in the history
…ging

In combine_fragments, cast `fragments` to list if improperly decoded
  • Loading branch information
cisaacstern authored Jul 27, 2023
2 parents f0c7dac + 1b3f478 commit a22e6aa
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pangeo_forge_recipes/rechunking.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import functools
import itertools
import logging
import operator
from typing import Dict, Iterator, List, Tuple

Expand All @@ -10,6 +11,8 @@
from .chunk_grid import ChunkGrid
from .types import CombineOp, Dimension, Index, IndexedPosition, Optional

logger = logging.getLogger(__name__)

# group keys are a tuple of tuples like (("lon", 1), ("time", 0))
# the ints are chunk indexes
# code should aways sort the key before emitting it
Expand All @@ -28,6 +31,8 @@ def split_fragment(
:param target_chunks_and_dims: mapping from dimension name to a tuple of (chunksize, dimsize)
"""

logger.info(f"Splitting {fragment = }, with {target_chunks = } and {schema = }")

if target_chunks is None and schema is None:
raise ValueError("Must specify either target_chunks or schema (or both).")
if schema is not None:
Expand Down Expand Up @@ -156,6 +161,12 @@ def combine_fragments(
:param group: the group key; not actually used in combining
:param fragments: indexed dataset fragments
"""
if not isinstance(fragments, list):
# patch for https://github.com/pangeo-forge/pangeo-forge-recipes/issues/552
logger.info(f"Casting `fragments` from {type(fragments) = } to list")
fragments = list(fragments)

logger.info(f"Combining {group = }, containing {fragments = }")

# we are combining over all the concat dims found in the indexes
# first check indexes for consistency
Expand Down

0 comments on commit a22e6aa

Please sign in to comment.