Skip to content

Commit d81a6fa

Browse files
committed
Handle missing commit ids in plot factory
1 parent 11fa1cc commit d81a6fa

File tree

1 file changed

+22
-5
lines changed

1 file changed

+22
-5
lines changed

bughog/analysis/plot_factory.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
1+
import logging
2+
13
from bughog.database.mongo.mongodb import MongoDB
24
from bughog.evaluation.experiment_result import ExperimentResult
35
from bughog.parameters import EvaluationParameters
46
from bughog.subject import factory
57
from bughog.subject.state_oracle import StateOracle
68

9+
logger = logging.getLogger(__name__)
10+
711

812
class PlotFactory:
913
@staticmethod
@@ -47,12 +51,25 @@ def __add_outcome_info(docs: list, state_oracle: StateOracle|None):
4751
for doc in docs:
4852
result_variables = set((variables[0], variables[1]) for variables in doc['result']['variables'])
4953

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.')
5567
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
5673

5774
new_doc = {
5875
'commit_nb': commit_nb,

0 commit comments

Comments
 (0)