Skip to content

Commit

Permalink
Added exception handling
Browse files Browse the repository at this point in the history
  • Loading branch information
SasCezar committed Dec 20, 2023
1 parent e8d1692 commit 7052aca
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/pipeline/project_annotation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import traceback
from typing import Tuple

import numpy as np
from loguru import logger

from entity.project import Project, Version
from pipeline.pipeline import PipelineBase
Expand All @@ -17,7 +19,12 @@ def run(self, project: Project, version: Version) -> Tuple[Project, Version]:
if file.annotation.unannotated:
continue
project_dist.append(file.annotation.distribution)

project.project_annotation[version.commit_id] = list(np.mean(project_dist, axis=0))
try:
project_dist = np.array(project_dist)
project.project_annotation[version.commit_id] = list(np.mean(project_dist, axis=0))
except Exception as e:
project.project_annotation[version.commit_id] = [0.0] * len(project.taxonomy)
logger.error(f"Error annotating project {project.name} @ {version.commit_id}")
traceback.print_exc()

return project, version

0 comments on commit 7052aca

Please sign in to comment.