(path: str | None, cfg: WandbCfg)
| 42 | |
| 43 | |
| 44 | def update_checkpoint_path(path: str | None, cfg: WandbCfg) -> Path | None: |
| 45 | if path is None: |
| 46 | return None |
| 47 | |
| 48 | if not str(path).startswith("wandb://"): |
| 49 | return Path(path) |
| 50 | |
| 51 | run_id, *version = path[len("wandb://") :].split(":") |
| 52 | if len(version) == 0: |
| 53 | version = None |
| 54 | elif len(version) == 1: |
| 55 | version = version[0] |
| 56 | else: |
| 57 | raise ValueError("Invalid version specifier!") |
| 58 | |
| 59 | project = cfg.project |
| 60 | return download_checkpoint( |
| 61 | f"{project}/{run_id}", |
| 62 | Path("checkpoints"), |
| 63 | version, |
| 64 | ) |
no test coverage detected