Skip to content

Commit

Permalink
make deepdiff optional
Browse files Browse the repository at this point in the history
  • Loading branch information
dlwh committed Oct 4, 2024
1 parent b41838f commit e575fce
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/levanter/store/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
from dataclasses import dataclass
from typing import Any, Callable, Dict, Iterator, List, Optional, Sequence, TypeVar, Union

import deepdiff
# import deepdiff
import fsspec.core
import pyarrow as pa
import ray
Expand Down Expand Up @@ -508,7 +508,7 @@ class CacheMetadata:
options: CacheOptions = CacheOptions.default()
preprocessor_metadata: Optional[dict[str, Any]] = None

def compare_to(self, other: "CacheMetadata") -> deepdiff.DeepDiff:
def compare_to(self, other: "CacheMetadata"):
"""
Compare this metadata to another set of metadata. This is used to check if the cache being loaded
was created with the expected configuration.
Expand All @@ -519,7 +519,15 @@ def compare_to(self, other: "CacheMetadata") -> deepdiff.DeepDiff:
sorta_self = dataclasses.replace(self, preprocessor_metadata=None)
else:
sorta_self = self
return deepdiff.DeepDiff(sorta_self, other)
try:
import deepdiff

return deepdiff.DeepDiff(sorta_self, other)
except Exception as e:
if "deepdiff" in str(e):
if sorta_self != other:
return {"message": "Metadata mismatch"}
return {}

@staticmethod
def empty():
Expand Down

0 comments on commit e575fce

Please sign in to comment.