Source code for hydro.migration

"""Functions that hopefully can migrate from a past version of data to a future version."""

from abc import ABC, abstractmethod

import xarray as xr


[docs] class MigrationABC(ABC):
[docs] version_from = "1.0.0.0"
[docs] def can_migrate(self, ds: xr.Dataset) -> bool: return self.version_from in ds.attrs.get("software_version", "")
@abstractmethod
[docs] def migrate(self, ds: xr.Dataset) -> xr.Dataset: return ds