Skip to content

Commit

Permalink
0.507
Browse files Browse the repository at this point in the history
  • Loading branch information
sizhky committed Sep 23, 2023
1 parent 5580d00 commit 7b9503a
Show file tree
Hide file tree
Showing 26 changed files with 1,190 additions and 1,003 deletions.
2 changes: 1 addition & 1 deletion _proc/decorators.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@
"OUTPUTS:\n",
"int: 21\n",
"══════════════════════════════════════════════════════════════════\n",
"[09/05/23 07:22:34] INFO foo took 1.04 seconds to execute <ipython-input-1-2384d961f6ef>:wrapper:7\n"
"[09/23/23 17:48:55] INFO foo took 1.02 seconds to execute <ipython-input-1-2384d961f6ef>:wrapper:7\n"
]
},
{
Expand Down
8 changes: 4 additions & 4 deletions _proc/jupyter_notebook.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@
"### display_dfs_side_by_side\n",
"\n",
"> display_dfs_side_by_side (*args, titles=<itertools.cycle object at\n",
"> 0x7fd845e00a80>, max_rows=50)"
"> 0x7f88f1237100>, max_rows=50)"
],
"text/plain": [
"---\n",
"\n",
"### display_dfs_side_by_side\n",
"\n",
"> display_dfs_side_by_side (*args, titles=<itertools.cycle object at\n",
"> 0x7fd845e00a80>, max_rows=50)"
"> 0x7f88f1237100>, max_rows=50)"
]
},
"execution_count": 5,
Expand Down Expand Up @@ -412,14 +412,14 @@
"\n",
"### shutdown_current_notebook\n",
"\n",
"> shutdown_current_notebook ()"
"> shutdown_current_notebook (delay:int=None)"
],
"text/plain": [
"---\n",
"\n",
"### shutdown_current_notebook\n",
"\n",
"> shutdown_current_notebook ()"
"> shutdown_current_notebook (delay:int=None)"
]
},
"execution_count": 12,
Expand Down
339 changes: 198 additions & 141 deletions _proc/logging.ipynb

Large diffs are not rendered by default.

128 changes: 58 additions & 70 deletions _proc/misc.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,53 @@
"<!-- WARNING: THIS FILE WAS AUTOGENERATED! DO NOT EDIT! -->"
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {
"language": "python"
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"1/10 (1.00s - 9.04s remaining - 1.00 s/iter) \n",
"2/10 (1.91s - 7.20s remaining - 1.11 iters/s) \n",
"3/10 (2.71s - 5.63s remaining - 1.24 iters/s) \n",
"4/10 (3.41s - 4.21s remaining - 1.43 iters/s) \n",
"5/10 (4.01s - 3.02s remaining - 1.66 iters/s) \n",
"6/10 (4.52s - 2.01s remaining - 1.99 iters/s) \n",
"7/10 (4.92s - 1.21s remaining - 2.47 iters/s) \n",
"8/10 (5.23s - 0.61s remaining - 3.28 iters/s) \n",
"9/10 (5.43s - 0.20s remaining - 4.90 iters/s) \n",
"10/10 (5.53s - 0.00s remaining - 9.64 iters/s) \r"
]
}
],
"source": [
"def track2(iterable, *, total=None):\n",
" try:\n",
" total = ifnone(total, len(iterable))\n",
" except:\n",
" ...\n",
" timer = Timer(total)\n",
" for item in iterable:\n",
" info = yield item\n",
" timer(info=info)\n",
" if info is not None:\n",
" yield # Just to ensure the send operation stops\n",
"\n",
"\n",
"l = list(range(10, 0, -1))\n",
"fact = 10\n",
"t = sum(l) / fact\n",
"for i in track2(l):\n",
" time.sleep(i / fact)\n",
" print()"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand All @@ -28,7 +75,7 @@
},
{
"cell_type": "code",
"execution_count": 17,
"execution_count": 75,
"metadata": {
"language": "python"
},
Expand All @@ -37,8 +84,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"51/100 (5.21s - 5.11s remaining - 9.78 iters/s) \n",
"My Info: 156.1\t100/100 (10.24s - 0.10s remaining - 9.77 iters/s) \r"
"51/100 (5.25s - 5.05s remaining - 9.71 iters/s) \n",
"My Info: 156.1\t100/100 (10.31s - 0.00s remaining - 9.75 iters/s) \r"
]
}
],
Expand All @@ -64,7 +111,7 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 80,
"metadata": {
"language": "python"
},
Expand All @@ -73,8 +120,8 @@
"name": "stdout",
"output_type": "stream",
"text": [
"My Info: 152.978\t50/100 (5.12s - 5.23s remaining - 9.76 iters/s) ) \n",
"My Info: 309.078\t100/100 (10.26s - 0.10s remaining - 9.74 iters/s) \r"
"50/100 (5.16s - 5.22s remaining - 9.58 iters/s) \n",
"My Info: 309.08\t100/100 (10.31s - 0.00s remaining - 9.75 iters/s) \r"
]
}
],
Expand All @@ -84,10 +131,11 @@
"\n",
"for i in (tracker := track2(range(N), total=N)):\n",
" time.sleep(0.1)\n",
" info = f\"My Info: {i*3.122}\"\n",
" info = f\"My Info: {i*3.122:.2f}\"\n",
" if i == N // 2:\n",
" print()\n",
" tracker.send(info)"
" if i >= N // 2:\n",
" tracker.send(info)"
]
},
{
Expand All @@ -99,24 +147,11 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {
"language": "python"
},
"outputs": [
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\">[03/20/23 18:59:31] </span><span style=\"color: #bfbf7f; text-decoration-color: #bfbf7f\">INFO </span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">0.00</span> seconds to execute `foo` <a href=\"file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py\" target=\"_blank\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">3733636588.py</span></a><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">:</span><a href=\"file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py#inner:8\" target=\"_blank\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">inner:8</span></a>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[2;36m[03/20/23 18:59:31]\u001b[0m\u001b[2;36m \u001b[0m\u001b[2;33mINFO \u001b[0m \u001b[1;36m0.00\u001b[0m seconds to execute `foo` \u001b]8;id=951613;file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py\u001b\\\u001b[2m3733636588.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=221759;file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py#inner:8\u001b\\\u001b[2minner:8\u001b[0m\u001b]8;;\u001b\\\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
Expand Down Expand Up @@ -247,36 +282,6 @@
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\"> </span><span style=\"color: #bfbf7f; text-decoration-color: #bfbf7f\">INFO </span> Args: <span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span> <a href=\"file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py\" target=\"_blank\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">3733636588.py</span></a><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">:</span><a href=\"file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py#inner:18\" target=\"_blank\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">inner:18</span></a>\n",
"<span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\"> </span> KWargs: <span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> </span>\n",
"<span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\"> </span> Output: <span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> </span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[2;36m \u001b[0m\u001b[2;36m \u001b[0m\u001b[2;33mINFO \u001b[0m Args: \u001b[3;35mNone\u001b[0m \u001b]8;id=157014;file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py\u001b\\\u001b[2m3733636588.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=358416;file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py#inner:18\u001b\\\u001b[2minner:18\u001b[0m\u001b]8;;\u001b\\\n",
"\u001b[2;36m \u001b[0m KWargs: \u001b[3;35mNone\u001b[0m \u001b[2m \u001b[0m\n",
"\u001b[2;36m \u001b[0m Output: \u001b[3;35mNone\u001b[0m \u001b[2m \u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\">[03/20/23 18:59:33] </span><span style=\"color: #bfbf7f; text-decoration-color: #bfbf7f\">INFO </span> <span style=\"color: #008080; text-decoration-color: #008080; font-weight: bold\">2.00</span> seconds to execute `foo` <a href=\"file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py\" target=\"_blank\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">3733636588.py</span></a><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">:</span><a href=\"file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py#inner:8\" target=\"_blank\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">inner:8</span></a>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[2;36m[03/20/23 18:59:33]\u001b[0m\u001b[2;36m \u001b[0m\u001b[2;33mINFO \u001b[0m \u001b[1;36m2.00\u001b[0m seconds to execute `foo` \u001b]8;id=139141;file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py\u001b\\\u001b[2m3733636588.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=352358;file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py#inner:8\u001b\\\u001b[2minner:8\u001b[0m\u001b]8;;\u001b\\\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
Expand Down Expand Up @@ -422,30 +427,13 @@
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/html": [
"<pre style=\"white-space:pre;overflow-x:auto;line-height:normal;font-family:Menlo,'DejaVu Sans Mono',consolas,'Courier New',monospace\"><span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\">[03/20/23 18:59:34] </span><span style=\"color: #bfbf7f; text-decoration-color: #bfbf7f\">INFO </span> Args: <span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span> <a href=\"file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py\" target=\"_blank\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">3733636588.py</span></a><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">:</span><a href=\"file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py#inner:18\" target=\"_blank\"><span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\">inner:18</span></a>\n",
"<span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\"> </span> KWargs: <span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> </span>\n",
"<span style=\"color: #7fbfbf; text-decoration-color: #7fbfbf\"> </span> Output: <span style=\"color: #800080; text-decoration-color: #800080; font-style: italic\">None</span> <span style=\"color: #7f7f7f; text-decoration-color: #7f7f7f\"> </span>\n",
"</pre>\n"
],
"text/plain": [
"\u001b[2;36m[03/20/23 18:59:34]\u001b[0m\u001b[2;36m \u001b[0m\u001b[2;33mINFO \u001b[0m Args: \u001b[3;35mNone\u001b[0m \u001b]8;id=156524;file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py\u001b\\\u001b[2m3733636588.py\u001b[0m\u001b]8;;\u001b\\\u001b[2m:\u001b[0m\u001b]8;id=522887;file:///var/folders/cp/1fbgq2n922j8ztdsq6551vldkr5sdy/T/ipykernel_9211/3733636588.py#inner:18\u001b\\\u001b[2minner:18\u001b[0m\u001b]8;;\u001b\\\n",
"\u001b[2;36m \u001b[0m KWargs: \u001b[3;35mNone\u001b[0m \u001b[2m \u001b[0m\n",
"\u001b[2;36m \u001b[0m Output: \u001b[3;35mNone\u001b[0m \u001b[2m \u001b[0m\n"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"data": {
"text/plain": [
"30"
]
},
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
Expand Down
14 changes: 14 additions & 0 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# Changelog

#### 0.506

Info, Debug, Warn and Excep will format ouputs separated by a `;` when args are passed
`notify_waiting` is a new function that letting you know some process is running for an unknown amount of time
optional `delay` during `shutdown_current_notebook`
Info, Debug, Warn and Excep will all have `X_mode` and `in_X_mode` functions much like in_debug_mode and debug_mode
`__init__` will auto pull from logger now
Better non-linear `Timer` (and `Report` and `track2`)

#### 0.505

🧹 `Info`, `Debug`, `Warn` and `Excep` will accept args (instead of a single arg)
🧹 `show` will show h4 headers instead of h2 for dataframe titles

#### 0.504

🧹 `phasify` loads by default
Expand Down
6 changes: 3 additions & 3 deletions conda/torch_snippets/meta.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package:
name: torch_snippets
version: '0.504'
version: '0.507'
source:
sha256: 28a4c1ea6ee4880feaab4d801ad5ec67fb70f43151ed2a16f1dad0817ecf8beb
url: https://files.pythonhosted.org/packages/f2/b5/95f75b7b74115a7ae98e20c3358397f02fb5670f5814faf4f75512de6787/torch_snippets-0.504.tar.gz
sha256: e08b504bf7acf5f510336573b2014ce08b533199023a850111823623788c08ab
url: https://files.pythonhosted.org/packages/db/59/61de774df04a6e09b8192dd40395f73a1da1806157f6132d5ec34dcd82d9/torch_snippets-0.507.tar.gz
about:
description: "# Utilities for simple needs\n\n\n\n## torch snippets does a lot of\
\ default importing for you\nWhether it is numpy, pandas, matplotlib or the useful\
Expand Down
2 changes: 1 addition & 1 deletion docs/decorators.html
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ <h3 class="anchored" data-anchor-id="timeit">timeit</h3>
OUTPUTS:
int: 21
══════════════════════════════════════════════════════════════════
[09/05/23 07:22:34] INFO foo took 1.04 seconds to execute &lt;ipython-input-1-2384d961f6ef&gt;:wrapper:7</code></pre>
[09/23/23 17:48:55] INFO foo took 1.02 seconds to execute &lt;ipython-input-1-2384d961f6ef&gt;:wrapper:7</code></pre>
</div>
<div class="cell-output cell-output-display" data-execution_count="4">
<pre><code>21</code></pre>
Expand Down
4 changes: 2 additions & 2 deletions docs/jupyter_notebook.html
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ <h3 class="anchored" data-anchor-id="show_big_dataframe">show_big_dataframe</h3>
<h3 class="anchored" data-anchor-id="display_dfs_side_by_side">display_dfs_side_by_side</h3>
<blockquote class="blockquote">
<pre><code> display_dfs_side_by_side (*args, titles=&lt;itertools.cycle object at
0x7fd845e00a80&gt;, max_rows=50)</code></pre>
0x7f88f1237100&gt;, max_rows=50)</code></pre>
</blockquote>
<hr>
</section>
Expand Down Expand Up @@ -409,7 +409,7 @@ <h3 class="anchored" data-anchor-id="h1">h1</h3>
<section id="shutdown_current_notebook" class="level3">
<h3 class="anchored" data-anchor-id="shutdown_current_notebook">shutdown_current_notebook</h3>
<blockquote class="blockquote">
<pre><code> shutdown_current_notebook ()</code></pre>
<pre><code> shutdown_current_notebook (delay:int=None)</code></pre>
</blockquote>


Expand Down
Loading

0 comments on commit 7b9503a

Please sign in to comment.