From d7504b9d28884ad12fc4a9e3c509d5bd5a24bd51 Mon Sep 17 00:00:00 2001 From: Dmitry Chigarev Date: Thu, 3 Feb 2022 17:25:55 +0300 Subject: [PATCH 1/2] FIX: Add time results verifier to Modin's get started notebook Signed-off-by: Dmitry Chigarev --- .../IntelModin_GettingStarted.ipynb | 51 +++++++++++++++++-- 1 file changed, 48 insertions(+), 3 deletions(-) diff --git a/AI-and-Analytics/Getting-Started-Samples/IntelModin_GettingStarted/IntelModin_GettingStarted.ipynb b/AI-and-Analytics/Getting-Started-Samples/IntelModin_GettingStarted/IntelModin_GettingStarted.ipynb index 777df8b8fa..6ecfbbfe3b 100644 --- a/AI-and-Analytics/Getting-Started-Samples/IntelModin_GettingStarted/IntelModin_GettingStarted.ipynb +++ b/AI-and-Analytics/Getting-Started-Samples/IntelModin_GettingStarted/IntelModin_GettingStarted.ipynb @@ -47,6 +47,50 @@ "import time" ] }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# ****** Do not change the code below! It verifies that the notebook is being run correctly! ******\n", + "\n", + "def verify_and_print_times(pandas_time, modin_time):\n", + " if modin_time < pandas_time:\n", + " print(f\"Modin was {pandas_time / modin_time:.2f}X faster than stock Pandas!\")\n", + " return\n", + " print(\n", + " f\"Oops, stock Pandas appears to be {modin_time / pandas_time:.2f}X faster than Modin in this case. \"\n", + " \"This is unlikely but could happen sometimes on certain machines/environments/datasets. \"\n", + " \"One of the most probable reasons is the excessive amount of partitions being assigned to a single worker. \"\n", + " \"You may visit Modin's optimization guide in order to learn more about such cases and how to fix them: \"\n", + " \"\\nhttps://modin.readthedocs.io/en/latest/usage_guide/optimization_notes/index.html\\n\\n\"\n", + " \"But first, verify that you're using the latest Modin version, also, try to use different executions, \"\n", + " \"for basic usage we recommend non-experimental 'PandasOnRay'\\n\"\n", + " \"Current execution is:\"\n", + " )\n", + " try:\n", + " import modin.config as cfg\n", + "\n", + " try:\n", + " storage_format = cfg.StorageFormat.get()\n", + " except AttributeError:\n", + " # for modin versions < 0.12\n", + " storage_format = cfg.Backend.get()\n", + " print(\n", + " f\"\\tExecution: {storage_format}On{cfg.Engine.get()}\\n\"\n", + " f\"\\tIs experimental: {cfg.IsExperimental.get()}\\n\"\n", + " f\"\\tCores to use by Modin (check that Modin uses all cores on your machine): {cfg.CpuCount.get()}\\n\"\n", + " f\"\\tIs in debug mode (debug mode may perform slower): {cfg.IsDebug.get()}\"\n", + " )\n", + " except ImportError:\n", + " # for modin versions < 0.8.2\n", + " pass\n", + " import modin\n", + "\n", + " print(f\"\\tModin version: {modin.__version__}\") " + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -612,6 +656,7 @@ "modin_time = time.time() - t1\n", "\n", "print(\"Pandas Time(seconds):\",pandas_time,\"\\nModin Time(seconds):\",modin_time)\n", + "verify_and_print_times(pandas_time, modin_time)\n", "outputDict={\"Pandas\":pandas_time,\"Modin\":modin_time}\n", "plotter(outputDict)" ] @@ -693,7 +738,7 @@ } ], "source": [ - "print(\"Modin was {}X faster than stock Pandas!\".format(round(pandas_time/modin_time, 2)))" + "verify_and_print_times(pandas_time, modin_time)" ] }, { @@ -852,7 +897,7 @@ } ], "source": [ - "print(\"Modin was {}X faster than stock Pandas!\".format(round(pandas_time/modin_time, 2)))" + "verify_and_print_times(pandas_time, modin_time)" ] }, { @@ -1000,7 +1045,7 @@ } ], "source": [ - "print(\"Modin was {}X faster than stock Pandas!\".format(round(pandas_time/modin_time, 2)))" + "verify_and_print_times(pandas_time, modin_time)" ] }, { From 42c015d9d1251f4914ceaa0d8b15e4bc9d1d74c2 Mon Sep 17 00:00:00 2001 From: Dmitry Chigarev Date: Fri, 4 Feb 2022 15:13:40 +0300 Subject: [PATCH 2/2] Align text section with the in-code variable names Signed-off-by: Dmitry Chigarev --- .../IntelModin_GettingStarted/IntelModin_GettingStarted.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AI-and-Analytics/Getting-Started-Samples/IntelModin_GettingStarted/IntelModin_GettingStarted.ipynb b/AI-and-Analytics/Getting-Started-Samples/IntelModin_GettingStarted/IntelModin_GettingStarted.ipynb index 6ecfbbfe3b..bb1f605850 100644 --- a/AI-and-Analytics/Getting-Started-Samples/IntelModin_GettingStarted/IntelModin_GettingStarted.ipynb +++ b/AI-and-Analytics/Getting-Started-Samples/IntelModin_GettingStarted/IntelModin_GettingStarted.ipynb @@ -102,7 +102,7 @@ "cell_type": "markdown", "metadata": {}, "source": [ - "We will also be importing **stock Pandas as pd** and **Modin as mpd to show differentiation**. You can see importing Modin is simple and **does not require any additional steps.**" + "We will also be importing **stock Pandas as pandas** and **Modin as pd to show differentiation**. You can see importing Modin is simple and **does not require any additional steps.**" ] }, {