Exemplo n.º 1
0
    def branch(self, branch):
        self._branch = branch

        if self._branch not in self.list_branches():
            self.create_branch(self._branch)

        self.branch_path = get_experiment_path(self.path, self._branch)
        self.index_path = get_experiment_run_path(self.path, self._branch,
                                                  self.active_commit)
        self.objects_dir_path = get_run_objects_dir_path(self.path,
                                                         self._branch,
                                                         self.active_commit)
        self.media_dir_path = os.path.join(self.objects_dir_path,
                                           AIM_MEDIA_DIR_NAME)

        self.meta_file_content = None
        self.meta_file_path = get_run_objects_meta_file_path(self.path,
                                                             self._branch,
                                                             self.active_commit)

        if not os.path.isdir(self.index_path):
            os.makedirs(self.index_path)

        if self.records_storage:
            self.records_storage.close()

        if os.path.exists(self.branch_path):
            self.records_storage = self.get_records_storage(
                self.objects_dir_path,
                self.mode)
Exemplo n.º 2
0
    def get_all_metrics(self) -> Dict[str, Metric]:
        if self._tmp_all_metrics is not None:
            return self._tmp_all_metrics

        meta_file_path = get_run_objects_meta_file_path(self.repo.path,
                                                        self.experiment_name,
                                                        self.run_hash)
        metrics = {}
        try:
            with open(meta_file_path, 'r+') as meta_file:
                artifacts = json.loads(meta_file.read().strip())
                # Filter only metrics
                for artifact in artifacts.values():
                    if artifact['type'] == 'metrics':
                        metric = Metric(self.repo,
                                        self,
                                        artifact['name'],
                                        artifact.get('context'))
                        metrics[artifact['name']] = metric
        except:
            pass

        self._tmp_all_metrics = metrics

        return metrics