| 496 | |
| 497 | |
| 498 | def setup_dirs(args: APNamespace) -> Tuple[Path, Path, Path, Path, Path | None]: |
| 499 | root_path = Path(args.root).expanduser() |
| 500 | config_path = root_path / Path(args.config).expanduser() |
| 501 | data_path = root_path / Path(args.data).expanduser() |
| 502 | output_path = root_path / Path(args.output).expanduser() |
| 503 | checkpoint_path = root_path / Path(args.checkpoint).expanduser() |
| 504 | if not config_path.exists(): |
| 505 | raise ValueError(f"Info: Config path {config_path} does not exist") |
| 506 | if not data_path.exists(): |
| 507 | print(f"Info: Data dir {data_path} does not exist, building") |
| 508 | data_path.mkdir(exist_ok=True, parents=True) |
| 509 | if not output_path.exists(): |
| 510 | print(f"Info: Output dir {output_path} does not exist, building") |
| 511 | output_path.mkdir(exist_ok=True, parents=True) |
| 512 | if not checkpoint_path.exists(): |
| 513 | checkpoint_path.mkdir(exist_ok=True, parents=True) |
| 514 | if args.resume is not None: |
| 515 | if not Path(args.resume).exists(): |
| 516 | raise ValueError("Resume path does not exist") |
| 517 | return config_path, output_path, data_path, checkpoint_path, Path(args.resume) if args.resume is not None else None |
| 518 | |
| 519 | |
| 520 | def main(args: APNamespace): |