Exemple #1
0
def extract_zip(file_path: Path, overwrite: bool = False):
    source = Path(lab.get_data_path() / 'source')

    with monit.section(f"Extract {file_path.stem}"):
        repo_source = source / file_path.stem
        if repo_source.exists():
            if overwrite:
                rm_tree(repo_source)
            else:
                return repo_source
        try:
            with zipfile.ZipFile(file_path, 'r') as repo_zip:
                repo_zip.extractall(repo_source)
        except zipfile.BadZipfile as e:
            print(file_path, e)

        return repo_source
Exemple #2
0
def clear_checkpoints(run_path: Path):
    checkpoints = list(get_checkpoints(run_path))
    if not checkpoints:
        return

    checkpoint_steps = sorted([int(c.name) for c in checkpoints])

    if len(checkpoint_steps) <= 2:
        return

    checkpoint_steps = checkpoint_steps[:-2]
    checkpoints_path = run_path / "checkpoints"
    from labml.internal.util import rm_tree

    for c in checkpoint_steps:
        path = checkpoints_path / str(c)
        rm_tree(path)
Exemple #3
0
    def _create_symlink_folder(self):
        if self.symlink_path.exists():
            rm_tree(self.symlink_path)

        self.symlink_path.mkdir(parents=True)
Exemple #4
0
def remove_run(run_path: Path):
    from labml.internal.util import rm_tree
    rm_tree(run_path)