|
| 1 | +import logging |
| 2 | + |
1 | 3 | from bughog.database.mongo.mongodb import MongoDB |
2 | 4 | from bughog.evaluation.experiment_result import ExperimentResult |
3 | 5 | from bughog.parameters import EvaluationParameters |
4 | 6 | from bughog.subject import factory |
5 | 7 | from bughog.subject.state_oracle import StateOracle |
6 | 8 |
|
| 9 | +logger = logging.getLogger(__name__) |
| 10 | + |
7 | 11 |
|
8 | 12 | class PlotFactory: |
9 | 13 | @staticmethod |
@@ -47,12 +51,25 @@ def __add_outcome_info(docs: list, state_oracle: StateOracle|None): |
47 | 51 | for doc in docs: |
48 | 52 | result_variables = set((variables[0], variables[1]) for variables in doc['result']['variables']) |
49 | 53 |
|
50 | | - commit_nb = doc['state']['commit_nb'] |
51 | | - commit_id = doc['state']['commit_id'] |
52 | | - if state_oracle: |
53 | | - commit_url = state_oracle.get_commit_url(commit_nb, commit_id) |
54 | | - else: |
| 54 | + commit_nb = doc['state'].get('commit_nb') |
| 55 | + commit_id = doc['state'].get('commit_id') |
| 56 | + |
| 57 | + # TODO: for some reason commit ids sometimes seem to be absent from state docs. |
| 58 | + if commit_nb is None and commit_id is None: |
| 59 | + logger.error('Skipping state doc with unknown commit number and commit id.') |
| 60 | + continue |
| 61 | + elif commit_nb is None: |
| 62 | + # Commit number is essential for placing the datapoint on the Gantt chart. |
| 63 | + logger.error(f'Skipping state doc with unknown commit number (commit id: {commit_id}).') |
| 64 | + continue |
| 65 | + elif commit_id is None: |
| 66 | + logger.error(f'Including state doc with unknown commit id (commit number: {commit_nb}), without supplying commit url.') |
55 | 67 | commit_url = None |
| 68 | + else: |
| 69 | + if state_oracle: |
| 70 | + commit_url = state_oracle.get_commit_url(commit_nb, commit_id) |
| 71 | + else: |
| 72 | + commit_url = None |
56 | 73 |
|
57 | 74 | new_doc = { |
58 | 75 | 'commit_nb': commit_nb, |
|
0 commit comments