Skip to content

Commit

Permalink
Handle function when computing cache keys
Browse files Browse the repository at this point in the history
  • Loading branch information
khaeru committed Dec 3, 2024
1 parent c518740 commit f9e8d71
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion message_ix_models/util/cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import logging
from collections.abc import Callable
from dataclasses import asdict, is_dataclass
from typing import TYPE_CHECKING
from types import FunctionType
from typing import TYPE_CHECKING, Union

import genno.caching
import ixmp
Expand Down Expand Up @@ -60,6 +61,11 @@ def _dataclass(o: object):
)


@genno.caching.Encoder.register
def _repr_only(o: Union[FunctionType]):
return repr(o)


@genno.caching.Encoder.register
def _si(o: ScenarioInfo):
return dict(o.set)
Expand Down

0 comments on commit f9e8d71

Please sign in to comment.