Skip to content

Commit

Permalink
feat: update caching to check if file has already cached to reduce lo…
Browse files Browse the repository at this point in the history
…ading stress. (#354)
  • Loading branch information
MRVermeulenDeltares committed May 8, 2024
1 parent 7648b01 commit a06570c
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions hydrolib/core/basemodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -807,14 +807,13 @@ def __init__(
filepath = self._get_updated_file_path(filepath, loading_path)

logger.info(f"Loading data from {filepath}")

data = self._load(loading_path)
context.register_model(filepath, self)
data["filepath"] = filepath

if (data := context.retrieve_model(filepath)) is None:
data = self._load(loading_path)
context.register_model(filepath, self)
data["filepath"] = filepath
kwargs.update(data)

context.register_model(filepath, self)

# Note: the relative mode needs to be obtained from the data directly
# because self._relative_mode has not been resolved yet (this is done as
# part of the __init__), however during the __init__ we need to already
Expand Down

0 comments on commit a06570c

Please sign in to comment.