Ejemplo n.º 1
0
    def latest_run_dir(self) -> Optional[Path]:
        """Path to the log directory for the latest call to ``run()``.

        Returns ``None`` if ``run()`` has not been called.
        """
        if self._run_id > 0:
            run_dir = Path(f"run_{self._run_id:03d}")
            return construct_path(run_dir, self.logdir)
        else:
            return None
Ejemplo n.º 2
0
 def create_logdir(self, log_dir: Optional[Union[str, Path]]) -> Path:
     """Create logdir for the Trainer."""
     # Create directory for logs.
     log_dir = Path(log_dir) if log_dir else None
     if not log_dir:
         # Initialize timestamp for identifying this Train  execution.
         timestr = datetime.today().strftime("%Y-%m-%d_%H-%M-%S")
         log_dir = Path(f"train_{timestr}")
     log_dir = construct_path(log_dir, DEFAULT_RESULTS_DIR)
     log_dir.mkdir(parents=True, exist_ok=True)
     logger.info(f"Trainer logs will be logged in: {log_dir}")
     return log_dir
Ejemplo n.º 3
0
 def latest_checkpoint_dir(self) -> Optional[Path]:
     """Path to the latest checkpoint directory."""
     checkpoint_dir = Path(TRAIN_CHECKPOINT_SUBDIR)
     return construct_path(checkpoint_dir, self.run_dir)