예제 #1
0
 def version_tuple(self) -> Tuple[int, int, int]:
     """
     Return a tuple of the version string.
     """
     validate_version_str(self.version)
     vsplit = self.version.split(".")
     return int(vsplit[0]), int(vsplit[1]), int(vsplit[2])
예제 #2
0
    def read_data_version(self,
                          path: Optional[Union[Path, str]] = None) -> str:
        """
        Read the data version from disk.

        Return a 3 length tuple from the semantic version string (of the
        form xx.yy.zz). Raise a DataVersionError if not found.
        """
        version_path = path or self._version_path
        if not version_path.exists():
            raise DataVersionError(f"{version_path} does not exist!")
        with version_path.open("r") as fi:
            version_str = fi.read()
        validate_version_str(version_str)
        return version_str
예제 #3
0
 def __init_subclass__(cls, **kwargs):
     """Register subclasses of datasets."""
     assert isinstance(cls.name, str), "name must be a string"
     validate_version_str(cls.version)
     # Register the subclass as a dataset.
     DataSet._datasets[cls.name.lower()] = cls