From 75e34f59870813c24598ed7e95c56803c7cd5907 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rok=20Ro=C5=A1kar?= <rok.roskar@sdsc.ethz.ch> Date: Mon, 30 Mar 2020 15:47:04 +0000 Subject: [PATCH] renku run papermill notebooks/examples/italy-covid-19.ipynb runs/italy-covid-19.ipynb -p data_folder ./data/covid-19-italy/ --- ...55fbcb87444ea80501341f0b7f1a_papermill.cwl | 67 ++++ runs/italy-covid-19.ipynb | 302 +++++++++++------- 2 files changed, 261 insertions(+), 108 deletions(-) create mode 100644 .renku/workflow/f2c255fbcb87444ea80501341f0b7f1a_papermill.cwl diff --git a/.renku/workflow/f2c255fbcb87444ea80501341f0b7f1a_papermill.cwl b/.renku/workflow/f2c255fbcb87444ea80501341f0b7f1a_papermill.cwl new file mode 100644 index 0000000..a0f3059 --- /dev/null +++ b/.renku/workflow/f2c255fbcb87444ea80501341f0b7f1a_papermill.cwl @@ -0,0 +1,67 @@ +arguments: [] +baseCommand: +- papermill +class: CommandLineTool +cwlVersion: v1.0 +hints: [] +inputs: + input_1: + default: + class: File + path: ../../notebooks/examples/italy-covid-19.ipynb + inputBinding: + position: 1 + separate: true + shellQuote: true + streamable: false + type: File + input_2: + default: runs/italy-covid-19.ipynb + inputBinding: + position: 2 + separate: true + shellQuote: true + streamable: false + type: string + input_3: + default: data_folder + inputBinding: + position: 3 + prefix: -p + separate: true + shellQuote: true + streamable: false + type: string + input_4: + default: + class: Directory + listing: [] + path: ../../data/covid-19-italy + inputBinding: + position: 4 + separate: true + shellQuote: true + streamable: false + type: Directory +outputs: + output_0: + outputBinding: + glob: $(inputs.input_2) + streamable: false + type: File +permanentFailCodes: [] +requirements: +- class: InlineJavascriptRequirement +- class: InitialWorkDirRequirement + listing: + - entry: '$({"listing": [], "class": "Directory"})' + entryname: runs + writable: true + - entry: $(inputs.input_1) + entryname: notebooks/examples/italy-covid-19.ipynb + writable: false + - entry: $(inputs.input_4) + entryname: data/covid-19-italy + writable: false +successCodes: [] +temporaryFailCodes: [] diff --git a/runs/italy-covid-19.ipynb b/runs/italy-covid-19.ipynb index 156f53c..073621f 100644 --- a/runs/italy-covid-19.ipynb +++ b/runs/italy-covid-19.ipynb @@ -4,10 +4,10 @@ "cell_type": "markdown", "metadata": { "papermill": { - "duration": 0.016838, - "end_time": "2020-03-30T15:01:07.532187", + "duration": 0.017573, + "end_time": "2020-03-30T15:47:00.902430", "exception": false, - "start_time": "2020-03-30T15:01:07.515349", + "start_time": "2020-03-30T15:47:00.884857", "status": "completed" }, "tags": [] @@ -23,10 +23,10 @@ "execution_count": 1, "metadata": { "papermill": { - "duration": 0.029402, - "end_time": "2020-03-30T15:01:07.571765", + "duration": 0.042314, + "end_time": "2020-03-30T15:47:00.956999", "exception": false, - "start_time": "2020-03-30T15:01:07.542363", + "start_time": "2020-03-30T15:47:00.914685", "status": "completed" }, "tags": [] @@ -42,10 +42,10 @@ "execution_count": 2, "metadata": { "papermill": { - "duration": 0.590434, - "end_time": "2020-03-30T15:01:08.171053", + "duration": 0.574034, + "end_time": "2020-03-30T15:47:01.544605", "exception": false, - "start_time": "2020-03-30T15:01:07.580619", + "start_time": "2020-03-30T15:47:00.970571", "status": "completed" }, "tags": [] @@ -57,6 +57,8 @@ "import pandas as pd\n", "import altair as alt\n", "\n", + "from IPython.display import display, HTML\n", + "\n", "from covid_19_dashboard.italy_utils import get_region_populations, prepare_dataframe" ] }, @@ -65,10 +67,34 @@ "execution_count": 3, "metadata": { "papermill": { - "duration": 0.029052, - "end_time": "2020-03-30T15:01:08.208621", + "duration": 0.038937, + "end_time": "2020-03-30T15:47:01.597549", + "exception": false, + "start_time": "2020-03-30T15:47:01.558612", + "status": "completed" + }, + "tags": [] + }, + "outputs": [], + "source": [ + "html_credits=HTML('''\n", + "<p style=\"font-size: smaller\">Data Sources: \n", + " <a href=\"https://github.com/pcm-dpc/COVID-19\">Italian Civil Protection</a>, <a href=\"https://wikidata.org\">Wikidata</a>\n", + "<br>\n", + "Analysis and Visualization:\n", + " <a href=\"https://renkulab.io/projects/covid-19/covid-19-public-data\">Covid-19 Public Data Collaboration Project</a>\n", + "</p>''')" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": { + "papermill": { + "duration": 0.033582, + "end_time": "2020-03-30T15:47:01.645232", "exception": false, - "start_time": "2020-03-30T15:01:08.179569", + "start_time": "2020-03-30T15:47:01.611650", "status": "completed" }, "tags": [ @@ -82,13 +108,13 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": { "papermill": { - "duration": 0.027658, - "end_time": "2020-03-30T15:01:08.244634", + "duration": 0.041421, + "end_time": "2020-03-30T15:47:01.700886", "exception": false, - "start_time": "2020-03-30T15:01:08.216976", + "start_time": "2020-03-30T15:47:01.659465", "status": "completed" }, "tags": [ @@ -103,13 +129,13 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": { "papermill": { - "duration": 0.036949, - "end_time": "2020-03-30T15:01:08.290501", + "duration": 0.045634, + "end_time": "2020-03-30T15:47:01.762893", "exception": false, - "start_time": "2020-03-30T15:01:08.253552", + "start_time": "2020-03-30T15:47:01.717259", "status": "completed" }, "tags": [] @@ -126,13 +152,13 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": { "papermill": { - "duration": 0.037513, - "end_time": "2020-03-30T15:01:08.336655", + "duration": 0.039386, + "end_time": "2020-03-30T15:47:01.817068", "exception": false, - "start_time": "2020-03-30T15:01:08.299142", + "start_time": "2020-03-30T15:47:01.777682", "status": "completed" }, "tags": [] @@ -148,10 +174,10 @@ "cell_type": "markdown", "metadata": { "papermill": { - "duration": 0.007906, - "end_time": "2020-03-30T15:01:08.353544", + "duration": 0.010648, + "end_time": "2020-03-30T15:47:01.842058", "exception": false, - "start_time": "2020-03-30T15:01:08.345638", + "start_time": "2020-03-30T15:47:01.831410", "status": "completed" }, "tags": [] @@ -162,13 +188,13 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": { "papermill": { - "duration": 0.064453, - "end_time": "2020-03-30T15:01:08.426377", + "duration": 0.094679, + "end_time": "2020-03-30T15:47:01.946901", "exception": false, - "start_time": "2020-03-30T15:01:08.361924", + "start_time": "2020-03-30T15:47:01.852222", "status": "completed" }, "tags": [] @@ -178,10 +204,10 @@ "data": { "text/html": [ "\n", - "<div id=\"altair-viz-99e5f6cb77784a22802456bb0a1c20b3\"></div>\n", + "<div id=\"altair-viz-218b5174c39541b7aface1108ea9c035\"></div>\n", "<script type=\"text/javascript\">\n", " (function(spec, embedOpt){\n", - " const outputDiv = document.getElementById(\"altair-viz-99e5f6cb77784a22802456bb0a1c20b3\");\n", + " const outputDiv = document.getElementById(\"altair-viz-218b5174c39541b7aface1108ea9c035\");\n", " const paths = {\n", " \"vega\": \"https://cdn.jsdelivr.net/npm//vega@5?noext\",\n", " \"vega-lib\": \"https://cdn.jsdelivr.net/npm//vega-lib?noext\",\n", @@ -229,9 +255,26 @@ "alt.HConcatChart(...)" ] }, - "execution_count": 7, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "\n", + "<p style=\"font-size: smaller\">Data Sources: \n", + " <a href=\"https://github.com/pcm-dpc/COVID-19\">Italian Civil Protection</a>, <a href=\"https://wikidata.org\">Wikidata</a>\n", + "<br>\n", + "Analysis and Visualization:\n", + " <a href=\"https://renkulab.io/projects/covid-19/covid-19-public-data\">Covid-19 Public Data Collaboration Project</a>\n", + "</p>" + ], + "text/plain": [ + "<IPython.core.display.HTML object>" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -241,22 +284,24 @@ "total = base.mark_point(color='orange', filled=True, size=100, opacity=1).encode(alt.Y('total_cases', title=\"Cases (orange)\"))\n", "tests = base.encode(alt.Y('tests', title=\"Tests (blue)\"))\n", "totals = alt.layer(tests, total)\n", - "alt.hconcat(totals, daily, \n", + "chart = alt.hconcat(totals, daily, \n", " title='Total and daily tests and cases nationwide'\n", ").configure_title(\n", " anchor='middle'\n", - ")" + ")\n", + "display(chart)\n", + "display(html_credits)" ] }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": { "papermill": { - "duration": 0.050324, - "end_time": "2020-03-30T15:01:08.485994", + "duration": 0.066053, + "end_time": "2020-03-30T15:47:02.028176", "exception": false, - "start_time": "2020-03-30T15:01:08.435670", + "start_time": "2020-03-30T15:47:01.962123", "status": "completed" }, "tags": [] @@ -284,13 +329,13 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": { "papermill": { - "duration": 0.355166, - "end_time": "2020-03-30T15:01:08.850692", + "duration": 0.61369, + "end_time": "2020-03-30T15:47:02.660735", "exception": false, - "start_time": "2020-03-30T15:01:08.495526", + "start_time": "2020-03-30T15:47:02.047045", "status": "completed" }, "tags": [] @@ -309,13 +354,13 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": { "papermill": { - "duration": 0.039941, - "end_time": "2020-03-30T15:01:08.900658", + "duration": 0.054045, + "end_time": "2020-03-30T15:47:02.733032", "exception": false, - "start_time": "2020-03-30T15:01:08.860717", + "start_time": "2020-03-30T15:47:02.678987", "status": "completed" }, "tags": [] @@ -331,10 +376,10 @@ "cell_type": "markdown", "metadata": { "papermill": { - "duration": 0.008303, - "end_time": "2020-03-30T15:01:08.917821", + "duration": 0.012923, + "end_time": "2020-03-30T15:47:02.761696", "exception": false, - "start_time": "2020-03-30T15:01:08.909518", + "start_time": "2020-03-30T15:47:02.748773", "status": "completed" }, "tags": [] @@ -345,13 +390,13 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": { "papermill": { - "duration": 0.104273, - "end_time": "2020-03-30T15:01:09.031061", + "duration": 0.166371, + "end_time": "2020-03-30T15:47:02.940836", "exception": false, - "start_time": "2020-03-30T15:01:08.926788", + "start_time": "2020-03-30T15:47:02.774465", "status": "completed" }, "tags": [] @@ -361,10 +406,10 @@ "data": { "text/html": [ "\n", - "<div id=\"altair-viz-4d8b655768c74270a1f4685519d07a3c\"></div>\n", + "<div id=\"altair-viz-90ec7a0498ed43cbaf44277379a07bad\"></div>\n", "<script type=\"text/javascript\">\n", " (function(spec, embedOpt){\n", - " const outputDiv = document.getElementById(\"altair-viz-4d8b655768c74270a1f4685519d07a3c\");\n", + " const outputDiv = document.getElementById(\"altair-viz-90ec7a0498ed43cbaf44277379a07bad\");\n", " const paths = {\n", " \"vega\": \"https://cdn.jsdelivr.net/npm//vega@5?noext\",\n", " \"vega-lib\": \"https://cdn.jsdelivr.net/npm//vega-lib?noext\",\n", @@ -412,9 +457,26 @@ "alt.FacetChart(...)" ] }, - "execution_count": 11, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "\n", + "<p style=\"font-size: smaller\">Data Sources: \n", + " <a href=\"https://github.com/pcm-dpc/COVID-19\">Italian Civil Protection</a>, <a href=\"https://wikidata.org\">Wikidata</a>\n", + "<br>\n", + "Analysis and Visualization:\n", + " <a href=\"https://renkulab.io/projects/covid-19/covid-19-public-data\">Covid-19 Public Data Collaboration Project</a>\n", + "</p>" + ], + "text/plain": [ + "<IPython.core.display.HTML object>" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -426,24 +488,26 @@ " width=200,\n", " height=200)\n", "totals = alt.layer(total, death)\n", - "totals.facet(facet='region', \n", + "chart = totals.facet(facet='region', \n", " columns=5, \n", " align='each', \n", " title='Total cases (orange) and deaths (black) by region'\n", ").configure_title(\n", " anchor='middle'\n", - ")" + ")\n", + "display(chart)\n", + "display(html_credits)" ] }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": { "papermill": { - "duration": 0.105389, - "end_time": "2020-03-30T15:01:09.149647", + "duration": 0.155288, + "end_time": "2020-03-30T15:47:03.118439", "exception": false, - "start_time": "2020-03-30T15:01:09.044258", + "start_time": "2020-03-30T15:47:02.963151", "status": "completed" }, "tags": [] @@ -453,10 +517,10 @@ "data": { "text/html": [ "\n", - "<div id=\"altair-viz-12b38561ee274de39a98b8477bffbccb\"></div>\n", + "<div id=\"altair-viz-83b23d0ce38f495c8c89111b787f2cb1\"></div>\n", "<script type=\"text/javascript\">\n", " (function(spec, embedOpt){\n", - " const outputDiv = document.getElementById(\"altair-viz-12b38561ee274de39a98b8477bffbccb\");\n", + " const outputDiv = document.getElementById(\"altair-viz-83b23d0ce38f495c8c89111b787f2cb1\");\n", " const paths = {\n", " \"vega\": \"https://cdn.jsdelivr.net/npm//vega@5?noext\",\n", " \"vega-lib\": \"https://cdn.jsdelivr.net/npm//vega-lib?noext\",\n", @@ -504,9 +568,26 @@ "alt.FacetChart(...)" ] }, - "execution_count": 12, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "\n", + "<p style=\"font-size: smaller\">Data Sources: \n", + " <a href=\"https://github.com/pcm-dpc/COVID-19\">Italian Civil Protection</a>, <a href=\"https://wikidata.org\">Wikidata</a>\n", + "<br>\n", + "Analysis and Visualization:\n", + " <a href=\"https://renkulab.io/projects/covid-19/covid-19-public-data\">Covid-19 Public Data Collaboration Project</a>\n", + "</p>" + ], + "text/plain": [ + "<IPython.core.display.HTML object>" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -518,24 +599,26 @@ " width=200,\n", " height=200)\n", "totals = alt.layer(total, death)\n", - "totals.facet(facet='region', \n", + "chart = totals.facet(facet='region', \n", " columns=5, \n", " align='each', \n", " title='Total cases (orange) and deaths (black) by region per 100k population'\n", ").configure_title(\n", " anchor='middle'\n", - ")" + ")\n", + "display(chart)\n", + "display(html_credits)" ] }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "metadata": { "papermill": { - "duration": 0.06734, - "end_time": "2020-03-30T15:01:09.235215", + "duration": 0.112092, + "end_time": "2020-03-30T15:47:03.263790", "exception": false, - "start_time": "2020-03-30T15:01:09.167875", + "start_time": "2020-03-30T15:47:03.151698", "status": "completed" }, "tags": [] @@ -550,13 +633,13 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "metadata": { "papermill": { - "duration": 0.120633, - "end_time": "2020-03-30T15:01:09.373534", + "duration": 0.169858, + "end_time": "2020-03-30T15:47:03.469457", "exception": false, - "start_time": "2020-03-30T15:01:09.252901", + "start_time": "2020-03-30T15:47:03.299599", "status": "completed" }, "tags": [] @@ -566,10 +649,10 @@ "data": { "text/html": [ "\n", - "<div id=\"altair-viz-7e4038f6a90040628bd21b68f5c43724\"></div>\n", + "<div id=\"altair-viz-5e5f4ac644f74bf0a985b1aa082570bc\"></div>\n", "<script type=\"text/javascript\">\n", " (function(spec, embedOpt){\n", - " const outputDiv = document.getElementById(\"altair-viz-7e4038f6a90040628bd21b68f5c43724\");\n", + " const outputDiv = document.getElementById(\"altair-viz-5e5f4ac644f74bf0a985b1aa082570bc\");\n", " const paths = {\n", " \"vega\": \"https://cdn.jsdelivr.net/npm//vega@5?noext\",\n", " \"vega-lib\": \"https://cdn.jsdelivr.net/npm//vega-lib?noext\",\n", @@ -617,9 +700,26 @@ "alt.FacetChart(...)" ] }, - "execution_count": 14, "metadata": {}, - "output_type": "execute_result" + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "\n", + "<p style=\"font-size: smaller\">Data Sources: \n", + " <a href=\"https://github.com/pcm-dpc/COVID-19\">Italian Civil Protection</a>, <a href=\"https://wikidata.org\">Wikidata</a>\n", + "<br>\n", + "Analysis and Visualization:\n", + " <a href=\"https://renkulab.io/projects/covid-19/covid-19-public-data\">Covid-19 Public Data Collaboration Project</a>\n", + "</p>" + ], + "text/plain": [ + "<IPython.core.display.HTML object>" + ] + }, + "metadata": {}, + "output_type": "display_data" } ], "source": [ @@ -630,39 +730,25 @@ ")\n", "daily_new = base.mark_bar(color='orange').encode(alt.Y('total_cases_diff', title='N'))\n", "daily_dead = base.mark_line(color='black').encode(alt.Y('dead_diff'))\n", - "(daily_new + daily_dead).facet(\n", + "chart = (daily_new + daily_dead).facet(\n", " facet='region', \n", " columns=5, \n", " align='each', \n", " title='Daily new cases (orange) and deaths (black) by region',\n", ").configure_title(\n", " anchor='middle'\n", - ")" + ")\n", + "display(chart)\n", + "display(html_credits)" ] - }, - { - "cell_type": "code", - "execution_count": null, - "metadata": { - "papermill": { - "duration": 0.021361, - "end_time": "2020-03-30T15:01:09.418072", - "exception": false, - "start_time": "2020-03-30T15:01:09.396711", - "status": "completed" - }, - "tags": [] - }, - "outputs": [], - "source": [] } ], "metadata": { "hide_input": true, "kernelspec": { - "display_name": "Python 3.7.7 64-bit ('.venv': venv)", + "display_name": "Python 3", "language": "python", - "name": "python37764bitvenvvenvdef91c48e9bd43a4b394e5189f093471" + "name": "python3" }, "language_info": { "codemirror_mode": { @@ -674,11 +760,11 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.7.7" + "version": "3.7.3" }, "papermill": { - "duration": 3.022458, - "end_time": "2020-03-30T15:01:09.755307", + "duration": 3.777963, + "end_time": "2020-03-30T15:47:03.822983", "environment_variables": {}, "exception": null, "input_path": "notebooks/examples/italy-covid-19.ipynb", @@ -686,7 +772,7 @@ "parameters": { "data_folder": "./data/covid-19-italy/" }, - "start_time": "2020-03-30T15:01:06.732849", + "start_time": "2020-03-30T15:47:00.045020", "version": "1.1.0" } }, -- GitLab