Added try..finally block for the clean-up of .pkl compiled stan models
@@ -323,6 +323,7 @@ class Experiment(ExperimentData):
Returns:
a Results object
"""
+ try:
for mname in kpis_to_analyse:
metric_df = self._get_metric_df(mname, reference_kpis, weighted_kpis)
@@ -349,8 +350,8 @@ class Experiment(ExperimentData):
result.df = df
else:
result.df = result.df.append(df)
-
- # Remove .pkl compiled stan model files
+ finally:
+ # Remove .pkl compiled stan model files in the finally no matter script in try was successful or not
if remove_pkls:
remove_model_pkls()
@@ -383,6 +384,7 @@ class Experiment(ExperimentData):
Returns:
a Results object
"""
+ try:
for mname in kpis_to_analyse:
metric_df = self._get_metric_df(mname, reference_kpis, weighted_kpis)
@@ -410,8 +412,8 @@ class Experiment(ExperimentData):
result.df = df
else:
result.df = result.df.append(df)
-
- # Remove .pkl compiled stan model files
+ finally:
+ # Remove .pkl compiled stan model files in the finally no matter script in try was successful or not
if remove_pkls:
remove_model_pkls()
