diff --git a/cadetrdm/batch_runner.py b/cadetrdm/batch_runner.py index f0e46006015b6e28219517cc673d5220d8f3d02b..4485397fd528b2f58b7f880453279704ee54f72b 100644 --- a/cadetrdm/batch_runner.py +++ b/cadetrdm/batch_runner.py @@ -30,6 +30,7 @@ class Case: self.name = name self.study = study self.options = options + self._results_branch = None @property def status_file(self): @@ -87,13 +88,26 @@ class Case: @property def has_results_for_this_run(self): + if self.results_branch == "not found": + return False + else: + return True + + @property + def results_branch(self): + if self._results_branch is None: + self._results_branch = self._get_results_branch() + + return self._results_branch + + def _get_results_branch(self): output_log = self.study.output_log for log_entry in output_log: if (self.study.current_commit_hash == log_entry.project_repo_commit_hash and self.options.hash == log_entry.options_hash): - return True + return log_entry.output_repo_branch - return False + return "not found" def run_study(self, force=False): """Run specified study commands in the given repository.""" @@ -128,3 +142,23 @@ class Case: print(f"Command execution failed: {e}") self.status = 'failed' return + + @property + def _results_path(self): + return self.study.path / (self.study._output_folder + "_cached") / self.results_branch + + def load(self, ): + if self.results_branch is None: + print(f"No results available for Case({self.study.path, self.options.hash[:7]})") + return None + + if self._results_path.exists(): + return + + self.study.copy_data_to_cache(self.results_branch) + + @property + def results_path(self): + self.load() + + return self._results_branch