Esempio n. 1
0
 def __init__(self, fs: FSBase):
     self._fs = fs
     try:
         self._iterations: List[str] = json.loads(
             fs.readtext(_CHECKPOINT_STATE_FILE))
     except Exception:
         self._iterations = []
Esempio n. 2
0
def read_subdir_versions_from_directory(fs: FS, dir: str) -> Dict[str, str]:
    """
    Given the path to a directory, return the subdir-version
    dictionary that lives in it.
    """
    SUBDIR_VERSIONS_FILEPATH = join(dir, SUBDIR_VERSIONS_FILENAME)
    try:
        return parse_subdir_versions(
            fs.readtext(SUBDIR_VERSIONS_FILEPATH, encoding="ascii"))
    except ResourceNotFound:
        return dict()
Esempio n. 3
0
    def parse_dependencies(module_name: str,
                           directory: FS) -> Dict[str, List[str]]:
        """
        Retrieve external dependencies from a module's manifest.
        :param module_name: Name of the module
        :param directory: Location of the module
        :return: A dictionary containing a list of dependencies for each type
        """
        manifest = directory.readtext(join(module_name, "__manifest__.py"))
        manifest_dict = ast.literal_eval(manifest)

        return manifest_dict.get("external_dependencies", {})
Esempio n. 4
0
    def get_module_version(module_name: str, directory: FS) -> str:
        """
        Get the version of the module in the given directory
        :param module_name: name of the module
        :param directory: FS object pointing to the parent directory of the module
        :return: version of the module or None if it is not present in the directory
        """
        version = None
        if module_name in directory.listdir("."):
            manifest = directory.readtext(join(module_name, "__manifest__.py"))
            version = ast.literal_eval(manifest)["version"]

        return version
Esempio n. 5
0
 def load_checkpoint(self, fs: FSBase) -> None:
     self.spec.load_checkpoint(fs, self.model)
     self._epochs = int(fs.readtext("epoch"))
 def load_checkpoint(self, fs: FSBase) -> None:
     self.v = int(fs.readtext("x"))