diff --git a/viz_scripts/survey_metrics.ipynb b/viz_scripts/survey_metrics.ipynb index 19bc0e0..60886ca 100644 --- a/viz_scripts/survey_metrics.ipynb +++ b/viz_scripts/survey_metrics.ipynb @@ -72,7 +72,7 @@ "outputs": [], "source": [ "# Do not run this notebook at all unless it is for a survey configuration; nbclient will run up through this cell\n", - "if not survey_info['trip-labels'] == 'ENKETO':\n", + "if not survey_info.get('trip-labels', None) == 'ENKETO':\n", " ipython = get_ipython()\n", " ipython._showtraceback = scaffolding.no_traceback_handler\n", " raise Exception(\"The plots in this notebook are only relevant to deployments with trip-level surveys\")" diff --git a/viz_scripts/survey_responses.ipynb b/viz_scripts/survey_responses.ipynb index 08f205b..28d7c3f 100644 --- a/viz_scripts/survey_responses.ipynb +++ b/viz_scripts/survey_responses.ipynb @@ -53,7 +53,7 @@ "outputs": [], "source": [ "# Do not run this notebook at all unless it is for a survey configuration; nbclient will run up through this cell\n", - "if not survey_info['trip-labels'] == 'ENKETO':\n", + "if not survey_info.get('trip-labels', None) == 'ENKETO':\n", " ipython = get_ipython()\n", " ipython._showtraceback = scaffolding.no_traceback_handler\n", " raise Exception(\"The plots in this notebook are only relevant to deployments with trip-level surveys\")" @@ -372,10 +372,14 @@ " \n", " plot_and_text_stacked_bar_chart(plot_df, \"Responses\", ax, text_results, get_survey_colors(list(plot_df.index.values) ,color_map), debug_df)\n", " set_title_and_save(fig, text_results, plot_title, filename)\n", - "\n", - " except:\n", + " except (AttributeError, KeyError, pd.errors.UndefinedVariableError) as e:\n", + " plt.clf()\n", " generate_missing_plot(plot_title_no_quality, debug_df, filename)\n", - " alt_text = store_alt_text_missing(debug_df, filename, plot_title_no_quality)" + " alt_text = store_alt_text_missing(debug_df, filename, plot_title_no_quality) \n", + " alt_html = store_alt_html_missing(debug_df, filename, plot_title_no_quality)\n", + " except Exception as e:\n", + " fig, ax = plt.subplots()\n", + " plot_and_text_error(e, ax, filename)" ] } ],