diff --git a/_proc/bounding_boxes.ipynb b/_proc/bounding_boxes.ipynb index a35cdac..662a5f3 100644 --- a/_proc/bounding_boxes.ipynb +++ b/_proc/bounding_boxes.ipynb @@ -99,7 +99,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "\u001b[2;36m[08/17/24 12:55:25]\u001b[0m\u001b[2;36m \u001b[0m\u001b[2;31mWARNING \u001b[0m Unable to load torch and dependent libraries from torch-snippets. \u001b]8;id=121523;file:///Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/loader.py:108\u001b\\\u001b[2mloader.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=164102;file:///Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/loader.py:108#:108\u001b\\\u001b[2m:108\u001b[0m\u001b]8;;\u001b\\\n", + "\u001b[2;36m[08/23/24 18:12:57]\u001b[0m\u001b[2;36m \u001b[0m\u001b[2;31mWARNING \u001b[0m Unable to load torch and dependent libraries from torch-snippets. \u001b]8;id=185334;file:///Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/loader.py:108\u001b\\\u001b[2mloader.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=169396;file:///Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/loader.py:108#:108\u001b\\\u001b[2m:108\u001b[0m\u001b]8;;\u001b\\\n", "\u001b[2;36m \u001b[0m Functionalities might be limited. pip install lovely-tensors in case there are torch related errors \u001b[2m \u001b[0m\n" ] } diff --git a/_proc/decorators.ipynb b/_proc/decorators.ipynb index f6dbd97..4b2ee11 100644 --- a/_proc/decorators.ipynb +++ b/_proc/decorators.ipynb @@ -282,7 +282,7 @@ "OUTPUTS:\n", "int: 21\n", "══════════════════════════════════════════════════════════════════\n", - "\u001b[2;36m[08/17/24 12:55:28]\u001b[0m\u001b[2;36m \u001b[0m\u001b[2;33mINFO \u001b[0m foo took \u001b[1;36m1.01\u001b[0m seconds to execute \u001b]8;id=866065;file://:47\u001b\\\u001b[2m\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=883885;file://:47#wrapper:47\u001b\\\u001b[2mwrapper:47\u001b[0m\u001b]8;;\u001b\\\n" + "\u001b[2;36m[08/23/24 18:13:00]\u001b[0m\u001b[2;36m \u001b[0m\u001b[2;33mINFO \u001b[0m foo took \u001b[1;36m1.00\u001b[0m seconds to execute \u001b]8;id=60504;file://:47\u001b\\\u001b[2m\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=369021;file://:47#wrapper:47\u001b\\\u001b[2mwrapper:47\u001b[0m\u001b]8;;\u001b\\\n" ] }, { diff --git a/_proc/jupyter_notebook.ipynb b/_proc/jupyter_notebook.ipynb index d9d0bc1..9f87c9d 100644 --- a/_proc/jupyter_notebook.ipynb +++ b/_proc/jupyter_notebook.ipynb @@ -219,7 +219,7 @@ "### display_dfs_side_by_side\n", "\n", "> display_dfs_side_by_side (*args, titles= 0x137427a00>, max_rows=50)" + "> 0x13fd9b3c0>, max_rows=50)" ], "text/plain": [ "---\n", @@ -227,7 +227,7 @@ "### display_dfs_side_by_side\n", "\n", "> display_dfs_side_by_side (*args, titles= 0x137427a00>, max_rows=50)" + "> 0x13fd9b3c0>, max_rows=50)" ] }, "execution_count": 6, diff --git a/_proc/misc.ipynb b/_proc/misc.ipynb index 7cae06b..221250b 100644 --- a/_proc/misc.ipynb +++ b/_proc/misc.ipynb @@ -32,15 +32,15 @@ "text": [ "\n", "1/10 (1.01s - 9.05s remaining - 1.01 s/iter) \n", - "2/10 (1.91s - 7.64s remaining - 1.05 iters/s) \n", - "3/10 (2.72s - 6.34s remaining - 1.10 iters/s) \n", - "4/10 (3.42s - 5.13s remaining - 1.17 iters/s) \n", + "2/10 (1.91s - 7.63s remaining - 1.05 iters/s) \n", + "3/10 (2.71s - 6.33s remaining - 1.11 iters/s) \n", + "4/10 (3.42s - 5.12s remaining - 1.17 iters/s) \n", "5/10 (4.02s - 4.02s remaining - 1.24 iters/s) \n", - "6/10 (4.53s - 3.02s remaining - 1.33 iters/s) \n", - "7/10 (4.93s - 2.11s remaining - 1.42 iters/s) \n", - "8/10 (5.24s - 1.31s remaining - 1.53 iters/s) \n", - "9/10 (5.44s - 0.60s remaining - 1.66 iters/s) \n", - "10/10 (5.54s - 0.00s remaining - 1.80 iters/s) \r" + "6/10 (4.52s - 3.01s remaining - 1.33 iters/s) \n", + "7/10 (4.92s - 2.11s remaining - 1.42 iters/s) \n", + "8/10 (5.23s - 1.31s remaining - 1.53 iters/s) \n", + "9/10 (5.43s - 0.60s remaining - 1.66 iters/s) \n", + "10/10 (5.53s - 0.00s remaining - 1.81 iters/s) \r" ] } ], @@ -84,8 +84,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "51/100 (5.29s - 5.08s remaining - 9.64 iters/s) \n", - "My Info: 156.1\t100/100 (10.39s - 0.00s remaining - 9.63 iters/s) \r" + "51/100 (5.28s - 5.07s remaining - 9.66 iters/s) \n", + "My Info: 156.1\t100/100 (10.38s - 0.00s remaining - 9.63 iters/s) \r" ] } ], @@ -120,8 +120,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "50/100 (5.21s - 5.21s remaining - 9.60 iters/s) \n", - "My Info: 309.08\t100/100 (10.39s - 0.00s remaining - 9.63 iters/s) \r" + "50/100 (5.20s - 5.20s remaining - 9.61 iters/s) \n", + "My Info: 309.08\t100/100 (10.36s - 0.00s remaining - 9.65 iters/s) \r" ] } ], @@ -155,11 +155,11 @@ { "data": { "text/html": [ - "
[08/11/24 19:04:44] DEBUG    0.00 seconds to execute `foo`                                                                                            1296653500.py:inner:16\n",
+       "
[08/23/24 17:39:53] DEBUG    0.00 seconds to execute `foo`                                                                                            1296653500.py:inner:16\n",
        "
\n" ], "text/plain": [ - "\u001b[2;36m[08/11/24 19:04:44]\u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b[1;36m0.00\u001b[0m seconds to execute `foo` \u001b]8;id=768985;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/1296653500.py:16\u001b\\\u001b[2m1296653500.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=794464;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/1296653500.py:16#inner:16\u001b\\\u001b[2minner:16\u001b[0m\u001b]8;;\u001b\\\n" + "\u001b[2;36m[08/23/24 17:39:53]\u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b[1;36m0.00\u001b[0m seconds to execute `foo` \u001b]8;id=645548;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1296653500.py:16\u001b\\\u001b[2m1296653500.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=353152;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1296653500.py:16#inner:16\u001b\\\u001b[2minner:16\u001b[0m\u001b]8;;\u001b\\\n" ] }, "metadata": {}, @@ -168,7 +168,7 @@ { "data": { "text/html": [ - "
                    DEBUG                                                                                                                          2064456364.py::12\" target=\"_blank\"><module>:12\n",
+       "
                    DEBUG                                                                                                                          2064456364.py::12\" target=\"_blank\"><module>:12\n",
        "                             0.00 seconds to execute `inner`                                                                                                                \n",
        "                             args()                                                                                                                                         \n",
        "                               0 - 10 (🏷️ int)                                                                                                                               \n",
@@ -179,7 +179,7 @@
        "
\n" ], "text/plain": [ - "\u001b[2;36m \u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b]8;id=196942;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/2064456364.py:12\u001b\\\u001b[2m2064456364.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=537244;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/2064456364.py:12#:12\u001b\\\u001b[2m:12\u001b[0m\u001b]8;;\u001b\\\n", + "\u001b[2;36m \u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b]8;id=824600;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/2064456364.py:12\u001b\\\u001b[2m2064456364.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=898659;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/2064456364.py:12#:12\u001b\\\u001b[2m:12\u001b[0m\u001b]8;;\u001b\\\n", "\u001b[2;36m \u001b[0m \u001b[1;36m0.00\u001b[0m seconds to execute `inner` \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;35margs\u001b[0m\u001b[1m(\u001b[0m\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m0\u001b[0m - \u001b[1;36m10\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", @@ -195,11 +195,11 @@ { "data": { "text/html": [ - "
[08/11/24 19:04:46] DEBUG    2.00 seconds to execute `foo`                                                                                            1296653500.py:inner:16\n",
+       "
[08/23/24 17:39:55] DEBUG    2.01 seconds to execute `foo`                                                                                            1296653500.py:inner:16\n",
        "
\n" ], "text/plain": [ - "\u001b[2;36m[08/11/24 19:04:46]\u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b[1;36m2.00\u001b[0m seconds to execute `foo` \u001b]8;id=200602;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/1296653500.py:16\u001b\\\u001b[2m1296653500.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=221957;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/1296653500.py:16#inner:16\u001b\\\u001b[2minner:16\u001b[0m\u001b]8;;\u001b\\\n" + "\u001b[2;36m[08/23/24 17:39:55]\u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b[1;36m2.01\u001b[0m seconds to execute `foo` \u001b]8;id=621942;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1296653500.py:16\u001b\\\u001b[2m1296653500.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=222460;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1296653500.py:16#inner:16\u001b\\\u001b[2minner:16\u001b[0m\u001b]8;;\u001b\\\n" ] }, "metadata": {}, @@ -208,7 +208,7 @@ { "data": { "text/html": [ - "
                    DEBUG                                                                                                                          2064456364.py::13\" target=\"_blank\"><module>:13\n",
+       "
                    DEBUG                                                                                                                          2064456364.py::13\" target=\"_blank\"><module>:13\n",
        "                             2.01 seconds to execute `inner`                                                                                                                \n",
        "                             args()                                                                                                                                         \n",
        "                               0 - 10 (🏷️ int)                                                                                                                               \n",
@@ -220,7 +220,7 @@
        "
\n" ], "text/plain": [ - "\u001b[2;36m \u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b]8;id=50473;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/2064456364.py:13\u001b\\\u001b[2m2064456364.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=285800;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/2064456364.py:13#:13\u001b\\\u001b[2m:13\u001b[0m\u001b]8;;\u001b\\\n", + "\u001b[2;36m \u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b]8;id=179073;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/2064456364.py:13\u001b\\\u001b[2m2064456364.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=325734;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/2064456364.py:13#:13\u001b\\\u001b[2m:13\u001b[0m\u001b]8;;\u001b\\\n", "\u001b[2;36m \u001b[0m \u001b[1;36m2.01\u001b[0m seconds to execute `inner` \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;35margs\u001b[0m\u001b[1m(\u001b[0m\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m0\u001b[0m - \u001b[1;36m10\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", @@ -251,9 +251,16 @@ " foo(10, b=20)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Try Catch with a single line" + ] + }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 33, "metadata": { "language": "python" }, @@ -261,25 +268,25 @@ { "data": { "text/html": [ - "
[08/11/24 19:11:33] ERROR    Error for `do` with                                                                                                      3146474900.py:inner:17\n",
+       "
[08/23/24 17:48:03] ERROR    Error for `do` with                                                                                                      1057038067.py:inner:30\n",
        "                             args()                                                                                                                                         \n",
        "                               0 - 1 (🏷️ int)                                                                                                                                \n",
        "                               1 - 2 (🏷️ int)                                                                                                                                \n",
        "                             kwargs                                                                                                                                         \n",
        "                               c - 10 (🏷️ int)                                                                                                                               \n",
        "                                                                                                                                                                            \n",
-       "                             division by zero                                                                                                                               \n",
+       "                             ZeroDivisionError: division by zero                                                                                                            \n",
        "
\n" ], "text/plain": [ - "\u001b[2;36m[08/11/24 19:11:33]\u001b[0m\u001b[2;36m \u001b[0m\u001b[1;31mERROR \u001b[0m Error for `do` with \u001b]8;id=675640;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py:17\u001b\\\u001b[2m3146474900.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=769587;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py:17#inner:17\u001b\\\u001b[2minner:17\u001b[0m\u001b]8;;\u001b\\\n", + "\u001b[2;36m[08/23/24 17:48:03]\u001b[0m\u001b[2;36m \u001b[0m\u001b[1;31mERROR \u001b[0m Error for `do` with \u001b]8;id=270527;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py:30\u001b\\\u001b[2m1057038067.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=157819;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py:30#inner:30\u001b\\\u001b[2minner:30\u001b[0m\u001b]8;;\u001b\\\n", "\u001b[2;36m \u001b[0m \u001b[1;35margs\u001b[0m\u001b[1m(\u001b[0m\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m0\u001b[0m - \u001b[1;36m1\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m1\u001b[0m - \u001b[1;36m2\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m kwargs \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m c - \u001b[1;36m10\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[2m \u001b[0m\n", - "\u001b[2;36m \u001b[0m division by zero \u001b[2m \u001b[0m\n" + "\u001b[2;36m \u001b[0m ZeroDivisionError: division by zero \u001b[2m \u001b[0m\n" ] }, "metadata": {}, @@ -296,9 +303,16 @@ "assert x is None # tryy returns None by default" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Use your own default on failure" + ] + }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 34, "metadata": { "language": "python" }, @@ -306,25 +320,25 @@ { "data": { "text/html": [ - "
[08/11/24 19:11:55] ERROR    Error for `do` with                                                                                                      3146474900.py:inner:17\n",
+       "
[08/23/24 17:48:04] ERROR    Error for `do` with                                                                                                      1057038067.py:inner:30\n",
        "                             args()                                                                                                                                         \n",
        "                               0 - 1 (🏷️ int)                                                                                                                                \n",
        "                               1 - 2 (🏷️ int)                                                                                                                                \n",
        "                             kwargs                                                                                                                                         \n",
        "                               c - 10 (🏷️ int)                                                                                                                               \n",
        "                                                                                                                                                                            \n",
-       "                             division by zero                                                                                                                               \n",
+       "                             ZeroDivisionError: division by zero                                                                                                            \n",
        "
\n" ], "text/plain": [ - "\u001b[2;36m[08/11/24 19:11:55]\u001b[0m\u001b[2;36m \u001b[0m\u001b[1;31mERROR \u001b[0m Error for `do` with \u001b]8;id=807965;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py:17\u001b\\\u001b[2m3146474900.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=923417;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py:17#inner:17\u001b\\\u001b[2minner:17\u001b[0m\u001b]8;;\u001b\\\n", + "\u001b[2;36m[08/23/24 17:48:04]\u001b[0m\u001b[2;36m \u001b[0m\u001b[1;31mERROR \u001b[0m Error for `do` with \u001b]8;id=550994;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py:30\u001b\\\u001b[2m1057038067.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=605547;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py:30#inner:30\u001b\\\u001b[2minner:30\u001b[0m\u001b]8;;\u001b\\\n", "\u001b[2;36m \u001b[0m \u001b[1;35margs\u001b[0m\u001b[1m(\u001b[0m\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m0\u001b[0m - \u001b[1;36m1\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m1\u001b[0m - \u001b[1;36m2\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m kwargs \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m c - \u001b[1;36m10\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[2m \u001b[0m\n", - "\u001b[2;36m \u001b[0m division by zero \u001b[2m \u001b[0m\n" + "\u001b[2;36m \u001b[0m ZeroDivisionError: division by zero \u001b[2m \u001b[0m\n" ] }, "metadata": {}, @@ -336,7 +350,7 @@ "'😔'" ] }, - "execution_count": 33, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -359,7 +373,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 35, "metadata": { "language": "python" }, @@ -367,7 +381,7 @@ { "data": { "text/html": [ - "
[08/11/24 19:11:56] ERROR    Error for `do` with                                                                                                      3146474900.py:inner:17\n",
+       "
[08/23/24 17:48:06] ERROR    Error for `do` with                                                                                                      1057038067.py:inner:30\n",
        "                             args()                                                                                                                                         \n",
        "                               0 - 1 (🏷️ int)                                                                                                                                \n",
        "                               1 - 2 (🏷️ int)                                                                                                                                \n",
@@ -375,10 +389,10 @@
        "                               c - 10 (🏷️ int)                                                                                                                               \n",
        "                                                                                                                                                                            \n",
        "                             Traceback (most recent call last):                                                                                                             \n",
-       "                               File \"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py\", line 9, in inner                                      \n",
+       "                               File \"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py\", line 21, in inner                                     \n",
        "                                 return f(*args, **kwargs)                                                                                                                  \n",
        "                                        ^^^^^^^^^^^^^^^^^^                                                                                                                  \n",
-       "                               File \"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/2870377084.py\", line 3, in do                                         \n",
+       "                               File \"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/580638143.py\", line 3, in do                                          \n",
        "                                 return 1 / 0                                                                                                                               \n",
        "                                        ~~^~~                                                                                                                               \n",
        "                             ZeroDivisionError: division by zero                                                                                                            \n",
@@ -386,7 +400,7 @@
        "
\n" ], "text/plain": [ - "\u001b[2;36m[08/11/24 19:11:56]\u001b[0m\u001b[2;36m \u001b[0m\u001b[1;31mERROR \u001b[0m Error for `do` with \u001b]8;id=118525;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py:17\u001b\\\u001b[2m3146474900.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=56484;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py:17#inner:17\u001b\\\u001b[2minner:17\u001b[0m\u001b]8;;\u001b\\\n", + "\u001b[2;36m[08/23/24 17:48:06]\u001b[0m\u001b[2;36m \u001b[0m\u001b[1;31mERROR \u001b[0m Error for `do` with \u001b]8;id=430447;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py:30\u001b\\\u001b[2m1057038067.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=852031;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py:30#inner:30\u001b\\\u001b[2minner:30\u001b[0m\u001b]8;;\u001b\\\n", "\u001b[2;36m \u001b[0m \u001b[1;35margs\u001b[0m\u001b[1m(\u001b[0m\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m0\u001b[0m - \u001b[1;36m1\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m1\u001b[0m - \u001b[1;36m2\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", @@ -394,10 +408,10 @@ "\u001b[2;36m \u001b[0m c - \u001b[1;36m10\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m Traceback \u001b[1m(\u001b[0mmost recent call last\u001b[1m)\u001b[0m: \u001b[2m \u001b[0m\n", - "\u001b[2;36m \u001b[0m File \u001b[32m\"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py\"\u001b[0m, line \u001b[1;36m9\u001b[0m, in inner \u001b[2m \u001b[0m\n", + "\u001b[2;36m \u001b[0m File \u001b[32m\"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py\"\u001b[0m, line \u001b[1;36m21\u001b[0m, in inner \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m return \u001b[1;35mf\u001b[0m\u001b[1m(\u001b[0m*args, **kwargs\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m ^^^^^^^^^^^^^^^^^^ \u001b[2m \u001b[0m\n", - "\u001b[2;36m \u001b[0m File \u001b[32m\"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/2870377084.py\"\u001b[0m, line \u001b[1;36m3\u001b[0m, in do \u001b[2m \u001b[0m\n", + "\u001b[2;36m \u001b[0m File \u001b[32m\"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/580638143.py\"\u001b[0m, line \u001b[1;36m3\u001b[0m, in do \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m return \u001b[1;36m1\u001b[0m \u001b[35m/\u001b[0m \u001b[1;36m0\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m ~~^~~ \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m ZeroDivisionError: division by zero \u001b[2m \u001b[0m\n", @@ -413,7 +427,7 @@ "'😔'" ] }, - "execution_count": 34, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -427,9 +441,359 @@ "do(1, 2, c=10)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can also silence the errors completely" + ] + }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 36, + "metadata": { + "language": "python" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'😔'" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "@tryy(silence_errors=True, output_to_return_on_fail=\"😔\")\n", + "def do(a, b, c):\n", + " return 1 / 0\n", + "\n", + "\n", + "do(1, 2, c=10)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can collect all your errors in a list" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": { + "language": "python" + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[\n", + "```↯ AttrDict ↯\n", + "func - do (🏷️ str)\n", + "args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 3 (🏷️ int)\n", + "kwargs\n", + " c - 67 (🏷️ int)\n", + "tb - NotImplementedError: 🤔 (🏷️ str)\n", + "err_type - NotImplementedError (🏷️ str)\n", + "\n", + "```\n", + ", \n", + "```↯ AttrDict ↯\n", + "func - do (🏷️ str)\n", + "args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 9 (🏷️ int)\n", + "kwargs\n", + " c - 8 (🏷️ int)\n", + "tb - NotImplementedError: 🤔 (🏷️ str)\n", + "err_type - NotImplementedError (🏷️ str)\n", + "\n", + "```\n", + ", \n", + "```↯ AttrDict ↯\n", + "func - do (🏷️ str)\n", + "args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 2 (🏷️ int)\n", + "kwargs\n", + " c - 23 (🏷️ int)\n", + "tb - NotImplementedError: 🤔 (🏷️ str)\n", + "err_type - NotImplementedError (🏷️ str)\n", + "\n", + "```\n", + ", \n", + "```↯ AttrDict ↯\n", + "func - do (🏷️ str)\n", + "args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 9 (🏷️ int)\n", + "kwargs\n", + " c - 6 (🏷️ int)\n", + "tb - NotImplementedError: 🤔 (🏷️ str)\n", + "err_type - NotImplementedError (🏷️ str)\n", + "\n", + "```\n", + "]\n" + ] + } + ], + "source": [ + "import random\n", + "\n", + "errors = []\n", + "\n", + "\n", + "@tryy(silence_errors=True, store_errors=errors)\n", + "def do(a, b, c):\n", + " if random.randint(0, 100) < 50:\n", + " return 1 / 0\n", + " else:\n", + " raise NotImplementedError(\"🤔\")\n", + "\n", + "\n", + "for _ in range(4):\n", + " do(1, random.randint(0, 10), c=random.randint(0, 100))\n", + "\n", + "print(errors)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "There's onlly one usecase where you would want to send in a list by yourself - when you want to append your errors to an existing list. The sensible default is to always store the errors, especially because this is a debugging tool.\n", + "\n", + "Just access all the errors in a dataframe like so" + ] + }, + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "language": "python" + }, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
funcargskwargstberr_type
0do[1, 9]{'c': 4}ZeroDivisionError: division by zeroZeroDivisionError
1do[1, 6]{'c': 61}NotImplementedError: 🤔NotImplementedError
2do[1, 9]{'c': 1}ZeroDivisionError: division by zeroZeroDivisionError
3do[1, 3]{'c': 59}NotImplementedError: 🤔NotImplementedError
\n", + "
" + ], + "text/plain": [ + " func args ... tb err_type\n", + "0 do [1, 9] ... ZeroDivisionError: division by zero ZeroDivisionError\n", + "1 do [1, 6] ... NotImplementedError: 🤔 NotImplementedError\n", + "2 do [1, 9] ... ZeroDivisionError: division by zero ZeroDivisionError\n", + "3 do [1, 3] ... NotImplementedError: 🤔 NotImplementedError\n", + "\n", + "[4 rows x 5 columns]" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import random\n", + "\n", + "random.seed(10)\n", + "errors = []\n", + "\n", + "\n", + "@tryy(silence_errors=True, store_errors=errors, output_to_return_on_fail=\"😔\")\n", + "def do(a, b, c):\n", + " if c < 50:\n", + " return 1 / 0\n", + " else:\n", + " raise NotImplementedError(\"🤔\")\n", + "\n", + "\n", + "for _ in range(4):\n", + " do(1, random.randint(0, 10), c=random.randint(0, 100))\n", + "\n", + "do.error_summary()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "and the actual list of errors like so" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": { + "language": "python" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[\n", + " ```↯ AttrDict ↯\n", + " func - do (🏷️ str)\n", + " args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 9 (🏷️ int)\n", + " kwargs\n", + " c - 4 (🏷️ int)\n", + " tb - ZeroDivisionError: division by zero (🏷️ str)\n", + " err_type - ZeroDivisionError (🏷️ str)\n", + " \n", + " ```,\n", + " \n", + " ```↯ AttrDict ↯\n", + " func - do (🏷️ str)\n", + " args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 6 (🏷️ int)\n", + " kwargs\n", + " c - 61 (🏷️ int)\n", + " tb - NotImplementedError: 🤔 (🏷️ str)\n", + " err_type - NotImplementedError (🏷️ str)\n", + " \n", + " ```,\n", + " \n", + " ```↯ AttrDict ↯\n", + " func - do (🏷️ str)\n", + " args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 9 (🏷️ int)\n", + " kwargs\n", + " c - 1 (🏷️ int)\n", + " tb - ZeroDivisionError: division by zero (🏷️ str)\n", + " err_type - ZeroDivisionError (🏷️ str)\n", + " \n", + " ```,\n", + " \n", + " ```↯ AttrDict ↯\n", + " func - do (🏷️ str)\n", + " args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 3 (🏷️ int)\n", + " kwargs\n", + " c - 59 (🏷️ int)\n", + " tb - NotImplementedError: 🤔 (🏷️ str)\n", + " err_type - NotImplementedError (🏷️ str)\n", + " \n", + " ```]" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "do.error_store" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Finally, you want to run the function (without try) to reproduce the error and actually start debugging. Just use the `.F` attribute to access the original function that you created" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": { + "language": "python" + }, + "outputs": [ + { + "ename": "ZeroDivisionError", + "evalue": "division by zero", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[51], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m ix \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m2\u001b[39m\n\u001b[1;32m 2\u001b[0m data \u001b[38;5;241m=\u001b[39m do\u001b[38;5;241m.\u001b[39merror_store[ix]\n\u001b[0;32m----> 3\u001b[0m \u001b[43mdo\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mF\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mdata\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mdata\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "Cell \u001b[0;32mIn[49], line 9\u001b[0m, in \u001b[0;36mdo\u001b[0;34m(a, b, c)\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[38;5;129m@tryy\u001b[39m(silence_errors\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m, store_errors\u001b[38;5;241m=\u001b[39merrors, output_to_return_on_fail\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m😔\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdo\u001b[39m(a, b, c):\n\u001b[1;32m 8\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m c \u001b[38;5;241m<\u001b[39m \u001b[38;5;241m50\u001b[39m:\n\u001b[0;32m----> 9\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;241;43m1\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m/\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\n\u001b[1;32m 10\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 11\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mNotImplementedError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m🤔\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "\u001b[0;31mZeroDivisionError\u001b[0m: division by zero" + ] + } + ], + "source": [ + "ix = 2\n", + "data = do.error_store[ix]\n", + "do.F(*data.args, **data.kwargs)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, "metadata": { "language": "python" }, @@ -460,7 +824,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 14, "metadata": { "language": "python" }, @@ -474,7 +838,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 15, "metadata": { "language": "python" }, @@ -494,7 +858,7 @@ "7" ] }, - "execution_count": 19, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -511,11 +875,33 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": { "language": "python" }, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "args kwargs\n", + "B new_param None\n" + ] + }, + { + "ename": "TypeError", + "evalue": "C() missing 3 required positional arguments: 'a', 'b', and 'c'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[16], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;129;43m@B\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mdeco_param\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mnew_param\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;43;01mdef\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;21;43mC\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43ma\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mb\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mc\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mreturn\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43ma\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m(\u001b[49m\u001b[43mb\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mc\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 6\u001b[0m \u001b[38;5;66;03m# Testing\u001b[39;00m\n", + "Cell \u001b[0;32mIn[13], line 17\u001b[0m, in \u001b[0;36mdeco..wrapper..custom_decorator\u001b[0;34m(func)\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcustom_decorator\u001b[39m(func):\n\u001b[0;32m---> 17\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mdecorator\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "Cell \u001b[0;32mIn[14], line 4\u001b[0m, in \u001b[0;36mB\u001b[0;34m(func, deco_param, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;129m@deco\u001b[39m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mB\u001b[39m(func, \u001b[38;5;241m*\u001b[39margs, deco_param\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdefault\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mB\u001b[39m\u001b[38;5;124m\"\u001b[39m, deco_param, \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124margs\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mkwargs\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs))\n\u001b[0;32m----> 4\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[0;31mTypeError\u001b[0m: C() missing 3 required positional arguments: 'a', 'b', and 'c'" + ] + } + ], "source": [ "@B(deco_param=\"new_param\")\n", "def C(a, b, c):\n", diff --git a/changelog.md b/changelog.md index 958a987..88dd999 100644 --- a/changelog.md +++ b/changelog.md @@ -1,4 +1,18 @@ # Changelog +#### 0.539 +✨ set `AD_SHOW_TAB_STOPS` env variable to anything to print with tab-stops (only recommended to see on REPL. Default is good for storing files) +✨ `crop_from_bb` has `padding` (px,py,pX,pY) +🐞 minor bugfix in `AD` +🎉 `AD` has a `fetch2` which preserves json structure while fetching all the leafs of the same name +🎉 `AD` has a `flatten` which flattens all nested jsons into flat dictionary with '.' combined key names +🎉 `AD` has a `flatten_and_make_dataframe` which creates one column for each nesting +✨ `tryy` will store all its errors and can be accessed by calling `.error_summary()` +🎉 torch snippets as a new cli function called `ts`, thanks to the wonderful `Typer`. Try + `ts time` + `ts zen-of python` + `ts zen-of c++` + `ts --help` + #### 0.538.1 ✨ slightly better error printing in `tryy` diff --git a/nbs/misc.ipynb b/nbs/misc.ipynb index db6db4f..98e06de 100644 --- a/nbs/misc.ipynb +++ b/nbs/misc.ipynb @@ -24,12 +24,12 @@ { "data": { "text/html": [ - "
[08/11/24 19:04:17] WARNING  Unable to load torch and dependent libraries from torch-snippets.                                                        loader.py::108\" target=\"_blank\"><module>:108\n",
+       "
[08/23/24 17:39:26] WARNING  Unable to load torch and dependent libraries from torch-snippets.                                                        loader.py::108\" target=\"_blank\"><module>:108\n",
        "                             Functionalities might be limited. pip install lovely-tensors in case there are torch related errors                                            \n",
        "
\n" ], "text/plain": [ - "\u001b[2;36m[08/11/24 19:04:17]\u001b[0m\u001b[2;36m \u001b[0m\u001b[2;31mWARNING \u001b[0m Unable to load torch and dependent libraries from torch-snippets. \u001b]8;id=984597;file:///Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/loader.py:108\u001b\\\u001b[2mloader.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=81772;file:///Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/loader.py:108#:108\u001b\\\u001b[2m:108\u001b[0m\u001b]8;;\u001b\\\n", + "\u001b[2;36m[08/23/24 17:39:26]\u001b[0m\u001b[2;36m \u001b[0m\u001b[2;31mWARNING \u001b[0m Unable to load torch and dependent libraries from torch-snippets. \u001b]8;id=216491;file:///Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/loader.py:108\u001b\\\u001b[2mloader.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=691599;file:///Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/loader.py:108#:108\u001b\\\u001b[2m:108\u001b[0m\u001b]8;;\u001b\\\n", "\u001b[2;36m \u001b[0m Functionalities might be limited. pip install lovely-tensors in case there are torch related errors \u001b[2m \u001b[0m\n" ] }, @@ -40,10 +40,11 @@ "source": [ "# | export\n", "import time\n", - "from torch_snippets.logger import Debug, Excep, debug_mode\n", + "from torch_snippets.logger import Debug, Excep, debug_mode, Info\n", "from torch_snippets.markup2 import AD\n", "from functools import wraps\n", - "from fastcore.basics import ifnone" + "from fastcore.basics import ifnone\n", + "from fastcore.foundation import L" ] }, { @@ -139,15 +140,15 @@ "text": [ "\n", "1/10 (1.01s - 9.05s remaining - 1.01 s/iter) \n", - "2/10 (1.91s - 7.64s remaining - 1.05 iters/s) \n", - "3/10 (2.72s - 6.34s remaining - 1.10 iters/s) \n", - "4/10 (3.42s - 5.13s remaining - 1.17 iters/s) \n", + "2/10 (1.91s - 7.63s remaining - 1.05 iters/s) \n", + "3/10 (2.71s - 6.33s remaining - 1.11 iters/s) \n", + "4/10 (3.42s - 5.12s remaining - 1.17 iters/s) \n", "5/10 (4.02s - 4.02s remaining - 1.24 iters/s) \n", - "6/10 (4.53s - 3.02s remaining - 1.33 iters/s) \n", - "7/10 (4.93s - 2.11s remaining - 1.42 iters/s) \n", - "8/10 (5.24s - 1.31s remaining - 1.53 iters/s) \n", - "9/10 (5.44s - 0.60s remaining - 1.66 iters/s) \n", - "10/10 (5.54s - 0.00s remaining - 1.80 iters/s) \r" + "6/10 (4.52s - 3.01s remaining - 1.33 iters/s) \n", + "7/10 (4.92s - 2.11s remaining - 1.42 iters/s) \n", + "8/10 (5.23s - 1.31s remaining - 1.53 iters/s) \n", + "9/10 (5.43s - 0.60s remaining - 1.66 iters/s) \n", + "10/10 (5.53s - 0.00s remaining - 1.81 iters/s) \r" ] } ], @@ -189,8 +190,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "51/100 (5.29s - 5.08s remaining - 9.64 iters/s) \n", - "My Info: 156.1\t100/100 (10.39s - 0.00s remaining - 9.63 iters/s) \r" + "51/100 (5.28s - 5.07s remaining - 9.66 iters/s) \n", + "My Info: 156.1\t100/100 (10.38s - 0.00s remaining - 9.63 iters/s) \r" ] } ], @@ -223,8 +224,8 @@ "name": "stdout", "output_type": "stream", "text": [ - "50/100 (5.21s - 5.21s remaining - 9.60 iters/s) \n", - "My Info: 309.08\t100/100 (10.39s - 0.00s remaining - 9.63 iters/s) \r" + "50/100 (5.20s - 5.20s remaining - 9.61 iters/s) \n", + "My Info: 309.08\t100/100 (10.36s - 0.00s remaining - 9.65 iters/s) \r" ] } ], @@ -297,11 +298,11 @@ { "data": { "text/html": [ - "
[08/11/24 19:04:44] DEBUG    0.00 seconds to execute `foo`                                                                                            1296653500.py:inner:16\n",
+       "
[08/23/24 17:39:53] DEBUG    0.00 seconds to execute `foo`                                                                                            1296653500.py:inner:16\n",
        "
\n" ], "text/plain": [ - "\u001b[2;36m[08/11/24 19:04:44]\u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b[1;36m0.00\u001b[0m seconds to execute `foo` \u001b]8;id=768985;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/1296653500.py:16\u001b\\\u001b[2m1296653500.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=794464;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/1296653500.py:16#inner:16\u001b\\\u001b[2minner:16\u001b[0m\u001b]8;;\u001b\\\n" + "\u001b[2;36m[08/23/24 17:39:53]\u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b[1;36m0.00\u001b[0m seconds to execute `foo` \u001b]8;id=645548;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1296653500.py:16\u001b\\\u001b[2m1296653500.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=353152;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1296653500.py:16#inner:16\u001b\\\u001b[2minner:16\u001b[0m\u001b]8;;\u001b\\\n" ] }, "metadata": {}, @@ -310,7 +311,7 @@ { "data": { "text/html": [ - "
                    DEBUG                                                                                                                          2064456364.py::12\" target=\"_blank\"><module>:12\n",
+       "
                    DEBUG                                                                                                                          2064456364.py::12\" target=\"_blank\"><module>:12\n",
        "                             0.00 seconds to execute `inner`                                                                                                                \n",
        "                             args()                                                                                                                                         \n",
        "                               0 - 10 (🏷️ int)                                                                                                                               \n",
@@ -321,7 +322,7 @@
        "
\n" ], "text/plain": [ - "\u001b[2;36m \u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b]8;id=196942;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/2064456364.py:12\u001b\\\u001b[2m2064456364.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=537244;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/2064456364.py:12#:12\u001b\\\u001b[2m:12\u001b[0m\u001b]8;;\u001b\\\n", + "\u001b[2;36m \u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b]8;id=824600;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/2064456364.py:12\u001b\\\u001b[2m2064456364.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=898659;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/2064456364.py:12#:12\u001b\\\u001b[2m:12\u001b[0m\u001b]8;;\u001b\\\n", "\u001b[2;36m \u001b[0m \u001b[1;36m0.00\u001b[0m seconds to execute `inner` \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;35margs\u001b[0m\u001b[1m(\u001b[0m\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m0\u001b[0m - \u001b[1;36m10\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", @@ -337,11 +338,11 @@ { "data": { "text/html": [ - "
[08/11/24 19:04:46] DEBUG    2.00 seconds to execute `foo`                                                                                            1296653500.py:inner:16\n",
+       "
[08/23/24 17:39:55] DEBUG    2.01 seconds to execute `foo`                                                                                            1296653500.py:inner:16\n",
        "
\n" ], "text/plain": [ - "\u001b[2;36m[08/11/24 19:04:46]\u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b[1;36m2.00\u001b[0m seconds to execute `foo` \u001b]8;id=200602;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/1296653500.py:16\u001b\\\u001b[2m1296653500.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=221957;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/1296653500.py:16#inner:16\u001b\\\u001b[2minner:16\u001b[0m\u001b]8;;\u001b\\\n" + "\u001b[2;36m[08/23/24 17:39:55]\u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b[1;36m2.01\u001b[0m seconds to execute `foo` \u001b]8;id=621942;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1296653500.py:16\u001b\\\u001b[2m1296653500.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=222460;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1296653500.py:16#inner:16\u001b\\\u001b[2minner:16\u001b[0m\u001b]8;;\u001b\\\n" ] }, "metadata": {}, @@ -350,7 +351,7 @@ { "data": { "text/html": [ - "
                    DEBUG                                                                                                                          2064456364.py::13\" target=\"_blank\"><module>:13\n",
+       "
                    DEBUG                                                                                                                          2064456364.py::13\" target=\"_blank\"><module>:13\n",
        "                             2.01 seconds to execute `inner`                                                                                                                \n",
        "                             args()                                                                                                                                         \n",
        "                               0 - 10 (🏷️ int)                                                                                                                               \n",
@@ -362,7 +363,7 @@
        "
\n" ], "text/plain": [ - "\u001b[2;36m \u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b]8;id=50473;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/2064456364.py:13\u001b\\\u001b[2m2064456364.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=285800;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/2064456364.py:13#:13\u001b\\\u001b[2m:13\u001b[0m\u001b]8;;\u001b\\\n", + "\u001b[2;36m \u001b[0m\u001b[2;36m \u001b[0m\u001b[32mDEBUG \u001b[0m \u001b]8;id=179073;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/2064456364.py:13\u001b\\\u001b[2m2064456364.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=325734;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/2064456364.py:13#:13\u001b\\\u001b[2m:13\u001b[0m\u001b]8;;\u001b\\\n", "\u001b[2;36m \u001b[0m \u001b[1;36m2.01\u001b[0m seconds to execute `inner` \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;35margs\u001b[0m\u001b[1m(\u001b[0m\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m0\u001b[0m - \u001b[1;36m10\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", @@ -395,7 +396,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 32, "metadata": {}, "outputs": [], "source": [ @@ -403,8 +404,20 @@ "# | hide\n", "\n", "\n", - "def tryy(func=None, *, output_to_return_on_fail=None, print_traceback=False):\n", + "def tryy(\n", + " func=None,\n", + " *,\n", + " output_to_return_on_fail=None,\n", + " silence_errors=False,\n", + " print_traceback=False,\n", + " store_errors: bool = True,\n", + "):\n", " def decorator(f):\n", + " if isinstance(store_errors, bool) and store_errors:\n", + " error_store = []\n", + " elif isinstance(store_errors, (list, L)):\n", + " error_store = store_errors\n", + "\n", " def inner(*args, **kwargs):\n", " try:\n", " return f(*args, **kwargs)\n", @@ -415,11 +428,31 @@ " import traceback\n", "\n", " tb = traceback.format_exc()\n", - " Excep(\n", - " f\"Error for `{f.__name__}` with \\n{summarize_input(args, kwargs)}\\n{tb}\"\n", - " )\n", + " if not silence_errors:\n", + " Excep(\n", + " f\"Error for `{f.__name__}` with \\n{summarize_input(args, kwargs)}\\n{tb}\"\n", + " )\n", + " if store_errors is not None:\n", + " error_store.append(\n", + " AD(\n", + " func=f.__name__,\n", + " args=args,\n", + " kwargs=kwargs,\n", + " tb=tb,\n", + " err_type=type(e).__name__,\n", + " )\n", + " )\n", " return output_to_return_on_fail\n", "\n", + " inner.F = f # Store reference to the original function\n", + " inner.error_store = error_store\n", + "\n", + " def error_summary():\n", + " import pandas as pd\n", + "\n", + " return pd.DataFrame([e.dict() for e in error_store])\n", + "\n", + " inner.error_summary = error_summary\n", " return inner\n", "\n", " if callable(func):\n", @@ -427,33 +460,40 @@ " return decorator" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "## Try Catch with a single line" + ] + }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 33, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
[08/11/24 19:11:33] ERROR    Error for `do` with                                                                                                      3146474900.py:inner:17\n",
+       "
[08/23/24 17:48:03] ERROR    Error for `do` with                                                                                                      1057038067.py:inner:30\n",
        "                             args()                                                                                                                                         \n",
        "                               0 - 1 (🏷️ int)                                                                                                                                \n",
        "                               1 - 2 (🏷️ int)                                                                                                                                \n",
        "                             kwargs                                                                                                                                         \n",
        "                               c - 10 (🏷️ int)                                                                                                                               \n",
        "                                                                                                                                                                            \n",
-       "                             division by zero                                                                                                                               \n",
+       "                             ZeroDivisionError: division by zero                                                                                                            \n",
        "
\n" ], "text/plain": [ - "\u001b[2;36m[08/11/24 19:11:33]\u001b[0m\u001b[2;36m \u001b[0m\u001b[1;31mERROR \u001b[0m Error for `do` with \u001b]8;id=675640;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py:17\u001b\\\u001b[2m3146474900.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=769587;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py:17#inner:17\u001b\\\u001b[2minner:17\u001b[0m\u001b]8;;\u001b\\\n", + "\u001b[2;36m[08/23/24 17:48:03]\u001b[0m\u001b[2;36m \u001b[0m\u001b[1;31mERROR \u001b[0m Error for `do` with \u001b]8;id=270527;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py:30\u001b\\\u001b[2m1057038067.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=157819;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py:30#inner:30\u001b\\\u001b[2minner:30\u001b[0m\u001b]8;;\u001b\\\n", "\u001b[2;36m \u001b[0m \u001b[1;35margs\u001b[0m\u001b[1m(\u001b[0m\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m0\u001b[0m - \u001b[1;36m1\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m1\u001b[0m - \u001b[1;36m2\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m kwargs \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m c - \u001b[1;36m10\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[2m \u001b[0m\n", - "\u001b[2;36m \u001b[0m division by zero \u001b[2m \u001b[0m\n" + "\u001b[2;36m \u001b[0m ZeroDivisionError: division by zero \u001b[2m \u001b[0m\n" ] }, "metadata": {}, @@ -470,33 +510,40 @@ "assert x is None # tryy returns None by default" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Use your own default on failure" + ] + }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
[08/11/24 19:11:55] ERROR    Error for `do` with                                                                                                      3146474900.py:inner:17\n",
+       "
[08/23/24 17:48:04] ERROR    Error for `do` with                                                                                                      1057038067.py:inner:30\n",
        "                             args()                                                                                                                                         \n",
        "                               0 - 1 (🏷️ int)                                                                                                                                \n",
        "                               1 - 2 (🏷️ int)                                                                                                                                \n",
        "                             kwargs                                                                                                                                         \n",
        "                               c - 10 (🏷️ int)                                                                                                                               \n",
        "                                                                                                                                                                            \n",
-       "                             division by zero                                                                                                                               \n",
+       "                             ZeroDivisionError: division by zero                                                                                                            \n",
        "
\n" ], "text/plain": [ - "\u001b[2;36m[08/11/24 19:11:55]\u001b[0m\u001b[2;36m \u001b[0m\u001b[1;31mERROR \u001b[0m Error for `do` with \u001b]8;id=807965;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py:17\u001b\\\u001b[2m3146474900.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=923417;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py:17#inner:17\u001b\\\u001b[2minner:17\u001b[0m\u001b]8;;\u001b\\\n", + "\u001b[2;36m[08/23/24 17:48:04]\u001b[0m\u001b[2;36m \u001b[0m\u001b[1;31mERROR \u001b[0m Error for `do` with \u001b]8;id=550994;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py:30\u001b\\\u001b[2m1057038067.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=605547;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py:30#inner:30\u001b\\\u001b[2minner:30\u001b[0m\u001b]8;;\u001b\\\n", "\u001b[2;36m \u001b[0m \u001b[1;35margs\u001b[0m\u001b[1m(\u001b[0m\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m0\u001b[0m - \u001b[1;36m1\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m1\u001b[0m - \u001b[1;36m2\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m kwargs \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m c - \u001b[1;36m10\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[2m \u001b[0m\n", - "\u001b[2;36m \u001b[0m division by zero \u001b[2m \u001b[0m\n" + "\u001b[2;36m \u001b[0m ZeroDivisionError: division by zero \u001b[2m \u001b[0m\n" ] }, "metadata": {}, @@ -508,7 +555,7 @@ "'😔'" ] }, - "execution_count": 33, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -531,13 +578,13 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
[08/11/24 19:11:56] ERROR    Error for `do` with                                                                                                      3146474900.py:inner:17\n",
+       "
[08/23/24 17:48:06] ERROR    Error for `do` with                                                                                                      1057038067.py:inner:30\n",
        "                             args()                                                                                                                                         \n",
        "                               0 - 1 (🏷️ int)                                                                                                                                \n",
        "                               1 - 2 (🏷️ int)                                                                                                                                \n",
@@ -545,10 +592,10 @@
        "                               c - 10 (🏷️ int)                                                                                                                               \n",
        "                                                                                                                                                                            \n",
        "                             Traceback (most recent call last):                                                                                                             \n",
-       "                               File \"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py\", line 9, in inner                                      \n",
+       "                               File \"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py\", line 21, in inner                                     \n",
        "                                 return f(*args, **kwargs)                                                                                                                  \n",
        "                                        ^^^^^^^^^^^^^^^^^^                                                                                                                  \n",
-       "                               File \"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/2870377084.py\", line 3, in do                                         \n",
+       "                               File \"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/580638143.py\", line 3, in do                                          \n",
        "                                 return 1 / 0                                                                                                                               \n",
        "                                        ~~^~~                                                                                                                               \n",
        "                             ZeroDivisionError: division by zero                                                                                                            \n",
@@ -556,7 +603,7 @@
        "
\n" ], "text/plain": [ - "\u001b[2;36m[08/11/24 19:11:56]\u001b[0m\u001b[2;36m \u001b[0m\u001b[1;31mERROR \u001b[0m Error for `do` with \u001b]8;id=118525;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py:17\u001b\\\u001b[2m3146474900.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=56484;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py:17#inner:17\u001b\\\u001b[2minner:17\u001b[0m\u001b]8;;\u001b\\\n", + "\u001b[2;36m[08/23/24 17:48:06]\u001b[0m\u001b[2;36m \u001b[0m\u001b[1;31mERROR \u001b[0m Error for `do` with \u001b]8;id=430447;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py:30\u001b\\\u001b[2m1057038067.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=852031;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py:30#inner:30\u001b\\\u001b[2minner:30\u001b[0m\u001b]8;;\u001b\\\n", "\u001b[2;36m \u001b[0m \u001b[1;35margs\u001b[0m\u001b[1m(\u001b[0m\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m0\u001b[0m - \u001b[1;36m1\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[1;36m1\u001b[0m - \u001b[1;36m2\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", @@ -564,10 +611,10 @@ "\u001b[2;36m \u001b[0m c - \u001b[1;36m10\u001b[0m \u001b[1m(\u001b[0m🏷️ int\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m Traceback \u001b[1m(\u001b[0mmost recent call last\u001b[1m)\u001b[0m: \u001b[2m \u001b[0m\n", - "\u001b[2;36m \u001b[0m File \u001b[32m\"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/3146474900.py\"\u001b[0m, line \u001b[1;36m9\u001b[0m, in inner \u001b[2m \u001b[0m\n", + "\u001b[2;36m \u001b[0m File \u001b[32m\"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/1057038067.py\"\u001b[0m, line \u001b[1;36m21\u001b[0m, in inner \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m return \u001b[1;35mf\u001b[0m\u001b[1m(\u001b[0m*args, **kwargs\u001b[1m)\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m ^^^^^^^^^^^^^^^^^^ \u001b[2m \u001b[0m\n", - "\u001b[2;36m \u001b[0m File \u001b[32m\"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_21562/2870377084.py\"\u001b[0m, line \u001b[1;36m3\u001b[0m, in do \u001b[2m \u001b[0m\n", + "\u001b[2;36m \u001b[0m File \u001b[32m\"/var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_28490/580638143.py\"\u001b[0m, line \u001b[1;36m3\u001b[0m, in do \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m return \u001b[1;36m1\u001b[0m \u001b[35m/\u001b[0m \u001b[1;36m0\u001b[0m \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m ~~^~~ \u001b[2m \u001b[0m\n", "\u001b[2;36m \u001b[0m ZeroDivisionError: division by zero \u001b[2m \u001b[0m\n", @@ -583,7 +630,7 @@ "'😔'" ] }, - "execution_count": 34, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -597,9 +644,353 @@ "do(1, 2, c=10)" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can also silence the errors completely" + ] + }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 36, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'😔'" + ] + }, + "execution_count": 36, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "@tryy(silence_errors=True, output_to_return_on_fail=\"😔\")\n", + "def do(a, b, c):\n", + " return 1 / 0\n", + "\n", + "\n", + "do(1, 2, c=10)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "You can collect all your errors in a list" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[\n", + "```↯ AttrDict ↯\n", + "func - do (🏷️ str)\n", + "args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 8 (🏷️ int)\n", + "kwargs\n", + " c - 83 (🏷️ int)\n", + "tb - ZeroDivisionError: division by zero (🏷️ str)\n", + "err_type - ZeroDivisionError (🏷️ str)\n", + "\n", + "```\n", + ", \n", + "```↯ AttrDict ↯\n", + "func - do (🏷️ str)\n", + "args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 9 (🏷️ int)\n", + "kwargs\n", + " c - 88 (🏷️ int)\n", + "tb - ZeroDivisionError: division by zero (🏷️ str)\n", + "err_type - ZeroDivisionError (🏷️ str)\n", + "\n", + "```\n", + ", \n", + "```↯ AttrDict ↯\n", + "func - do (🏷️ str)\n", + "args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 3 (🏷️ int)\n", + "kwargs\n", + " c - 59 (🏷️ int)\n", + "tb - NotImplementedError: 🤔 (🏷️ str)\n", + "err_type - NotImplementedError (🏷️ str)\n", + "\n", + "```\n", + ", \n", + "```↯ AttrDict ↯\n", + "func - do (🏷️ str)\n", + "args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 6 (🏷️ int)\n", + "kwargs\n", + " c - 6 (🏷️ int)\n", + "tb - NotImplementedError: 🤔 (🏷️ str)\n", + "err_type - NotImplementedError (🏷️ str)\n", + "\n", + "```\n", + "]\n" + ] + } + ], + "source": [ + "import random\n", + "\n", + "errors = []\n", + "\n", + "\n", + "@tryy(silence_errors=True, store_errors=errors)\n", + "def do(a, b, c):\n", + " if random.randint(0, 100) < 50:\n", + " return 1 / 0\n", + " else:\n", + " raise NotImplementedError(\"🤔\")\n", + "\n", + "\n", + "for _ in range(4):\n", + " do(1, random.randint(0, 10), c=random.randint(0, 100))\n", + "\n", + "print(errors)" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "There's onlly one usecase where you would want to send in a list by yourself - when you want to append your errors to an existing list. The sensible default is to always store the errors, especially because this is a debugging tool.\n", + "\n", + "Just access all the errors in a dataframe like so" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
funcargskwargstberr_type
0do[1, 9]{'c': 4}ZeroDivisionError: division by zeroZeroDivisionError
1do[1, 6]{'c': 61}NotImplementedError: 🤔NotImplementedError
2do[1, 9]{'c': 1}ZeroDivisionError: division by zeroZeroDivisionError
3do[1, 3]{'c': 59}NotImplementedError: 🤔NotImplementedError
\n", + "
" + ], + "text/plain": [ + " func args kwargs tb \\\n", + "0 do [1, 9] {'c': 4} ZeroDivisionError: division by zero \n", + "1 do [1, 6] {'c': 61} NotImplementedError: 🤔 \n", + "2 do [1, 9] {'c': 1} ZeroDivisionError: division by zero \n", + "3 do [1, 3] {'c': 59} NotImplementedError: 🤔 \n", + "\n", + " err_type \n", + "0 ZeroDivisionError \n", + "1 NotImplementedError \n", + "2 ZeroDivisionError \n", + "3 NotImplementedError " + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "import random\n", + "\n", + "random.seed(10)\n", + "errors = []\n", + "\n", + "\n", + "@tryy(silence_errors=True, store_errors=errors, output_to_return_on_fail=\"😔\")\n", + "def do(a, b, c):\n", + " if c < 50:\n", + " return 1 / 0\n", + " else:\n", + " raise NotImplementedError(\"🤔\")\n", + "\n", + "\n", + "for _ in range(4):\n", + " do(1, random.randint(0, 10), c=random.randint(0, 100))\n", + "\n", + "do.error_summary()" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "and the actual list of errors like so" + ] + }, + { + "cell_type": "code", + "execution_count": 52, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[\n", + " ```↯ AttrDict ↯\n", + " func - do (🏷️ str)\n", + " args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 9 (🏷️ int)\n", + " kwargs\n", + " c - 4 (🏷️ int)\n", + " tb - ZeroDivisionError: division by zero (🏷️ str)\n", + " err_type - ZeroDivisionError (🏷️ str)\n", + " \n", + " ```,\n", + " \n", + " ```↯ AttrDict ↯\n", + " func - do (🏷️ str)\n", + " args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 6 (🏷️ int)\n", + " kwargs\n", + " c - 61 (🏷️ int)\n", + " tb - NotImplementedError: 🤔 (🏷️ str)\n", + " err_type - NotImplementedError (🏷️ str)\n", + " \n", + " ```,\n", + " \n", + " ```↯ AttrDict ↯\n", + " func - do (🏷️ str)\n", + " args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 9 (🏷️ int)\n", + " kwargs\n", + " c - 1 (🏷️ int)\n", + " tb - ZeroDivisionError: division by zero (🏷️ str)\n", + " err_type - ZeroDivisionError (🏷️ str)\n", + " \n", + " ```,\n", + " \n", + " ```↯ AttrDict ↯\n", + " func - do (🏷️ str)\n", + " args()\n", + " 0 - 1 (🏷️ int)\n", + " 1 - 3 (🏷️ int)\n", + " kwargs\n", + " c - 59 (🏷️ int)\n", + " tb - NotImplementedError: 🤔 (🏷️ str)\n", + " err_type - NotImplementedError (🏷️ str)\n", + " \n", + " ```]" + ] + }, + "execution_count": 52, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "do.error_store" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Finally, you want to run the function (without try) to reproduce the error and actually start debugging. Just use the `.F` attribute to access the original function that you created" + ] + }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": {}, + "outputs": [ + { + "ename": "ZeroDivisionError", + "evalue": "division by zero", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mZeroDivisionError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[51], line 3\u001b[0m\n\u001b[1;32m 1\u001b[0m ix \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m2\u001b[39m\n\u001b[1;32m 2\u001b[0m data \u001b[38;5;241m=\u001b[39m do\u001b[38;5;241m.\u001b[39merror_store[ix]\n\u001b[0;32m----> 3\u001b[0m \u001b[43mdo\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mF\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mdata\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mdata\u001b[49m\u001b[38;5;241;43m.\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "Cell \u001b[0;32mIn[49], line 9\u001b[0m, in \u001b[0;36mdo\u001b[0;34m(a, b, c)\u001b[0m\n\u001b[1;32m 6\u001b[0m \u001b[38;5;129m@tryy\u001b[39m(silence_errors\u001b[38;5;241m=\u001b[39m\u001b[38;5;28;01mTrue\u001b[39;00m, store_errors\u001b[38;5;241m=\u001b[39merrors, output_to_return_on_fail\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m😔\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n\u001b[1;32m 7\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mdo\u001b[39m(a, b, c):\n\u001b[1;32m 8\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m c \u001b[38;5;241m<\u001b[39m \u001b[38;5;241m50\u001b[39m:\n\u001b[0;32m----> 9\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[38;5;241;43m1\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m/\u001b[39;49m\u001b[43m \u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\n\u001b[1;32m 10\u001b[0m \u001b[38;5;28;01melse\u001b[39;00m:\n\u001b[1;32m 11\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m \u001b[38;5;167;01mNotImplementedError\u001b[39;00m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m🤔\u001b[39m\u001b[38;5;124m\"\u001b[39m)\n", + "\u001b[0;31mZeroDivisionError\u001b[0m: division by zero" + ] + } + ], + "source": [ + "ix = 2\n", + "data = do.error_store[ix]\n", + "do.F(*data.args, **data.kwargs)" + ] + }, + { + "cell_type": "code", + "execution_count": 13, "metadata": {}, "outputs": [], "source": [ @@ -628,7 +1019,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 14, "metadata": {}, "outputs": [], "source": [ @@ -640,7 +1031,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -658,7 +1049,7 @@ "7" ] }, - "execution_count": 19, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -675,9 +1066,31 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 16, "metadata": {}, - "outputs": [], + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "args kwargs\n", + "B new_param None\n" + ] + }, + { + "ename": "TypeError", + "evalue": "C() missing 3 required positional arguments: 'a', 'b', and 'c'", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)", + "Cell \u001b[0;32mIn[16], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;129;43m@B\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43mdeco_param\u001b[49m\u001b[38;5;241;43m=\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[38;5;124;43mnew_param\u001b[39;49m\u001b[38;5;124;43m\"\u001b[39;49m\u001b[43m)\u001b[49m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;43;01mdef\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[38;5;21;43mC\u001b[39;49m\u001b[43m(\u001b[49m\u001b[43ma\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mb\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[43mc\u001b[49m\u001b[43m)\u001b[49m\u001b[43m:\u001b[49m\n\u001b[1;32m 3\u001b[0m \u001b[43m \u001b[49m\u001b[38;5;28;43;01mreturn\u001b[39;49;00m\u001b[43m \u001b[49m\u001b[43ma\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m+\u001b[39;49m\u001b[43m \u001b[49m\u001b[43m(\u001b[49m\u001b[43mb\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43m \u001b[49m\u001b[43mc\u001b[49m\u001b[43m)\u001b[49m\n\u001b[1;32m 6\u001b[0m \u001b[38;5;66;03m# Testing\u001b[39;00m\n", + "Cell \u001b[0;32mIn[13], line 17\u001b[0m, in \u001b[0;36mdeco..wrapper..custom_decorator\u001b[0;34m(func)\u001b[0m\n\u001b[1;32m 16\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mcustom_decorator\u001b[39m(func):\n\u001b[0;32m---> 17\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mdecorator\u001b[49m\u001b[43m(\u001b[49m\u001b[43mfunc\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "Cell \u001b[0;32mIn[14], line 4\u001b[0m, in \u001b[0;36mB\u001b[0;34m(func, deco_param, *args, **kwargs)\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[38;5;129m@deco\u001b[39m\n\u001b[1;32m 2\u001b[0m \u001b[38;5;28;01mdef\u001b[39;00m \u001b[38;5;21mB\u001b[39m(func, \u001b[38;5;241m*\u001b[39margs, deco_param\u001b[38;5;241m=\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mdefault\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs):\n\u001b[1;32m 3\u001b[0m \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mB\u001b[39m\u001b[38;5;124m\"\u001b[39m, deco_param, \u001b[38;5;28mprint\u001b[39m(\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124margs\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;241m*\u001b[39margs, \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mkwargs\u001b[39m\u001b[38;5;124m\"\u001b[39m, \u001b[38;5;241m*\u001b[39m\u001b[38;5;241m*\u001b[39mkwargs))\n\u001b[0;32m----> 4\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m \u001b[43mfunc\u001b[49m\u001b[43m(\u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43margs\u001b[49m\u001b[43m,\u001b[49m\u001b[43m \u001b[49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[38;5;241;43m*\u001b[39;49m\u001b[43mkwargs\u001b[49m\u001b[43m)\u001b[49m\n", + "\u001b[0;31mTypeError\u001b[0m: C() missing 3 required positional arguments: 'a', 'b', and 'c'" + ] + } + ], "source": [ "@B(deco_param=\"new_param\")\n", "def C(a, b, c):\n", diff --git a/scripts.ipynb b/scripts.ipynb index ff745fe..d67b0c3 100644 --- a/scripts.ipynb +++ b/scripts.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 8, + "execution_count": 1, "metadata": {}, "outputs": [ { @@ -14,141 +14,141 @@ "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/bokeh_loader.py\u001b[0m\n", "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/load_defaults.py\u001b[0m\n", "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/decorators.py\u001b[0m\n", - "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/misc.py\u001b[0m\n", "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/inspector.py\u001b[0m\n", "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/pdf_loader.py\u001b[0m\n", + "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/imgaug_loader.py\u001b[0m\n", + "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/misc.py\u001b[0m\n", "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/adapters.py\u001b[0m\n", "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/registry.py\u001b[0m\n", "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/trainer/config.py\u001b[0m\n", - "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/ipython.py\u001b[0m\n", - "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/logger.py\u001b[0m\n", - "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/imgaug_loader.py\u001b[0m\n", "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/interactive_show.py\u001b[0m\n", + "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/logger.py\u001b[0m\n", "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/sklegos.py\u001b[0m\n", "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/trainer/capsule.py\u001b[0m\n", + "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/ipython.py\u001b[0m\n", "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/charts.py\u001b[0m\n", "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/bb_utils.py\u001b[0m\n", - "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/markup.py\u001b[0m\n", "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/paths.py\u001b[0m\n", + "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/markup.py\u001b[0m\n", "\u001b[1mreformatted /Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/_modidx.py\u001b[0m\n", "\n", "\u001b[1mAll done! ✨ 🍰 ✨\u001b[0m\n", "\u001b[34m\u001b[1m20 files \u001b[0m\u001b[1mreformatted\u001b[0m, \u001b[34m18 files \u001b[0mleft unchanged.\n", "Obtaining file:///Users/yeshwanth/Code/Personal/torch_snippets\n", " Preparing metadata (setup.py) ... \u001b[?25ldone\n", - "\u001b[?25hRequirement already satisfied: fastcore in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (1.5.54)\n", - "Requirement already satisfied: matplotlib in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (3.9.1)\n", - "Requirement already satisfied: Pillow in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (10.4.0)\n", - "Requirement already satisfied: altair in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (5.3.0)\n", - "Requirement already satisfied: dill in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (0.3.8)\n", - "Requirement already satisfied: ipython in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (8.26.0)\n", - "Requirement already satisfied: loguru in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (0.7.2)\n", - "Requirement already satisfied: numpy in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (2.0.1)\n", - "Requirement already satisfied: pandas in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (2.2.2)\n", - "Requirement already satisfied: tqdm in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (4.66.4)\n", - "Requirement already satisfied: rich in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (13.7.1)\n", - "Requirement already satisfied: PyYAML in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (6.0.1)\n", - "Requirement already satisfied: catalogue in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (2.0.10)\n", - "Requirement already satisfied: confection in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (0.1.5)\n", - "Requirement already satisfied: pydantic in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (2.8.2)\n", - "Requirement already satisfied: typing in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (3.7.4.3)\n", - "Requirement already satisfied: srsly in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (2.4.8)\n", - "Requirement already satisfied: typing_extensions in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (4.12.2)\n", - "Requirement already satisfied: wasabi in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (1.1.3)\n", - "Requirement already satisfied: jsonlines in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (4.0.0)\n", - "Requirement already satisfied: imgaug>=0.4.0 in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (0.4.0)\n", - "Requirement already satisfied: xmltodict in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (0.13.0)\n", - "Requirement already satisfied: fuzzywuzzy in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (0.18.0)\n", - "Requirement already satisfied: scikit-learn in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (1.5.1)\n", - "Requirement already satisfied: nltk in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (3.8.1)\n", - "Requirement already satisfied: python-Levenshtein in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (0.25.1)\n", - "Requirement already satisfied: pre-commit in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (3.7.1)\n", - "Requirement already satisfied: pymupdf in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (1.24.9)\n", - "Requirement already satisfied: nbconvert in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (7.16.4)\n", - "Requirement already satisfied: nbformat in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (5.10.4)\n", - "Requirement already satisfied: icecream in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (2.1.3)\n", - "Requirement already satisfied: mergedeep in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.536) (1.3.4)\n", - "Requirement already satisfied: six in /opt/miniconda3/lib/python3.12/site-packages (from imgaug>=0.4.0->torch_snippets==0.536) (1.16.0)\n", - "Requirement already satisfied: scipy in /opt/miniconda3/lib/python3.12/site-packages (from imgaug>=0.4.0->torch_snippets==0.536) (1.14.0)\n", - "Requirement already satisfied: scikit-image>=0.14.2 in /opt/miniconda3/lib/python3.12/site-packages (from imgaug>=0.4.0->torch_snippets==0.536) (0.24.0)\n", - "Requirement already satisfied: opencv-python in /opt/miniconda3/lib/python3.12/site-packages (from imgaug>=0.4.0->torch_snippets==0.536) (4.10.0.84)\n", - "Requirement already satisfied: imageio in /opt/miniconda3/lib/python3.12/site-packages (from imgaug>=0.4.0->torch_snippets==0.536) (2.34.2)\n", - "Requirement already satisfied: Shapely in /opt/miniconda3/lib/python3.12/site-packages (from imgaug>=0.4.0->torch_snippets==0.536) (2.0.5)\n", - "Requirement already satisfied: jinja2 in /opt/miniconda3/lib/python3.12/site-packages (from altair->torch_snippets==0.536) (3.1.4)\n", - "Requirement already satisfied: jsonschema>=3.0 in /opt/miniconda3/lib/python3.12/site-packages (from altair->torch_snippets==0.536) (4.23.0)\n", - "Requirement already satisfied: packaging in /opt/miniconda3/lib/python3.12/site-packages (from altair->torch_snippets==0.536) (23.2)\n", - "Requirement already satisfied: toolz in /opt/miniconda3/lib/python3.12/site-packages (from altair->torch_snippets==0.536) (0.12.1)\n", - "Requirement already satisfied: python-dateutil>=2.8.2 in /opt/miniconda3/lib/python3.12/site-packages (from pandas->torch_snippets==0.536) (2.9.0.post0)\n", - "Requirement already satisfied: pytz>=2020.1 in /opt/miniconda3/lib/python3.12/site-packages (from pandas->torch_snippets==0.536) (2024.1)\n", - "Requirement already satisfied: tzdata>=2022.7 in /opt/miniconda3/lib/python3.12/site-packages (from pandas->torch_snippets==0.536) (2024.1)\n", - "Requirement already satisfied: annotated-types>=0.4.0 in /opt/miniconda3/lib/python3.12/site-packages (from pydantic->torch_snippets==0.536) (0.7.0)\n", - "Requirement already satisfied: pydantic-core==2.20.1 in /opt/miniconda3/lib/python3.12/site-packages (from pydantic->torch_snippets==0.536) (2.20.1)\n", - "Requirement already satisfied: colorama>=0.3.9 in /opt/miniconda3/lib/python3.12/site-packages (from icecream->torch_snippets==0.536) (0.4.6)\n", - "Requirement already satisfied: pygments>=2.2.0 in /opt/miniconda3/lib/python3.12/site-packages (from icecream->torch_snippets==0.536) (2.18.0)\n", - "Requirement already satisfied: executing>=0.3.1 in /opt/miniconda3/lib/python3.12/site-packages (from icecream->torch_snippets==0.536) (2.0.1)\n", - "Requirement already satisfied: asttokens>=2.0.1 in /opt/miniconda3/lib/python3.12/site-packages (from icecream->torch_snippets==0.536) (2.4.1)\n", - "Requirement already satisfied: decorator in /opt/miniconda3/lib/python3.12/site-packages (from ipython->torch_snippets==0.536) (5.1.1)\n", - "Requirement already satisfied: jedi>=0.16 in /opt/miniconda3/lib/python3.12/site-packages (from ipython->torch_snippets==0.536) (0.19.1)\n", - "Requirement already satisfied: matplotlib-inline in /opt/miniconda3/lib/python3.12/site-packages (from ipython->torch_snippets==0.536) (0.1.7)\n", - "Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in /opt/miniconda3/lib/python3.12/site-packages (from ipython->torch_snippets==0.536) (3.0.47)\n", - "Requirement already satisfied: stack-data in /opt/miniconda3/lib/python3.12/site-packages (from ipython->torch_snippets==0.536) (0.6.3)\n", - "Requirement already satisfied: traitlets>=5.13.0 in /opt/miniconda3/lib/python3.12/site-packages (from ipython->torch_snippets==0.536) (5.14.3)\n", - "Requirement already satisfied: pexpect>4.3 in /opt/miniconda3/lib/python3.12/site-packages (from ipython->torch_snippets==0.536) (4.9.0)\n", - "Requirement already satisfied: attrs>=19.2.0 in /opt/miniconda3/lib/python3.12/site-packages (from jsonlines->torch_snippets==0.536) (23.2.0)\n", - "Requirement already satisfied: contourpy>=1.0.1 in /opt/miniconda3/lib/python3.12/site-packages (from matplotlib->torch_snippets==0.536) (1.2.1)\n", - "Requirement already satisfied: cycler>=0.10 in /opt/miniconda3/lib/python3.12/site-packages (from matplotlib->torch_snippets==0.536) (0.12.1)\n", - "Requirement already satisfied: fonttools>=4.22.0 in /opt/miniconda3/lib/python3.12/site-packages (from matplotlib->torch_snippets==0.536) (4.53.1)\n", - "Requirement already satisfied: kiwisolver>=1.3.1 in /opt/miniconda3/lib/python3.12/site-packages (from matplotlib->torch_snippets==0.536) (1.4.5)\n", - "Requirement already satisfied: pyparsing>=2.3.1 in /opt/miniconda3/lib/python3.12/site-packages (from matplotlib->torch_snippets==0.536) (3.1.2)\n", - "Requirement already satisfied: beautifulsoup4 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.536) (4.12.3)\n", - "Requirement already satisfied: bleach!=5.0.0 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.536) (6.1.0)\n", - "Requirement already satisfied: defusedxml in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.536) (0.7.1)\n", - "Requirement already satisfied: jupyter-core>=4.7 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.536) (5.7.2)\n", - "Requirement already satisfied: jupyterlab-pygments in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.536) (0.3.0)\n", - "Requirement already satisfied: markupsafe>=2.0 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.536) (2.1.5)\n", - "Requirement already satisfied: mistune<4,>=2.0.3 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.536) (3.0.2)\n", - "Requirement already satisfied: nbclient>=0.5.0 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.536) (0.10.0)\n", - "Requirement already satisfied: pandocfilters>=1.4.1 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.536) (1.5.1)\n", - "Requirement already satisfied: tinycss2 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.536) (1.3.0)\n", - "Requirement already satisfied: fastjsonschema>=2.15 in /opt/miniconda3/lib/python3.12/site-packages (from nbformat->torch_snippets==0.536) (2.20.0)\n", - "Requirement already satisfied: click in /opt/miniconda3/lib/python3.12/site-packages (from nltk->torch_snippets==0.536) (8.1.7)\n", - "Requirement already satisfied: joblib in /opt/miniconda3/lib/python3.12/site-packages (from nltk->torch_snippets==0.536) (1.4.2)\n", - "Requirement already satisfied: regex>=2021.8.3 in /opt/miniconda3/lib/python3.12/site-packages (from nltk->torch_snippets==0.536) (2024.7.24)\n", - "Requirement already satisfied: cfgv>=2.0.0 in /opt/miniconda3/lib/python3.12/site-packages (from pre-commit->torch_snippets==0.536) (3.4.0)\n", - "Requirement already satisfied: identify>=1.0.0 in /opt/miniconda3/lib/python3.12/site-packages (from pre-commit->torch_snippets==0.536) (2.6.0)\n", - "Requirement already satisfied: nodeenv>=0.11.1 in /opt/miniconda3/lib/python3.12/site-packages (from pre-commit->torch_snippets==0.536) (1.9.1)\n", - "Requirement already satisfied: virtualenv>=20.10.0 in /opt/miniconda3/lib/python3.12/site-packages (from pre-commit->torch_snippets==0.536) (20.26.3)\n", - "Requirement already satisfied: PyMuPDFb==1.24.9 in /opt/miniconda3/lib/python3.12/site-packages (from pymupdf->torch_snippets==0.536) (1.24.9)\n", - "Requirement already satisfied: Levenshtein==0.25.1 in /opt/miniconda3/lib/python3.12/site-packages (from python-Levenshtein->torch_snippets==0.536) (0.25.1)\n", - "Requirement already satisfied: rapidfuzz<4.0.0,>=3.8.0 in /opt/miniconda3/lib/python3.12/site-packages (from Levenshtein==0.25.1->python-Levenshtein->torch_snippets==0.536) (3.9.4)\n", - "Requirement already satisfied: markdown-it-py>=2.2.0 in /opt/miniconda3/lib/python3.12/site-packages (from rich->torch_snippets==0.536) (3.0.0)\n", - "Requirement already satisfied: threadpoolctl>=3.1.0 in /opt/miniconda3/lib/python3.12/site-packages (from scikit-learn->torch_snippets==0.536) (3.5.0)\n", - "Requirement already satisfied: webencodings in /opt/miniconda3/lib/python3.12/site-packages (from bleach!=5.0.0->nbconvert->torch_snippets==0.536) (0.5.1)\n", - "Requirement already satisfied: parso<0.9.0,>=0.8.3 in /opt/miniconda3/lib/python3.12/site-packages (from jedi>=0.16->ipython->torch_snippets==0.536) (0.8.4)\n", - "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /opt/miniconda3/lib/python3.12/site-packages (from jsonschema>=3.0->altair->torch_snippets==0.536) (2023.12.1)\n", - "Requirement already satisfied: referencing>=0.28.4 in /opt/miniconda3/lib/python3.12/site-packages (from jsonschema>=3.0->altair->torch_snippets==0.536) (0.35.1)\n", - "Requirement already satisfied: rpds-py>=0.7.1 in /opt/miniconda3/lib/python3.12/site-packages (from jsonschema>=3.0->altair->torch_snippets==0.536) (0.19.0)\n", - "Requirement already satisfied: platformdirs>=2.5 in /opt/miniconda3/lib/python3.12/site-packages (from jupyter-core>=4.7->nbconvert->torch_snippets==0.536) (3.10.0)\n", - "Requirement already satisfied: mdurl~=0.1 in /opt/miniconda3/lib/python3.12/site-packages (from markdown-it-py>=2.2.0->rich->torch_snippets==0.536) (0.1.2)\n", - "Requirement already satisfied: jupyter-client>=6.1.12 in /opt/miniconda3/lib/python3.12/site-packages (from nbclient>=0.5.0->nbconvert->torch_snippets==0.536) (8.6.2)\n", - "Requirement already satisfied: ptyprocess>=0.5 in /opt/miniconda3/lib/python3.12/site-packages (from pexpect>4.3->ipython->torch_snippets==0.536) (0.7.0)\n", - "Requirement already satisfied: wcwidth in /opt/miniconda3/lib/python3.12/site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython->torch_snippets==0.536) (0.2.13)\n", - "Requirement already satisfied: networkx>=2.8 in /opt/miniconda3/lib/python3.12/site-packages (from scikit-image>=0.14.2->imgaug>=0.4.0->torch_snippets==0.536) (3.3)\n", - "Requirement already satisfied: tifffile>=2022.8.12 in /opt/miniconda3/lib/python3.12/site-packages (from scikit-image>=0.14.2->imgaug>=0.4.0->torch_snippets==0.536) (2024.7.24)\n", - "Requirement already satisfied: lazy-loader>=0.4 in /opt/miniconda3/lib/python3.12/site-packages (from scikit-image>=0.14.2->imgaug>=0.4.0->torch_snippets==0.536) (0.4)\n", - "Requirement already satisfied: distlib<1,>=0.3.7 in /opt/miniconda3/lib/python3.12/site-packages (from virtualenv>=20.10.0->pre-commit->torch_snippets==0.536) (0.3.8)\n", - "Requirement already satisfied: filelock<4,>=3.12.2 in /opt/miniconda3/lib/python3.12/site-packages (from virtualenv>=20.10.0->pre-commit->torch_snippets==0.536) (3.15.4)\n", - "Requirement already satisfied: soupsieve>1.2 in /opt/miniconda3/lib/python3.12/site-packages (from beautifulsoup4->nbconvert->torch_snippets==0.536) (2.5)\n", - "Requirement already satisfied: pure-eval in /opt/miniconda3/lib/python3.12/site-packages (from stack-data->ipython->torch_snippets==0.536) (0.2.3)\n", - "Requirement already satisfied: pyzmq>=23.0 in /opt/miniconda3/lib/python3.12/site-packages (from jupyter-client>=6.1.12->nbclient>=0.5.0->nbconvert->torch_snippets==0.536) (26.0.3)\n", - "Requirement already satisfied: tornado>=6.2 in /opt/miniconda3/lib/python3.12/site-packages (from jupyter-client>=6.1.12->nbclient>=0.5.0->nbconvert->torch_snippets==0.536) (6.4.1)\n", + "\u001b[?25hRequirement already satisfied: fastcore in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (1.6.3)\n", + "Requirement already satisfied: matplotlib in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (3.9.1)\n", + "Requirement already satisfied: Pillow in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (10.4.0)\n", + "Requirement already satisfied: altair in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (5.3.0)\n", + "Requirement already satisfied: dill in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (0.3.8)\n", + "Requirement already satisfied: ipython in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (8.26.0)\n", + "Requirement already satisfied: loguru in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (0.7.2)\n", + "Requirement already satisfied: numpy in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (2.0.1)\n", + "Requirement already satisfied: pandas in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (2.2.2)\n", + "Requirement already satisfied: tqdm in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (4.66.4)\n", + "Requirement already satisfied: rich in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (13.7.1)\n", + "Requirement already satisfied: PyYAML in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (6.0.1)\n", + "Requirement already satisfied: catalogue in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (2.0.10)\n", + "Requirement already satisfied: confection in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (0.1.5)\n", + "Requirement already satisfied: pydantic in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (2.8.2)\n", + "Requirement already satisfied: typing in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (3.7.4.3)\n", + "Requirement already satisfied: srsly in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (2.4.8)\n", + "Requirement already satisfied: typing_extensions in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (4.12.2)\n", + "Requirement already satisfied: wasabi in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (1.1.3)\n", + "Requirement already satisfied: jsonlines in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (4.0.0)\n", + "Requirement already satisfied: imgaug>=0.4.0 in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (0.4.0)\n", + "Requirement already satisfied: xmltodict in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (0.13.0)\n", + "Requirement already satisfied: fuzzywuzzy in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (0.18.0)\n", + "Requirement already satisfied: scikit-learn in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (1.5.1)\n", + "Requirement already satisfied: nltk in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (3.8.1)\n", + "Requirement already satisfied: python-Levenshtein in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (0.25.1)\n", + "Requirement already satisfied: pre-commit in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (3.7.1)\n", + "Requirement already satisfied: pymupdf in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (1.24.9)\n", + "Requirement already satisfied: nbconvert in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (7.16.4)\n", + "Requirement already satisfied: nbformat in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (5.10.4)\n", + "Requirement already satisfied: icecream in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (2.1.3)\n", + "Requirement already satisfied: mergedeep in /opt/miniconda3/lib/python3.12/site-packages (from torch_snippets==0.538.1) (1.3.4)\n", + "Requirement already satisfied: six in /opt/miniconda3/lib/python3.12/site-packages (from imgaug>=0.4.0->torch_snippets==0.538.1) (1.16.0)\n", + "Requirement already satisfied: scipy in /opt/miniconda3/lib/python3.12/site-packages (from imgaug>=0.4.0->torch_snippets==0.538.1) (1.14.0)\n", + "Requirement already satisfied: scikit-image>=0.14.2 in /opt/miniconda3/lib/python3.12/site-packages (from imgaug>=0.4.0->torch_snippets==0.538.1) (0.24.0)\n", + "Requirement already satisfied: opencv-python in /opt/miniconda3/lib/python3.12/site-packages (from imgaug>=0.4.0->torch_snippets==0.538.1) (4.10.0.84)\n", + "Requirement already satisfied: imageio in /opt/miniconda3/lib/python3.12/site-packages (from imgaug>=0.4.0->torch_snippets==0.538.1) (2.34.2)\n", + "Requirement already satisfied: Shapely in /opt/miniconda3/lib/python3.12/site-packages (from imgaug>=0.4.0->torch_snippets==0.538.1) (2.0.5)\n", + "Requirement already satisfied: jinja2 in /opt/miniconda3/lib/python3.12/site-packages (from altair->torch_snippets==0.538.1) (3.1.4)\n", + "Requirement already satisfied: jsonschema>=3.0 in /opt/miniconda3/lib/python3.12/site-packages (from altair->torch_snippets==0.538.1) (4.23.0)\n", + "Requirement already satisfied: packaging in /opt/miniconda3/lib/python3.12/site-packages (from altair->torch_snippets==0.538.1) (23.2)\n", + "Requirement already satisfied: toolz in /opt/miniconda3/lib/python3.12/site-packages (from altair->torch_snippets==0.538.1) (0.12.1)\n", + "Requirement already satisfied: python-dateutil>=2.8.2 in /opt/miniconda3/lib/python3.12/site-packages (from pandas->torch_snippets==0.538.1) (2.9.0.post0)\n", + "Requirement already satisfied: pytz>=2020.1 in /opt/miniconda3/lib/python3.12/site-packages (from pandas->torch_snippets==0.538.1) (2024.1)\n", + "Requirement already satisfied: tzdata>=2022.7 in /opt/miniconda3/lib/python3.12/site-packages (from pandas->torch_snippets==0.538.1) (2024.1)\n", + "Requirement already satisfied: annotated-types>=0.4.0 in /opt/miniconda3/lib/python3.12/site-packages (from pydantic->torch_snippets==0.538.1) (0.7.0)\n", + "Requirement already satisfied: pydantic-core==2.20.1 in /opt/miniconda3/lib/python3.12/site-packages (from pydantic->torch_snippets==0.538.1) (2.20.1)\n", + "Requirement already satisfied: colorama>=0.3.9 in /opt/miniconda3/lib/python3.12/site-packages (from icecream->torch_snippets==0.538.1) (0.4.6)\n", + "Requirement already satisfied: pygments>=2.2.0 in /opt/miniconda3/lib/python3.12/site-packages (from icecream->torch_snippets==0.538.1) (2.18.0)\n", + "Requirement already satisfied: executing>=0.3.1 in /opt/miniconda3/lib/python3.12/site-packages (from icecream->torch_snippets==0.538.1) (2.0.1)\n", + "Requirement already satisfied: asttokens>=2.0.1 in /opt/miniconda3/lib/python3.12/site-packages (from icecream->torch_snippets==0.538.1) (2.4.1)\n", + "Requirement already satisfied: decorator in /opt/miniconda3/lib/python3.12/site-packages (from ipython->torch_snippets==0.538.1) (5.1.1)\n", + "Requirement already satisfied: jedi>=0.16 in /opt/miniconda3/lib/python3.12/site-packages (from ipython->torch_snippets==0.538.1) (0.19.1)\n", + "Requirement already satisfied: matplotlib-inline in /opt/miniconda3/lib/python3.12/site-packages (from ipython->torch_snippets==0.538.1) (0.1.7)\n", + "Requirement already satisfied: prompt-toolkit<3.1.0,>=3.0.41 in /opt/miniconda3/lib/python3.12/site-packages (from ipython->torch_snippets==0.538.1) (3.0.47)\n", + "Requirement already satisfied: stack-data in /opt/miniconda3/lib/python3.12/site-packages (from ipython->torch_snippets==0.538.1) (0.6.3)\n", + "Requirement already satisfied: traitlets>=5.13.0 in /opt/miniconda3/lib/python3.12/site-packages (from ipython->torch_snippets==0.538.1) (5.14.3)\n", + "Requirement already satisfied: pexpect>4.3 in /opt/miniconda3/lib/python3.12/site-packages (from ipython->torch_snippets==0.538.1) (4.9.0)\n", + "Requirement already satisfied: attrs>=19.2.0 in /opt/miniconda3/lib/python3.12/site-packages (from jsonlines->torch_snippets==0.538.1) (23.2.0)\n", + "Requirement already satisfied: contourpy>=1.0.1 in /opt/miniconda3/lib/python3.12/site-packages (from matplotlib->torch_snippets==0.538.1) (1.2.1)\n", + "Requirement already satisfied: cycler>=0.10 in /opt/miniconda3/lib/python3.12/site-packages (from matplotlib->torch_snippets==0.538.1) (0.12.1)\n", + "Requirement already satisfied: fonttools>=4.22.0 in /opt/miniconda3/lib/python3.12/site-packages (from matplotlib->torch_snippets==0.538.1) (4.53.1)\n", + "Requirement already satisfied: kiwisolver>=1.3.1 in /opt/miniconda3/lib/python3.12/site-packages (from matplotlib->torch_snippets==0.538.1) (1.4.5)\n", + "Requirement already satisfied: pyparsing>=2.3.1 in /opt/miniconda3/lib/python3.12/site-packages (from matplotlib->torch_snippets==0.538.1) (3.1.2)\n", + "Requirement already satisfied: beautifulsoup4 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.538.1) (4.12.3)\n", + "Requirement already satisfied: bleach!=5.0.0 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.538.1) (6.1.0)\n", + "Requirement already satisfied: defusedxml in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.538.1) (0.7.1)\n", + "Requirement already satisfied: jupyter-core>=4.7 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.538.1) (5.7.2)\n", + "Requirement already satisfied: jupyterlab-pygments in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.538.1) (0.3.0)\n", + "Requirement already satisfied: markupsafe>=2.0 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.538.1) (2.1.5)\n", + "Requirement already satisfied: mistune<4,>=2.0.3 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.538.1) (3.0.2)\n", + "Requirement already satisfied: nbclient>=0.5.0 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.538.1) (0.10.0)\n", + "Requirement already satisfied: pandocfilters>=1.4.1 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.538.1) (1.5.1)\n", + "Requirement already satisfied: tinycss2 in /opt/miniconda3/lib/python3.12/site-packages (from nbconvert->torch_snippets==0.538.1) (1.3.0)\n", + "Requirement already satisfied: fastjsonschema>=2.15 in /opt/miniconda3/lib/python3.12/site-packages (from nbformat->torch_snippets==0.538.1) (2.20.0)\n", + "Requirement already satisfied: click in /opt/miniconda3/lib/python3.12/site-packages (from nltk->torch_snippets==0.538.1) (8.1.7)\n", + "Requirement already satisfied: joblib in /opt/miniconda3/lib/python3.12/site-packages (from nltk->torch_snippets==0.538.1) (1.4.2)\n", + "Requirement already satisfied: regex>=2021.8.3 in /opt/miniconda3/lib/python3.12/site-packages (from nltk->torch_snippets==0.538.1) (2024.7.24)\n", + "Requirement already satisfied: cfgv>=2.0.0 in /opt/miniconda3/lib/python3.12/site-packages (from pre-commit->torch_snippets==0.538.1) (3.4.0)\n", + "Requirement already satisfied: identify>=1.0.0 in /opt/miniconda3/lib/python3.12/site-packages (from pre-commit->torch_snippets==0.538.1) (2.6.0)\n", + "Requirement already satisfied: nodeenv>=0.11.1 in /opt/miniconda3/lib/python3.12/site-packages (from pre-commit->torch_snippets==0.538.1) (1.9.1)\n", + "Requirement already satisfied: virtualenv>=20.10.0 in /opt/miniconda3/lib/python3.12/site-packages (from pre-commit->torch_snippets==0.538.1) (20.26.3)\n", + "Requirement already satisfied: PyMuPDFb==1.24.9 in /opt/miniconda3/lib/python3.12/site-packages (from pymupdf->torch_snippets==0.538.1) (1.24.9)\n", + "Requirement already satisfied: Levenshtein==0.25.1 in /opt/miniconda3/lib/python3.12/site-packages (from python-Levenshtein->torch_snippets==0.538.1) (0.25.1)\n", + "Requirement already satisfied: rapidfuzz<4.0.0,>=3.8.0 in /opt/miniconda3/lib/python3.12/site-packages (from Levenshtein==0.25.1->python-Levenshtein->torch_snippets==0.538.1) (3.9.4)\n", + "Requirement already satisfied: markdown-it-py>=2.2.0 in /opt/miniconda3/lib/python3.12/site-packages (from rich->torch_snippets==0.538.1) (3.0.0)\n", + "Requirement already satisfied: threadpoolctl>=3.1.0 in /opt/miniconda3/lib/python3.12/site-packages (from scikit-learn->torch_snippets==0.538.1) (3.5.0)\n", + "Requirement already satisfied: webencodings in /opt/miniconda3/lib/python3.12/site-packages (from bleach!=5.0.0->nbconvert->torch_snippets==0.538.1) (0.5.1)\n", + "Requirement already satisfied: parso<0.9.0,>=0.8.3 in /opt/miniconda3/lib/python3.12/site-packages (from jedi>=0.16->ipython->torch_snippets==0.538.1) (0.8.4)\n", + "Requirement already satisfied: jsonschema-specifications>=2023.03.6 in /opt/miniconda3/lib/python3.12/site-packages (from jsonschema>=3.0->altair->torch_snippets==0.538.1) (2023.12.1)\n", + "Requirement already satisfied: referencing>=0.28.4 in /opt/miniconda3/lib/python3.12/site-packages (from jsonschema>=3.0->altair->torch_snippets==0.538.1) (0.35.1)\n", + "Requirement already satisfied: rpds-py>=0.7.1 in /opt/miniconda3/lib/python3.12/site-packages (from jsonschema>=3.0->altair->torch_snippets==0.538.1) (0.19.0)\n", + "Requirement already satisfied: platformdirs>=2.5 in /opt/miniconda3/lib/python3.12/site-packages (from jupyter-core>=4.7->nbconvert->torch_snippets==0.538.1) (3.10.0)\n", + "Requirement already satisfied: mdurl~=0.1 in /opt/miniconda3/lib/python3.12/site-packages (from markdown-it-py>=2.2.0->rich->torch_snippets==0.538.1) (0.1.2)\n", + "Requirement already satisfied: jupyter-client>=6.1.12 in /opt/miniconda3/lib/python3.12/site-packages (from nbclient>=0.5.0->nbconvert->torch_snippets==0.538.1) (8.6.2)\n", + "Requirement already satisfied: ptyprocess>=0.5 in /opt/miniconda3/lib/python3.12/site-packages (from pexpect>4.3->ipython->torch_snippets==0.538.1) (0.7.0)\n", + "Requirement already satisfied: wcwidth in /opt/miniconda3/lib/python3.12/site-packages (from prompt-toolkit<3.1.0,>=3.0.41->ipython->torch_snippets==0.538.1) (0.2.13)\n", + "Requirement already satisfied: networkx>=2.8 in /opt/miniconda3/lib/python3.12/site-packages (from scikit-image>=0.14.2->imgaug>=0.4.0->torch_snippets==0.538.1) (3.3)\n", + "Requirement already satisfied: tifffile>=2022.8.12 in /opt/miniconda3/lib/python3.12/site-packages (from scikit-image>=0.14.2->imgaug>=0.4.0->torch_snippets==0.538.1) (2024.7.24)\n", + "Requirement already satisfied: lazy-loader>=0.4 in /opt/miniconda3/lib/python3.12/site-packages (from scikit-image>=0.14.2->imgaug>=0.4.0->torch_snippets==0.538.1) (0.4)\n", + "Requirement already satisfied: distlib<1,>=0.3.7 in /opt/miniconda3/lib/python3.12/site-packages (from virtualenv>=20.10.0->pre-commit->torch_snippets==0.538.1) (0.3.8)\n", + "Requirement already satisfied: filelock<4,>=3.12.2 in /opt/miniconda3/lib/python3.12/site-packages (from virtualenv>=20.10.0->pre-commit->torch_snippets==0.538.1) (3.15.4)\n", + "Requirement already satisfied: soupsieve>1.2 in /opt/miniconda3/lib/python3.12/site-packages (from beautifulsoup4->nbconvert->torch_snippets==0.538.1) (2.5)\n", + "Requirement already satisfied: pure-eval in /opt/miniconda3/lib/python3.12/site-packages (from stack-data->ipython->torch_snippets==0.538.1) (0.2.3)\n", + "Requirement already satisfied: pyzmq>=23.0 in /opt/miniconda3/lib/python3.12/site-packages (from jupyter-client>=6.1.12->nbclient>=0.5.0->nbconvert->torch_snippets==0.538.1) (26.0.3)\n", + "Requirement already satisfied: tornado>=6.2 in /opt/miniconda3/lib/python3.12/site-packages (from jupyter-client>=6.1.12->nbclient>=0.5.0->nbconvert->torch_snippets==0.538.1) (6.4.1)\n", "Installing collected packages: torch_snippets\n", " Attempting uninstall: torch_snippets\n", - " Found existing installation: torch_snippets 0.536\n", - " Uninstalling torch_snippets-0.536:\n", - " Successfully uninstalled torch_snippets-0.536\n", + " Found existing installation: torch_snippets 0.538\n", + " Uninstalling torch_snippets-0.538:\n", + " Successfully uninstalled torch_snippets-0.538\n", " Running setup.py develop for torch_snippets\n", - "Successfully installed torch_snippets-0.536\n", + "Successfully installed torch_snippets-0.538.1\n", "Note: you may need to restart the kernel to use updated packages.\n" ] } @@ -162,17 +162,32 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ - "
[07/25/24 07:18:20] INFO     loaded 25 lines                                                                                                        4135304039.py::3\" target=\"_blank\"><module>:3\n",
+       "
[08/17/24 12:55:12] WARNING  Unable to load torch and dependent libraries from torch-snippets.                                                        loader.py::108\" target=\"_blank\"><module>:108\n",
+       "                             Functionalities might be limited. pip install lovely-tensors in case there are torch related errors                                            \n",
+       "
\n" + ], + "text/plain": [ + "\u001b[2;36m[08/17/24 12:55:12]\u001b[0m\u001b[2;36m \u001b[0m\u001b[2;31mWARNING \u001b[0m Unable to load torch and dependent libraries from torch-snippets. \u001b]8;id=186562;file:///Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/loader.py:108\u001b\\\u001b[2mloader.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=522368;file:///Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/loader.py:108#:108\u001b\\\u001b[2m:108\u001b[0m\u001b]8;;\u001b\\\n", + "\u001b[2;36m \u001b[0m Functionalities might be limited. pip install lovely-tensors in case there are torch related errors \u001b[2m \u001b[0m\n" + ] + }, + "metadata": {}, + "output_type": "display_data" + }, + { + "data": { + "text/html": [ + "
[08/17/24 12:55:13] INFO     loaded 25 lines                                                                                                        4135304039.py::3\" target=\"_blank\"><module>:3\n",
        "
\n" ], "text/plain": [ - "\u001b[2;36m[07/25/24 07:18:20]\u001b[0m\u001b[2;36m \u001b[0m\u001b[2;33mINFO \u001b[0m loaded \u001b[1;36m25\u001b[0m lines \u001b]8;id=2469;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_1245/4135304039.py:3\u001b\\\u001b[2m4135304039.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=677104;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_1245/4135304039.py:3#:3\u001b\\\u001b[2m:3\u001b[0m\u001b]8;;\u001b\\\n" + "\u001b[2;36m[08/17/24 12:55:13]\u001b[0m\u001b[2;36m \u001b[0m\u001b[2;33mINFO \u001b[0m loaded \u001b[1;36m25\u001b[0m lines \u001b]8;id=101360;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_48311/4135304039.py:3\u001b\\\u001b[2m4135304039.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=489669;file:///var/folders/1_/71dqv9vx2750gmyz77q_f45w0000gn/T/ipykernel_48311/4135304039.py:3#:3\u001b\\\u001b[2m:3\u001b[0m\u001b]8;;\u001b\\\n" ] }, "metadata": {}, @@ -181,10 +196,10 @@ { "data": { "text/plain": [ - "'0.537'" + "'0.538.1'" ] }, - "execution_count": 20, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } @@ -198,7 +213,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 3, "metadata": {}, "outputs": [ { @@ -236,67 +251,67 @@ "adding license file 'LICENSE.txt'\n", "writing manifest file 'torch_snippets.egg-info/SOURCES.txt'\n", "running check\n", - "creating torch_snippets-0.537\n", - "creating torch_snippets-0.537/torch_snippets\n", - "creating torch_snippets-0.537/torch_snippets.egg-info\n", - "creating torch_snippets-0.537/torch_snippets/thinc_parser\n", - "creating torch_snippets-0.537/torch_snippets/trainer\n", - "copying files to torch_snippets-0.537...\n", - "copying LICENSE -> torch_snippets-0.537\n", - "copying LICENSE.txt -> torch_snippets-0.537\n", - "copying MANIFEST.in -> torch_snippets-0.537\n", - "copying README.md -> torch_snippets-0.537\n", - "copying settings.ini -> torch_snippets-0.537\n", - "copying setup.cfg -> torch_snippets-0.537\n", - "copying setup.py -> torch_snippets-0.537\n", - "copying torch_snippets/__init__.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/_modidx.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/_nbdev.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/adapters.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/bb_utils.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/bokeh_loader.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/charts.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/dates.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/decorators.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/fastcores.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/icecream.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/imgaug_loader.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/inspector.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/interactive_show.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/ipython.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/load_defaults.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/loader.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/logger.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/markup.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/markup2.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/misc.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/paths.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/pdf_loader.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/registry.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/scp.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/sklegos.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/text_utils.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/tmp.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/torch_loader.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets/video.py -> torch_snippets-0.537/torch_snippets\n", - "copying torch_snippets.egg-info/PKG-INFO -> torch_snippets-0.537/torch_snippets.egg-info\n", - "copying torch_snippets.egg-info/SOURCES.txt -> torch_snippets-0.537/torch_snippets.egg-info\n", - "copying torch_snippets.egg-info/dependency_links.txt -> torch_snippets-0.537/torch_snippets.egg-info\n", - "copying torch_snippets.egg-info/not-zip-safe -> torch_snippets-0.537/torch_snippets.egg-info\n", - "copying torch_snippets.egg-info/requires.txt -> torch_snippets-0.537/torch_snippets.egg-info\n", - "copying torch_snippets.egg-info/top_level.txt -> torch_snippets-0.537/torch_snippets.egg-info\n", - "copying torch_snippets/thinc_parser/__init__.py -> torch_snippets-0.537/torch_snippets/thinc_parser\n", - "copying torch_snippets/thinc_parser/parser.py -> torch_snippets-0.537/torch_snippets/thinc_parser\n", - "copying torch_snippets/trainer/__init__.py -> torch_snippets-0.537/torch_snippets/trainer\n", - "copying torch_snippets/trainer/capsule.py -> torch_snippets-0.537/torch_snippets/trainer\n", - "copying torch_snippets/trainer/config.py -> torch_snippets-0.537/torch_snippets/trainer\n", - "copying torch_snippets/trainer/hooks.py -> torch_snippets-0.537/torch_snippets/trainer\n", - "copying torch_snippets/trainer/neural_graph.py -> torch_snippets-0.537/torch_snippets/trainer\n", - "copying torch_snippets.egg-info/SOURCES.txt -> torch_snippets-0.537/torch_snippets.egg-info\n", - "Writing torch_snippets-0.537/setup.cfg\n", + "creating torch_snippets-0.538.1\n", + "creating torch_snippets-0.538.1/torch_snippets\n", + "creating torch_snippets-0.538.1/torch_snippets.egg-info\n", + "creating torch_snippets-0.538.1/torch_snippets/thinc_parser\n", + "creating torch_snippets-0.538.1/torch_snippets/trainer\n", + "copying files to torch_snippets-0.538.1...\n", + "copying LICENSE -> torch_snippets-0.538.1\n", + "copying LICENSE.txt -> torch_snippets-0.538.1\n", + "copying MANIFEST.in -> torch_snippets-0.538.1\n", + "copying README.md -> torch_snippets-0.538.1\n", + "copying settings.ini -> torch_snippets-0.538.1\n", + "copying setup.cfg -> torch_snippets-0.538.1\n", + "copying setup.py -> torch_snippets-0.538.1\n", + "copying torch_snippets/__init__.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/_modidx.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/_nbdev.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/adapters.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/bb_utils.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/bokeh_loader.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/charts.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/dates.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/decorators.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/fastcores.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/icecream.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/imgaug_loader.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/inspector.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/interactive_show.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/ipython.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/load_defaults.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/loader.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/logger.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/markup.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/markup2.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/misc.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/paths.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/pdf_loader.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/registry.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/scp.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/sklegos.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/text_utils.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/tmp.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/torch_loader.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets/video.py -> torch_snippets-0.538.1/torch_snippets\n", + "copying torch_snippets.egg-info/PKG-INFO -> torch_snippets-0.538.1/torch_snippets.egg-info\n", + "copying torch_snippets.egg-info/SOURCES.txt -> torch_snippets-0.538.1/torch_snippets.egg-info\n", + "copying torch_snippets.egg-info/dependency_links.txt -> torch_snippets-0.538.1/torch_snippets.egg-info\n", + "copying torch_snippets.egg-info/not-zip-safe -> torch_snippets-0.538.1/torch_snippets.egg-info\n", + "copying torch_snippets.egg-info/requires.txt -> torch_snippets-0.538.1/torch_snippets.egg-info\n", + "copying torch_snippets.egg-info/top_level.txt -> torch_snippets-0.538.1/torch_snippets.egg-info\n", + "copying torch_snippets/thinc_parser/__init__.py -> torch_snippets-0.538.1/torch_snippets/thinc_parser\n", + "copying torch_snippets/thinc_parser/parser.py -> torch_snippets-0.538.1/torch_snippets/thinc_parser\n", + "copying torch_snippets/trainer/__init__.py -> torch_snippets-0.538.1/torch_snippets/trainer\n", + "copying torch_snippets/trainer/capsule.py -> torch_snippets-0.538.1/torch_snippets/trainer\n", + "copying torch_snippets/trainer/config.py -> torch_snippets-0.538.1/torch_snippets/trainer\n", + "copying torch_snippets/trainer/hooks.py -> torch_snippets-0.538.1/torch_snippets/trainer\n", + "copying torch_snippets/trainer/neural_graph.py -> torch_snippets-0.538.1/torch_snippets/trainer\n", + "copying torch_snippets.egg-info/SOURCES.txt -> torch_snippets-0.538.1/torch_snippets.egg-info\n", + "Writing torch_snippets-0.538.1/setup.cfg\n", "creating dist\n", "Creating tar archive\n", - "removing 'torch_snippets-0.537' (and everything under it)\n", + "removing 'torch_snippets-0.538.1' (and everything under it)\n", "running bdist_wheel\n", "running build\n", "running build_py\n", @@ -401,10 +416,10 @@ "copying build/lib/torch_snippets/adapters.py -> build/bdist.macosx-11.1-arm64/wheel/torch_snippets\n", "copying build/lib/torch_snippets/decorators.py -> build/bdist.macosx-11.1-arm64/wheel/torch_snippets\n", "running install_egg_info\n", - "Copying torch_snippets.egg-info to build/bdist.macosx-11.1-arm64/wheel/torch_snippets-0.537-py3.12.egg-info\n", + "Copying torch_snippets.egg-info to build/bdist.macosx-11.1-arm64/wheel/torch_snippets-0.538.1-py3.12.egg-info\n", "running install_scripts\n", - "creating build/bdist.macosx-11.1-arm64/wheel/torch_snippets-0.537.dist-info/WHEEL\n", - "creating 'dist/torch_snippets-0.537-py3-none-any.whl' and adding 'build/bdist.macosx-11.1-arm64/wheel' to it\n", + "creating build/bdist.macosx-11.1-arm64/wheel/torch_snippets-0.538.1.dist-info/WHEEL\n", + "creating 'dist/torch_snippets-0.538.1-py3-none-any.whl' and adding 'build/bdist.macosx-11.1-arm64/wheel' to it\n", "adding 'torch_snippets/__init__.py'\n", "adding 'torch_snippets/_modidx.py'\n", "adding 'torch_snippets/_nbdev.py'\n", @@ -442,21 +457,21 @@ "adding 'torch_snippets/trainer/config.py'\n", "adding 'torch_snippets/trainer/hooks.py'\n", "adding 'torch_snippets/trainer/neural_graph.py'\n", - "adding 'torch_snippets-0.537.dist-info/LICENSE'\n", - "adding 'torch_snippets-0.537.dist-info/LICENSE.txt'\n", - "adding 'torch_snippets-0.537.dist-info/METADATA'\n", - "adding 'torch_snippets-0.537.dist-info/WHEEL'\n", - "adding 'torch_snippets-0.537.dist-info/top_level.txt'\n", - "adding 'torch_snippets-0.537.dist-info/RECORD'\n", + "adding 'torch_snippets-0.538.1.dist-info/LICENSE'\n", + "adding 'torch_snippets-0.538.1.dist-info/LICENSE.txt'\n", + "adding 'torch_snippets-0.538.1.dist-info/METADATA'\n", + "adding 'torch_snippets-0.538.1.dist-info/WHEEL'\n", + "adding 'torch_snippets-0.538.1.dist-info/top_level.txt'\n", + "adding 'torch_snippets-0.538.1.dist-info/RECORD'\n", "removing build/bdist.macosx-11.1-arm64/wheel\n", "Uploading distributions to https://upload.pypi.org/legacy/\n", - "Uploading torch_snippets-0.537-py3-none-any.whl\n", - "\u001b[2K\u001b[35m100%\u001b[0m \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m106.6/106.6 kB\u001b[0m • \u001b[33m00:00\u001b[0m • \u001b[31m469.9 MB/s\u001b[0m\n", - "\u001b[?25hUploading torch_snippets-0.537.tar.gz\n", - "\u001b[2K\u001b[35m100%\u001b[0m \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m93.8/93.8 kB\u001b[0m • \u001b[33m00:00\u001b[0m • \u001b[31m186.9 MB/s\u001b[0m\n", + "Uploading torch_snippets-0.538.1-py3-none-any.whl\n", + "\u001b[2K\u001b[35m100%\u001b[0m \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m107.9/107.9 kB\u001b[0m • \u001b[33m00:01\u001b[0m • \u001b[31m386.0 MB/s\u001b[0m\n", + "\u001b[?25hUploading torch_snippets-0.538.1.tar.gz\n", + "\u001b[2K\u001b[35m100%\u001b[0m \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m95.0/95.0 kB\u001b[0m • \u001b[33m00:00\u001b[0m • \u001b[31m193.1 MB/s\u001b[0m\n", "\u001b[?25h\n", "\u001b[32mView at:\u001b[0m\n", - "https://pypi.org/project/torch-snippets/0.537/\n" + "https://pypi.org/project/torch-snippets/0.538.1/\n" ] } ], @@ -474,12 +489,251 @@ "name": "stdout", "output_type": "stream", "text": [ - "Quarto is not installed. We will download and install it for you.\n", - "Installing or upgrading quarto -- this requires root access.\n", - "Password:\n", - "sudo: a password is required\n", - "Cancelled. Please download and install Quarto from quarto.org.\n", - "Password:" + "/opt/miniconda3/lib/python3.12/site-packages/nbdev/processors.py:222: UserWarning: Found cells containing imports and other code. See FAQ.\n", + "---\n", + "#| echo: false\n", + "#| output: asis\n", + "from nbdev import show_doc\n", + "\n", + "show_doc(AttrDict)\n", + "---\n", + "\n", + " warn(f'Found cells containing imports and other code. See FAQ.\\n---\\n{cell.source}\\n---\\n')\n", + "/opt/miniconda3/lib/python3.12/site-packages/nbdev/processors.py:222: UserWarning: Found cells containing imports and other code. See FAQ.\n", + "---\n", + "try:\n", + " import torch\n", + "\n", + " d = AD(a=torch.Tensor([1, 2, 3]), b=\"hello\")\n", + " write_json(d, \"/tmp/tmp.json\")\n", + " print(\"\\n\".join(readlines(\"/tmp/tmp.json\")))\n", + "except ModuleNotFoundError:\n", + " ...\n", + "---\n", + "\n", + " warn(f'Found cells containing imports and other code. See FAQ.\\n---\\n{cell.source}\\n---\\n')\n", + "/opt/miniconda3/lib/python3.12/site-packages/nbdev/processors.py:222: UserWarning: Found cells containing imports and other code. See FAQ.\n", + "---\n", + "@timeit\n", + "@io\n", + "def foo(a, b):\n", + " \"\"\"\n", + " This function takes two arguments, `a` and `b`, and returns their sum.\n", + "\n", + " Parameters:\n", + " a (int): The first number.\n", + " b (int): The second number.\n", + "\n", + " Returns:\n", + " int: The sum of `a` and `b`.\n", + " \"\"\"\n", + " import time\n", + "\n", + " time.sleep(1)\n", + " return a + b\n", + "\n", + "\n", + "foo(10, 11)\n", + "---\n", + "\n", + " warn(f'Found cells containing imports and other code. See FAQ.\\n---\\n{cell.source}\\n---\\n')\n", + "/opt/miniconda3/lib/python3.12/site-packages/nbdev/processors.py:222: UserWarning: Found cells containing imports and other code. See FAQ.\n", + "---\n", + "from torch_snippets.loader import *\n", + "from sklearn.datasets import make_moons\n", + "\n", + "np.random.seed(10)\n", + "x, y = make_moons(1000, noise=0.1)\n", + "df = pd.DataFrame({\"x1\": x[:, 0], \"x2\": x[:, 1], \"y\": y})\n", + "\n", + "Chart(df).mark_circle().encode(x=\"x1:Q\", y=\"x2:Q\", color=\"y:N\").interactive()\n", + "---\n", + "\n", + " warn(f'Found cells containing imports and other code. See FAQ.\\n---\\n{cell.source}\\n---\\n')\n", + "/opt/miniconda3/lib/python3.12/site-packages/nbdev/processors.py:222: UserWarning: Found cells containing imports and other code. See FAQ.\n", + "---\n", + "import pandas as pd\n", + "\n", + "spider(\n", + " pd.DataFrame(\n", + " {\n", + " \"x\": [*\"abcde\"],\n", + " \"c1\": [10, 11, 12, 13, 14],\n", + " \"c2\": [0.1, 0.3, 0.4, 0.1, 0.9],\n", + " \"c3\": [1e5, 2e5, 3.5e5, 8e4, 5e4],\n", + " \"c4\": [9, 12, 5, 2, 0.2],\n", + " \"test\": [1, 1, 1, 1, 5],\n", + " },\n", + " index=[*\"abcde\"],\n", + " ),\n", + " title=\"Sample Spider\",\n", + " padding=1.1,\n", + ")\n", + "---\n", + "\n", + " warn(f'Found cells containing imports and other code. See FAQ.\\n---\\n{cell.source}\\n---\\n')\n", + "/opt/miniconda3/lib/python3.12/site-packages/nbdev/processors.py:222: UserWarning: Found cells containing imports and other code. See FAQ.\n", + "---\n", + "import numpy as np\n", + "\n", + "df = pd.DataFrame(np.random.randn(300, 7) > 0.33).astype(int)\n", + "df.columns = [rand() for _ in range(len(df.columns))]\n", + "# df['id'] = [rand() for _ in range(len(df))]\n", + "df\n", + "UpSetAltair(\n", + " df,\n", + " sets=list(df.columns),\n", + " abbre=list(df.columns),\n", + " sort_by=\"frequencey\",\n", + " sort_order=\"ascending\",\n", + ")\n", + "---\n", + "\n", + " warn(f'Found cells containing imports and other code. See FAQ.\\n---\\n{cell.source}\\n---\\n')\n", + "concurrent.futures.process._RemoteTraceback: \n", + "\"\"\"\n", + "Traceback (most recent call last):\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/IPython/core/interactiveshell.py\", line 3577, in run_code\n", + " exec(code_obj, self.user_global_ns, self.user_ns)\n", + " File \"\", line 3, in \n", + " from torch_snippets.bokeh_loader import bshow\n", + " File \"/Users/yeshwanth/Code/Personal/torch_snippets/torch_snippets/bokeh_loader.py\", line 7, in \n", + " from bokeh.io import output_notebook, show as bshow\n", + "ModuleNotFoundError: No module named 'bokeh'\n", + "\n", + "The above exception was the direct cause of the following exception:\n", + "\n", + "Traceback (most recent call last):\n", + " File \"/opt/miniconda3/lib/python3.12/concurrent/futures/process.py\", line 263, in _process_worker\n", + " r = call_item.fn(*call_item.args, **call_item.kwargs)\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/concurrent/futures/process.py\", line 212, in _process_chunk\n", + " return [fn(*args) for args in chunk]\n", + " ^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/fastcore/parallel.py\", line 61, in _call\n", + " return g(item)\n", + " ^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/nbdev/serve_drv.py\", line 22, in main\n", + " if src.suffix=='.ipynb': exec_nb(src, dst, x)\n", + " ^^^^^^^^^^^^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/nbdev/serve_drv.py\", line 16, in exec_nb\n", + " cb()(nb)\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/nbdev/processors.py\", line 279, in __call__\n", + " def __call__(self, nb): return self.nb_proc(nb).process()\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/nbdev/process.py\", line 127, in process\n", + " for proc in self.procs: self._proc(proc)\n", + " ^^^^^^^^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/nbdev/process.py\", line 120, in _proc\n", + " for cell in self.nb.cells: self._process_cell(proc, cell)\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/nbdev/process.py\", line 111, in _process_cell\n", + " if callable(proc) and not _is_direc(proc): cell = opt_set(cell, proc(cell))\n", + " ^^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/nbdev/processors.py\", line 241, in __call__\n", + " raise Exception(f\"Error{' in notebook: '+title if title else ''} in cell {cell.idx_} :\\n{cell.source}\") from self.k.exc[1]\n", + "Exception: Error in cell 2 :\n", + "from pathlib import Path\n", + "from torch_snippets import *\n", + "from torch_snippets.bokeh_loader import bshow\n", + "from bokeh.io import output_notebook, show as bokeh_show, output_file\n", + "from bokeh.plotting import figure, from_networkx\n", + "from bokeh.models import (\n", + " Circle,\n", + " Rect,\n", + " WheelZoomTool,\n", + " PanTool,\n", + " BoxZoomTool,\n", + " ResetTool,\n", + " MultiLine,\n", + " NodesAndLinkedEdges,\n", + " EdgesAndLinkedNodes,\n", + " HoverTool,\n", + " TapTool,\n", + " BoxSelectTool,\n", + ")\n", + "from bokeh.palettes import Spectral7\n", + "import networkx as nx\n", + "import torch\n", + "import numpy as np\n", + "from fastcore.basics import ifnone\n", + "from typing import Optional, Any, Iterable, Union\n", + "from torch_snippets.bb_utils import split_bb_to_xyXY, to_absolute, to_relative\n", + "\n", + "output_notebook()\n", + "\"\"\"\n", + "\n", + "The above exception was the direct cause of the following exception:\n", + "\n", + "Traceback (most recent call last):\n", + " File \"/opt/miniconda3/bin/nbdev_docs\", line 8, in \n", + " sys.exit(nbdev_docs())\n", + " ^^^^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/fastcore/script.py\", line 119, in _f\n", + " return tfunc(**merge(args, args_from_prog(func, xtra)))\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/nbdev/quarto.py\", line 274, in nbdev_docs\n", + " cache,cfg,path = _pre_docs(path, n_workers=n_workers, **kwargs)\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/nbdev/quarto.py\", line 202, in _pre_docs\n", + " cache = proc_nbs(path, n_workers=n_workers, **kwargs)\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/nbdev/serve.py\", line 77, in proc_nbs\n", + " parallel(nbdev.serve_drv.main, files, n_workers=n_workers, pause=0.01, **kw)\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/fastcore/parallel.py\", line 132, in parallel\n", + " return L(r)\n", + " ^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/fastcore/foundation.py\", line 98, in __call__\n", + " return super().__call__(x, *args, **kwargs)\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/fastcore/foundation.py\", line 106, in __init__\n", + " items = listify(items, *rest, use_list=use_list, match=match)\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/site-packages/fastcore/basics.py\", line 66, in listify\n", + " elif is_iter(o): res = list(o)\n", + " ^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/concurrent/futures/process.py\", line 642, in _chain_from_iterable_of_lists\n", + " for element in iterable:\n", + " File \"/opt/miniconda3/lib/python3.12/concurrent/futures/_base.py\", line 619, in result_iterator\n", + " yield _result_or_cancel(fs.pop())\n", + " ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/concurrent/futures/_base.py\", line 317, in _result_or_cancel\n", + " return fut.result(timeout)\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/concurrent/futures/_base.py\", line 449, in result\n", + " return self.__get_result()\n", + " ^^^^^^^^^^^^^^^^^^^\n", + " File \"/opt/miniconda3/lib/python3.12/concurrent/futures/_base.py\", line 401, in __get_result\n", + " raise self._exception\n", + "Exception: Error in cell 2 :\n", + "from pathlib import Path\n", + "from torch_snippets import *\n", + "from torch_snippets.bokeh_loader import bshow\n", + "from bokeh.io import output_notebook, show as bokeh_show, output_file\n", + "from bokeh.plotting import figure, from_networkx\n", + "from bokeh.models import (\n", + " Circle,\n", + " Rect,\n", + " WheelZoomTool,\n", + " PanTool,\n", + " BoxZoomTool,\n", + " ResetTool,\n", + " MultiLine,\n", + " NodesAndLinkedEdges,\n", + " EdgesAndLinkedNodes,\n", + " HoverTool,\n", + " TapTool,\n", + " BoxSelectTool,\n", + ")\n", + "from bokeh.palettes import Spectral7\n", + "import networkx as nx\n", + "import torch\n", + "import numpy as np\n", + "from fastcore.basics import ifnone\n", + "from typing import Optional, Any, Iterable, Union\n", + "from torch_snippets.bb_utils import split_bb_to_xyXY, to_absolute, to_relative\n", + "\n", + "output_notebook()\n" ] } ], @@ -489,24 +743,24 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 5, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "[master 55336f9] 0.537\n", - " 1 file changed, 18 insertions(+), 17 deletions(-)\n", - "Enumerating objects: 5, done.\n", - "Counting objects: 100% (5/5), done.\n", + "[master 7d0b19f] 0.538.1\n", + " 9 files changed, 12 insertions(+), 9 deletions(-)\n", + "Enumerating objects: 29, done.\n", + "Counting objects: 100% (29/29), done.\n", "Delta compression using up to 12 threads\n", - "Compressing objects: 100% (3/3), done.\n", - "Writing objects: 100% (3/3), 507 bytes | 507.00 KiB/s, done.\n", - "Total 3 (delta 2), reused 0 (delta 0), pack-reused 0\n", - "remote: Resolving deltas: 100% (2/2), completed with 2 local objects.\u001b[K\n", + "Compressing objects: 100% (15/15), done.\n", + "Writing objects: 100% (15/15), 1.43 KiB | 1.43 MiB/s, done.\n", + "Total 15 (delta 14), reused 0 (delta 0), pack-reused 0\n", + "remote: Resolving deltas: 100% (14/14), completed with 14 local objects.\u001b[K\n", "To ssh://github.com/sizhky/torch_snippets\n", - " 329144a..55336f9 master -> master\n" + " 3edebb3..7d0b19f master -> master\n" ] } ], @@ -515,6 +769,13 @@ "!git commit -m {VERSION}\n", "!git push" ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { diff --git a/settings.ini b/settings.ini index e330561..23fe0e1 100644 --- a/settings.ini +++ b/settings.ini @@ -8,14 +8,14 @@ author = Yeshwanth Reddy author_email = 1992chinna@gmail.com copyright = sizhky branch = master -version = 0.538.1 +version = 0.539 min_python = 3.7 audience = Developers language = English custom_sidebar = False license = apache2 status = 2 -requirements = fastcore matplotlib Pillow altair dill ipython loguru numpy pandas tqdm rich PyYAML catalogue confection pydantic typing srsly typing_extensions wasabi jsonlines imgaug>=0.4.0 xmltodict fuzzywuzzy scikit-learn nltk python-Levenshtein pre-commit pymupdf nbconvert nbformat icecream mergedeep +requirements = fastcore matplotlib Pillow altair dill ipython loguru numpy pandas tqdm rich PyYAML catalogue confection pydantic typing srsly typing_extensions wasabi jsonlines imgaug>=0.4.0 xmltodict fuzzywuzzy scikit-learn nltk python-Levenshtein pre-commit pymupdf nbconvert nbformat icecream mergedeep typer nbs_path = nbs doc_path = docs doc_host = https://%(user)s.github.io @@ -23,3 +23,4 @@ doc_baseurl = /%(lib_name)s/ git_url = https://github.com/%(user)s/%(lib_name)s/tree/%(branch)s/ lib_path = %(lib_name)s title = %(lib_name)s +console_scripts = ts=torch_snippets.cli:cli \ No newline at end of file diff --git a/torch_snippets.egg-info/PKG-INFO b/torch_snippets.egg-info/PKG-INFO index 1a5a774..106c27e 100644 --- a/torch_snippets.egg-info/PKG-INFO +++ b/torch_snippets.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: torch_snippets -Version: 0.538.1 +Version: 0.539 Summary: One line functions for common tasks Home-page: https://github.com/sizhky/torch_snippets/tree/master/ Author: Yeshwanth Reddy @@ -49,6 +49,7 @@ Requires-Dist: nbconvert Requires-Dist: nbformat Requires-Dist: icecream Requires-Dist: mergedeep +Requires-Dist: typer # Utilities for simple needs diff --git a/torch_snippets.egg-info/SOURCES.txt b/torch_snippets.egg-info/SOURCES.txt index 2fe9e53..71f5dc7 100644 --- a/torch_snippets.egg-info/SOURCES.txt +++ b/torch_snippets.egg-info/SOURCES.txt @@ -12,6 +12,7 @@ torch_snippets/adapters.py torch_snippets/bb_utils.py torch_snippets/bokeh_loader.py torch_snippets/charts.py +torch_snippets/cli.py torch_snippets/dates.py torch_snippets/decorators.py torch_snippets/fastcores.py @@ -29,15 +30,18 @@ torch_snippets/misc.py torch_snippets/paths.py torch_snippets/pdf_loader.py torch_snippets/registry.py +torch_snippets/s3_loader.py torch_snippets/scp.py torch_snippets/sklegos.py torch_snippets/text_utils.py torch_snippets/tmp.py torch_snippets/torch_loader.py torch_snippets/video.py +torch_snippets/zen.py torch_snippets.egg-info/PKG-INFO torch_snippets.egg-info/SOURCES.txt torch_snippets.egg-info/dependency_links.txt +torch_snippets.egg-info/entry_points.txt torch_snippets.egg-info/not-zip-safe torch_snippets.egg-info/requires.txt torch_snippets.egg-info/top_level.txt diff --git a/torch_snippets.egg-info/entry_points.txt b/torch_snippets.egg-info/entry_points.txt new file mode 100644 index 0000000..f4bd242 --- /dev/null +++ b/torch_snippets.egg-info/entry_points.txt @@ -0,0 +1,2 @@ +[console_scripts] +ts = torch_snippets.cli:cli diff --git a/torch_snippets.egg-info/requires.txt b/torch_snippets.egg-info/requires.txt index bbde90b..767b106 100644 --- a/torch_snippets.egg-info/requires.txt +++ b/torch_snippets.egg-info/requires.txt @@ -30,3 +30,4 @@ nbconvert nbformat icecream mergedeep +typer diff --git a/torch_snippets/__init__.py b/torch_snippets/__init__.py index 16baf29..79550c6 100644 --- a/torch_snippets/__init__.py +++ b/torch_snippets/__init__.py @@ -1,4 +1,4 @@ -__version__ = "0.538.1" +__version__ = "0.539" from .loader import * from .paths import * from .markup import * @@ -22,3 +22,6 @@ from .torch_loader import * except Exception as e: ... + +from .s3_loader import * +from .zen import * diff --git a/torch_snippets/_modidx.py b/torch_snippets/_modidx.py index f8b1990..0ac1ba6 100644 --- a/torch_snippets/_modidx.py +++ b/torch_snippets/_modidx.py @@ -94,6 +94,7 @@ 'torch_snippets.charts.spider': ('charts.html#spider', 'torch_snippets/charts.py'), 'torch_snippets.charts.upsetaltair_top_level_configuration': ( 'charts.html#upsetaltair_top_level_configuration', 'torch_snippets/charts.py')}, + 'torch_snippets.cli': {}, 'torch_snippets.dates': {}, 'torch_snippets.decorators': { 'torch_snippets.decorators.check_kwargs_not_none': ( 'decorators.html#check_kwargs_not_none', 'torch_snippets/decorators.py'), @@ -269,17 +270,26 @@ 'torch_snippets.markup2.AttrDict.drop': ('markups.html#attrdict.drop', 'torch_snippets/markup2.py'), 'torch_snippets.markup2.AttrDict.fetch': ( 'markups.html#attrdict.fetch', 'torch_snippets/markup2.py'), + 'torch_snippets.markup2.AttrDict.fetch2': ( 'markups.html#attrdict.fetch2', + 'torch_snippets/markup2.py'), 'torch_snippets.markup2.AttrDict.find_address': ( 'markups.html#attrdict.find_address', 'torch_snippets/markup2.py'), + 'torch_snippets.markup2.AttrDict.flatten': ( 'markups.html#attrdict.flatten', + 'torch_snippets/markup2.py'), + 'torch_snippets.markup2.AttrDict.flatten_and_make_dataframe': ( 'markups.html#attrdict.flatten_and_make_dataframe', + 'torch_snippets/markup2.py'), 'torch_snippets.markup2.AttrDict.get': ('markups.html#attrdict.get', 'torch_snippets/markup2.py'), 'torch_snippets.markup2.AttrDict.items': ( 'markups.html#attrdict.items', 'torch_snippets/markup2.py'), 'torch_snippets.markup2.AttrDict.keys': ('markups.html#attrdict.keys', 'torch_snippets/markup2.py'), 'torch_snippets.markup2.AttrDict.map': ('markups.html#attrdict.map', 'torch_snippets/markup2.py'), + 'torch_snippets.markup2.AttrDict.merge_addersses': ( 'markups.html#attrdict.merge_addersses', + 'torch_snippets/markup2.py'), 'torch_snippets.markup2.AttrDict.pretty': ( 'markups.html#attrdict.pretty', 'torch_snippets/markup2.py'), 'torch_snippets.markup2.AttrDict.print_summary': ( 'markups.html#attrdict.print_summary', 'torch_snippets/markup2.py'), + 'torch_snippets.markup2.AttrDict.set': ('markups.html#attrdict.set', 'torch_snippets/markup2.py'), 'torch_snippets.markup2.AttrDict.slice': ( 'markups.html#attrdict.slice', 'torch_snippets/markup2.py'), 'torch_snippets.markup2.AttrDict.summary': ( 'markups.html#attrdict.summary', @@ -301,6 +311,8 @@ 'torch_snippets.markup2.hash_pandas_dataframe': ( 'markups.html#hash_pandas_dataframe', 'torch_snippets/markup2.py'), 'torch_snippets.markup2.hash_tensor': ('markups.html#hash_tensor', 'torch_snippets/markup2.py'), + 'torch_snippets.markup2.is_attrdict_like': ( 'markups.html#is_attrdict_like', + 'torch_snippets/markup2.py'), 'torch_snippets.markup2.isnamedtupleinstance': ( 'markups.html#isnamedtupleinstance', 'torch_snippets/markup2.py'), 'torch_snippets.markup2.pretty_json': ('markups.html#pretty_json', 'torch_snippets/markup2.py'), @@ -389,6 +401,7 @@ 'torch_snippets.registry.parse_string': ( 'registry.html#parse_string', 'torch_snippets/registry.py'), 'torch_snippets.registry.tryeval': ('registry.html#tryeval', 'torch_snippets/registry.py')}, + 'torch_snippets.s3_loader': {}, 'torch_snippets.scp': {}, 'torch_snippets.sklegos': { 'torch_snippets.sklegos.Cat2Num': ('sklegos.html#cat2num', 'torch_snippets/sklegos.py'), 'torch_snippets.sklegos.Cat2Num.__init__': ( 'sklegos.html#cat2num.__init__', @@ -512,4 +525,5 @@ 'torch_snippets/trainer/config.py')}, 'torch_snippets.trainer.hooks': {}, 'torch_snippets.trainer.neural_graph': {}, - 'torch_snippets.video': {}}} + 'torch_snippets.video': {}, + 'torch_snippets.zen': {}}} diff --git a/torch_snippets/cli.py b/torch_snippets/cli.py new file mode 100644 index 0000000..2599275 --- /dev/null +++ b/torch_snippets/cli.py @@ -0,0 +1,21 @@ +from typer import Typer +from .loader import show as _show + +cli = Typer() + + +@cli.command() +def time(): + """print the time now, in %Y-%m-%d %H:%M:%S format""" + import time + + print(time.strftime("%Y-%m-%d %H:%M:%S")) + + +# Other cool utils + + +@cli.command() +def show(path): + """print the object""" + _show(path) diff --git a/torch_snippets/loader.py b/torch_snippets/loader.py index 7e2e800..45e47ab 100755 --- a/torch_snippets/loader.py +++ b/torch_snippets/loader.py @@ -256,13 +256,18 @@ def readPIL(fname, mode="RGB"): return Image.open(str(fname)).convert(mode.upper()) -def crop_from_bb(im, bb): +def crop_from_bb(im, bb, padding=None): if isinstance(bb, list): - return [crop_from_bb(im, _bb) for _bb in bb] + return [crop_from_bb(im, _bb, padding=padding) for _bb in bb] x, y, X, Y = bb + px, py, pX, pY = padding if max(x, y, X, Y) < 1.5: h, w = im.shape[:2] x, y, X, Y = BB(bb).absolute((h, w)) + y = max(0, y - py) + Y = min(h, Y + pY) + x = max(0, x - px) + X = min(w, X + pX) return im.copy()[y:Y, x:X] diff --git a/torch_snippets/markup2.py b/torch_snippets/markup2.py index 527353c..e01c97b 100644 --- a/torch_snippets/markup2.py +++ b/torch_snippets/markup2.py @@ -26,7 +26,7 @@ import os from collections.abc import Mapping from json import JSONEncoder -from typing import Union +from typing import Union, List import jsonlines import xmltodict @@ -114,6 +114,13 @@ def hash_pandas_dataframe(input): return "ID:#" +def is_attrdict_like(input): + o = isinstance(input, (Mapping, AttrDict)) or all( + [hasattr(input, k) for k in ["keys", "values", "items"]] + ) + return o + + class AttrDict(object): """ Utility class to interact with a dictionary as if it were an object. `AD` is an alias to this class @@ -238,6 +245,20 @@ def update(self, input): def get(self, key, default=None): return self.fetch(key) if key in self else default + def set(self, key, value): + if "." in key: + _keys = key.split(".") + leaf = _keys[-1] + else: + _keys = [key] + leaf = key + for _key in _keys: + if _key not in self and key != leaf: + self[_key] = AD() + if _key == leaf: + self[_key] = value + self = self[_key] + def __iter__(self): return iter(self.keys()) @@ -355,6 +376,8 @@ def find_address(self, key, current_path=""): def summary(self, current_path="", depth=0, sep=" ", max_items=10): max_items = int(os.environ.get("AD_MAX_ITEMS", max_items)) + if os.environ.get("AD_SHOW_TAB_STOPS", False): + sep = "⋮ " sep = os.environ.get("AD_SEP", sep) def format_path(path, key): @@ -384,7 +407,10 @@ class Torch: is_np = False if isinstance(item, np.ndarray): is_np = True - item = torch.tensor(item) + try: + item = torch.tensor(item) + except: + item = torch.tensor(item.copy()) is_np = "🔦" if not is_np else "np." return f"{sep * depth}{key} - {is_np}{item} - {hash_tensor(item)}\n" @@ -440,7 +466,7 @@ def print_summary(self, **kwargs): print(self.summary(**kwargs)) def write_summary(self, to, **kwargs): - writelines(self.summary(**kwargs).split("\n"), to) + writelines(self.summary(sep="\t", **kwargs).split("\n"), to, mode="w") def fetch(self, addr): if isinstance(addr, (list, L)): @@ -454,6 +480,87 @@ def fetch(self, addr): o = o[p] return o + def merge_addersses(self, ADs): + """Given a list of ADs, merge them into a single AD, which recursively merging the addresses + E.g. When input is + ```↯ AttrDict ↯ + 01f3daf0-f33a-11ee-a30b-129eb4343ebc.metrics.old.0.recall - 0.5 (🏷️ float) + ``` + , + ```↯ AttrDict ↯ + 01f3daf0-f33a-11ee-a30b-129eb4343ebc.metrics.new.0.recall - 0.7566584022717563 (🏷️ float) + ``` + , + ```↯ AttrDict ↯ + 01f3daf0-f33a-11ee-a30b-129eb4343ebc.metrics.new.1.recall - 0.8080808080808081 (🏷️ float) + ``` + , + ```↯ AttrDict ↯ + 01f3db47-f33a-11ee-a30d-129eb4343ebc.metrics.old.0.recall - 0.5 (🏷️ float) + ``` + Output will be + ```↯ AttrDict ↯ + 01f3daf0-f33a-11ee-a30b-129eb4343ebc + metrics + old[] + 0 + recall - 0.5 (🏷️ float) + new[] + 0 + recall - 0.7566584022717563 (🏷️ float) + 1 + recall - 0.8080808080808081 (🏷️ float) + 01f3db47-f33a-11ee-a30d-129eb4343ebc + metrics + old[] + 0 + recall - 0.5 (🏷️ float) + ``` + """ + o = AttrDict() + for ad in ADs: + for k in ad.keys(): + o.set(k, ad[k]) + return o + + def flatten(self): + """Flatten the AD into a single level AD with keys as dot combined keys""" + o = AttrDict() + for k in self.keys(): + v = self[k] + if is_attrdict_like(v): + v = v.flatten() + for _k in v.keys(): + o[f"{k}.{_k}"] = v[_k] + elif isinstance(v, (list, tuple, set, frozenset, L)): + for i, _v in enumerate(v): + if is_attrdict_like(_v): + _v = _v.flatten() + for _k, __v in _v.items(): + o[f"{k}.{i}.{_k}"] = __v + else: + o[f"{k}.{i}"] = _v + else: + o[k] = v + return o + + def fetch2(self, *, key=None, addrs=None): + """given dot notation address/addresses fetch the value while maintaining the original structure""" + if key is not None: + addrs = self.find_address(key) + if isinstance(addrs, (list, L)): + return self.merge_addersses( + L([self.fetch2(addrs=_addr) for _addr in addrs]) + ) + + o = self + for p in addrs.split("."): + try: + o = o[int(p)] + except: + o = o[p] + return AttrDict({addrs: o}) + def write_config(self, to): c = Config(self.dict()) c.to_disk(to) @@ -464,6 +571,12 @@ def slice(self, key): vs = self.fetch(ks) return AttrDict(dict(zip(ks, vs))) + def flatten_and_make_dataframe(self): + import pandas as pd + + df = pd.DataFrame([(*k.split("."), v) for k, v in self.flatten().items()]) + return df + AD = AttrDict AD.dict = AD.to_dict diff --git a/torch_snippets/misc.py b/torch_snippets/misc.py index 49319c6..b31361c 100644 --- a/torch_snippets/misc.py +++ b/torch_snippets/misc.py @@ -5,10 +5,11 @@ # %% ../nbs/misc.ipynb 2 import time -from .logger import Debug, Excep, debug_mode +from .logger import Debug, Excep, debug_mode, Info from .markup2 import AD from functools import wraps from fastcore.basics import ifnone +from fastcore.foundation import L # %% ../nbs/misc.ipynb 3 class Timer: @@ -106,8 +107,20 @@ def inner(*args, **kwargs): return inner # %% ../nbs/misc.ipynb 12 -def tryy(func=None, *, output_to_return_on_fail=None, print_traceback=False): +def tryy( + func=None, + *, + output_to_return_on_fail=None, + silence_errors=False, + print_traceback=False, + store_errors: bool = True, +): def decorator(f): + if isinstance(store_errors, bool) and store_errors: + error_store = [] + elif isinstance(store_errors, (list, L)): + error_store = store_errors + def inner(*args, **kwargs): try: return f(*args, **kwargs) @@ -118,11 +131,31 @@ def inner(*args, **kwargs): import traceback tb = traceback.format_exc() - Excep( - f"Error for `{f.__name__}` with \n{summarize_input(args, kwargs)}\n{tb}" - ) + if not silence_errors: + Excep( + f"Error for `{f.__name__}` with \n{summarize_input(args, kwargs)}\n{tb}" + ) + if store_errors is not None: + error_store.append( + AD( + func=f.__name__, + args=args, + kwargs=kwargs, + tb=tb, + err_type=type(e).__name__, + ) + ) return output_to_return_on_fail + inner.F = f # Store reference to the original function + inner.error_store = error_store + + def error_summary(): + import pandas as pd + + return pd.DataFrame([e.dict() for e in error_store]) + + inner.error_summary = error_summary return inner if callable(func): diff --git a/torch_snippets/s3_loader.py b/torch_snippets/s3_loader.py new file mode 100644 index 0000000..71ce222 --- /dev/null +++ b/torch_snippets/s3_loader.py @@ -0,0 +1,15 @@ +from .cli import cli +from .paths import P, parent, makedir +from .load_defaults import exists + + +@cli.command() +def download_s3_folder(s3_location, local_location, completeness_file): + from s3fs import S3FileSystem + + s3 = S3FileSystem() + completeness_file = P(completeness_file) + makedir(parent(local_location)) + if not exists(completeness_file): + s3.download(s3_location, local_location, recursive=True) + completeness_file.touch() diff --git a/torch_snippets/zen.py b/torch_snippets/zen.py new file mode 100644 index 0000000..128241b --- /dev/null +++ b/torch_snippets/zen.py @@ -0,0 +1,9 @@ +from .cli import cli + + +@cli.command() +def zen_of(language): + if language == "python": + import this + else: + raise NotImplementedError(f"zen of {language} is yet to be found")