diff --git a/_proc/decorators.ipynb b/_proc/decorators.ipynb index 0e64312..a966511 100644 --- a/_proc/decorators.ipynb +++ b/_proc/decorators.ipynb @@ -139,7 +139,7 @@ "OUTPUTS:\n", "int: 21\n", "══════════════════════════════════════════════════════════════════\n", - "[12/25/23 17:14:46] INFO foo took 1.01 seconds to execute :wrapper:7\n" + "[12/25/23 17:20:39] INFO foo took 1.03 seconds to execute :wrapper:7\n" ] }, { diff --git a/_proc/jupyter_notebook.ipynb b/_proc/jupyter_notebook.ipynb index 1462497..ff599e0 100644 --- a/_proc/jupyter_notebook.ipynb +++ b/_proc/jupyter_notebook.ipynb @@ -213,7 +213,7 @@ "### display_dfs_side_by_side\n", "\n", "> display_dfs_side_by_side (*args, titles= 0x7feb97a4a880>, max_rows=50)" + "> 0x7fca9e249180>, max_rows=50)" ], "text/plain": [ "---\n", @@ -221,7 +221,7 @@ "### display_dfs_side_by_side\n", "\n", "> display_dfs_side_by_side (*args, titles= 0x7feb97a4a880>, max_rows=50)" + "> 0x7fca9e249180>, max_rows=50)" ] }, "execution_count": 6, diff --git a/_proc/markups.ipynb b/_proc/markups.ipynb index dac58fd..a5c1195 100644 --- a/_proc/markups.ipynb +++ b/_proc/markups.ipynb @@ -447,7 +447,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "[12/25/23 17:14:45] INFO loaded 8 lines ::6\n", + "[12/25/23 17:20:38] INFO loaded 8 lines ::6\n", "{\n", "\"a\": [\n", "1.0,\n", diff --git a/changelog.md b/changelog.md index a08af2b..921f637 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,9 @@ # Changelog +#### 0.517 + +🐞 `print_shapes_hook` will gracefully fail + #### 0.516 🐞 `attach` will add hook to the input module as well (not just the children) diff --git a/conda/torch_snippets/meta.yaml b/conda/torch_snippets/meta.yaml index 193c5e3..7895dba 100644 --- a/conda/torch_snippets/meta.yaml +++ b/conda/torch_snippets/meta.yaml @@ -1,9 +1,9 @@ package: name: torch_snippets - version: '0.516' + version: '0.517' source: - sha256: e8085ad6d1adc834a0ba1a267361dbeee148cfe2f117d2b6332137cdc2b39a76 - url: https://files.pythonhosted.org/packages/fe/39/743bb8dd223dad384b7e83c2618658caa9c56256985833767c75400016be/torch_snippets-0.516.tar.gz + sha256: aa7ed4b2b1a755e90d7983d8e159a1f9784fe7aa6c361845c45117c02b3368cb + url: https://files.pythonhosted.org/packages/40/62/d2d4b822f6e71c7f93f3f6ceb0326c88b5c64888b71d7bd0df8ceacfc3fb/torch_snippets-0.517.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\ diff --git a/docs/decorators.html b/docs/decorators.html index d315390..4410371 100644 --- a/docs/decorators.html +++ b/docs/decorators.html @@ -347,7 +347,7 @@

timeit

OUTPUTS: int: 21 ══════════════════════════════════════════════════════════════════ -[12/25/23 17:14:46] INFO foo took 1.01 seconds to execute <ipython-input-1-2384d961f6ef>:wrapper:7 +[12/25/23 17:20:39] INFO foo took 1.03 seconds to execute <ipython-input-1-2384d961f6ef>:wrapper:7
21
diff --git a/docs/jupyter_notebook.html b/docs/jupyter_notebook.html index cdda7a3..b9c7374 100644 --- a/docs/jupyter_notebook.html +++ b/docs/jupyter_notebook.html @@ -368,7 +368,7 @@

show_big_dataframe

display_dfs_side_by_side

 display_dfs_side_by_side (*args, titles=<itertools.cycle object at
-                           0x7feb97a4a880>, max_rows=50)
+ 0x7fca9e249180>, max_rows=50)

diff --git a/docs/markups.html b/docs/markups.html index 79181f9..72b9000 100644 --- a/docs/markups.html +++ b/docs/markups.html @@ -443,7 +443,7 @@

read_json

except ModuleNotFoundError: ...
-
[12/25/23 17:14:45] INFO     loaded 8 lines                                                                                        <ipython-input-1-e6d68859b80d>:<module>:6
+
[12/25/23 17:20:38] INFO     loaded 8 lines                                                                                        <ipython-input-1-e6d68859b80d>:<module>:6
 {
 "a": [
 1.0,
diff --git a/docs/search.json b/docs/search.json
index 8f34816..1431b95 100644
--- a/docs/search.json
+++ b/docs/search.json
@@ -4,14 +4,14 @@
     "href": "decorators.html",
     "title": "Decorator Utilites",
     "section": "",
-    "text": "check_kwargs_not_none\n\n check_kwargs_not_none (func)\n\n\n\n\nio\n\n io (func)\n\n\n\n\ntimeit\n\n timeit (func)\n\n\n@timeit\n@io\ndef foo(a, b):\n    import time\n\n    time.sleep(1)\n    return a + b\n\n\nfoo(10, 11)\n\n══════════════════════════════════════════════════════════════════\nINPUTS:ARGS:\ntuple of 2 items\n        int: 10\n        int: 11\n══════════════════════════════════════════════════════════════════\n══════════════════════════════════════════════════════════════════\nOUTPUTS:\nint: 21\n══════════════════════════════════════════════════════════════════\n[12/25/23 17:14:46] INFO     foo took 1.01 seconds to execute                                                                       :wrapper:7\n\n\n21\n\n\n\n@check_kwargs_not_none\n@io\ndef foo(*, a=None, b=None):\n    return a + b\n\n\nfoo(a=None, b=10)\n\nValueError: Input argument 'a' cannot be None\n\n\n\nimport nbdev\n\nnbdev.nbdev_export()"
+    "text": "check_kwargs_not_none\n\n check_kwargs_not_none (func)\n\n\n\n\nio\n\n io (func)\n\n\n\n\ntimeit\n\n timeit (func)\n\n\n@timeit\n@io\ndef foo(a, b):\n    import time\n\n    time.sleep(1)\n    return a + b\n\n\nfoo(10, 11)\n\n══════════════════════════════════════════════════════════════════\nINPUTS:ARGS:\ntuple of 2 items\n        int: 10\n        int: 11\n══════════════════════════════════════════════════════════════════\n══════════════════════════════════════════════════════════════════\nOUTPUTS:\nint: 21\n══════════════════════════════════════════════════════════════════\n[12/25/23 17:20:39] INFO     foo took 1.03 seconds to execute                                                                       :wrapper:7\n\n\n21\n\n\n\n@check_kwargs_not_none\n@io\ndef foo(*, a=None, b=None):\n    return a + b\n\n\nfoo(a=None, b=10)\n\nValueError: Input argument 'a' cannot be None\n\n\n\nimport nbdev\n\nnbdev.nbdev_export()"
   },
   {
     "objectID": "markups.html",
     "href": "markups.html",
     "title": "Markups",
     "section": "",
-    "text": "AttrDict\n\n AttrDict (data=None, **kwargs)\n\nUtility class to interact with a dictionary as if it were an object. AD is an alias to this class\nFEATURES: 0. Access and modify keys (including nested keys) as if they were object attributes, supporting tab-completion. Example: self.key1.key2[0].key3 1. Keys and values are recursively converted to AttrDict instances. 2. Pretty-print the dictionary using self.pretty(). 3. Convert the entire structure to a regular dictionary at any time using self.to_dict(). 3. Recursively remove keys using self.drop(key) from a JSON object. 4. Apply a function to all values at all levels using map.\nGOTCHAS: 1. All integer keys are implicitly converted to strings due to the enforced self.key format. 2. You can still use self[int], but this internally converts the integer to a string.\nMETHODS: - items(): Return the items of the AttrDict as key-value pairs. - keys(): Return the keys of the AttrDict. - values(): Return the values of the AttrDict. - update(dict): Update the AttrDict with key-value pairs from another dictionary. - get(key, default=None): Get the value associated with a key, with an optional default value. - __iter__(): Allow iteration over the keys of the AttrDict. - __len__(): Return the number of keys in the AttrDict. - __repr__(): Return a string representation of the AttrDict. - __dir__(): List the keys of the AttrDict as attributes. - __contains__(key): Check if a key exists in the AttrDict. - __delitem__(key): Delete a key from the AttrDict. - map(func): Apply a function to all values in the AttrDict. - drop(key): Recursively remove a key and its values from the AttrDict. - to_dict(): Convert the AttrDict and its nested structure to a regular dictionary. - pretty(print_with_logger=False, *args, **kwargs): Pretty-print the AttrDict as JSON. - __eq__(other): Compare the AttrDict with another dictionary for equality. - find_address(key, current_path=\"\"): Find and return all addresses (paths) of a given key in the AttrDict. - summary(current_path='', summary_str='', depth=0, sep='  '): Generate a summary of the structure and values in the AttrDict. - write_summary(to, **kwargs): Write the summary to a file or stream. - fetch(addr): Retrieve a value at a specified address (path).\nPARAMETERS: - data (dict, optional): Initial data to populate the AttrDict.\nUSAGE: - Create an AttrDict instance by providing an optional initial dictionary, and then access and manipulate its contents as if they were object attributes.\nEXAMPLE:\nmy_dict = {'name': 'John', 'age': 30, 'address': {'city': 'New York', 'zip': '10001'}}\nattr_dict = AttrDict(my_dict)\nprint(attr_dict.name)  # Access values like attributes\nattr_dict.address.city = 'Los Angeles'  # Modify nested values\n\nxx = AttrDict({\"a\": 1, \"b\": [{\"c\": 2, \"d\": 4}, {\"e\": 3}]})\nprint(type(xx.b[0]))\nprint(type(xx.to_dict()[\"b\"][0]))\nxx.pretty()\n\n\n\n\n\n\n\n\n\n{\n    \"a\": 1,\n    \"b\": [\n        {\n            \"c\": 2,\n            \"d\": 4\n        },\n        {\n            \"e\": 3\n        }\n    ]\n}\n\n\n\n\nx = {\"abc\": {\"b\": 10, \"c\": 11}, \"d\": {\"e\": {\"f\": [2, {\"abc\": \"pqrs\"}, 2.234]}}}\n\ny = AttrDict(x)\n\nassert y.abc.b == 10\nassert y.d.e.f == [2, {\"abc\": \"pqrs\"}, 2.234]\n\ny.d.e.g = 11\n\n# del y.abc.c\n# OR\ndel y[\"abc\"][\"c\"]\n\nassert y.to_dict() == {\n    \"abc\": {\"b\": 10},\n    \"d\": {\"e\": {\"f\": [2, {\"abc\": \"pqrs\"}, 2.234], \"g\": 11}},\n}\n\ny.pretty(indent=2)\n\nassert \"abc\" in y\nassert \"def\" not in y\nprint(\"e\" in y.d)\n\n{\n  \"abc\": {\n    \"b\": 10\n  },\n  \"d\": {\n    \"e\": {\n      \"f\": [\n        2,\n        {\n          \"abc\": \"pqrs\"\n        },\n        2.234\n      ],\n      \"g\": 11\n    }\n  }\n}\n\n\n\nTrue\n\n\n\n\nx = {\"abc\": {\"b\": 10, \"c\": 11}, \"d\": {\"e\": {\"f\": [2, {\"abc\": \"pqrs\"}, 2.234]}}}\ny = AttrDict(x)\ny.abc[[\"b\", \"c\"]]\n\n{'b': 10, 'c': 11}\n\n\n\n\n\nwrite_json\n\n write_json (obj, fpath, silent=False)\n\n\n\n\nread_json\n\n read_json (fpath)\n\n\ntry:\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\")))\nexcept ModuleNotFoundError:\n    ...\n\n[12/25/23 17:14:45] INFO     loaded 8 lines                                                                                        ::6\n{\n\"a\": [\n1.0,\n2.0,\n3.0\n],\n\"b\": \"hello\"\n}\n\n\n\nd = [1, {1: 1, 2: 2}, 3]\n\npretty_json({1: 1, 2: 2})\npretty_json(d)\n\nf = write_json(d, \"/tmp/test.json\")\nprint(f)\nread_json(f)\n\n/tmp/test.json\n\n\n\n[1, {'1': 1, '2': 2}, 3]\n\n\n\n\n\nread_jsonl\n\n read_jsonl (file)\n\n\n\n\nwrite_jsonl\n\n write_jsonl (items, dest, mode='w')\n\n\n\n\nwrite_yaml\n\n write_yaml (content, fpath)\n\n\n\n\nread_yaml\n\n read_yaml (file)\n\n\n\n\nwrite_xml\n\n write_xml (data:Union[__main__.AttrDict,dict],\n            file_path:Union[str,pathlib.Path])\n\n\n\n\nread_xml\n\n read_xml (file_path:Union[str,pathlib.Path])\n\nRead xml data as a dictionary\n\ny\n\n{'abc': {'b': 10, 'c': 11}, 'd': {'e': {'f': [2, {'abc': 'pqrs'}, 2.234]}}}\n\n\n\nprint(y.summary())\n\nabc\n        b - int\n        c - int\nd\n        e\n                f - L"
+    "text": "AttrDict\n\n AttrDict (data=None, **kwargs)\n\nUtility class to interact with a dictionary as if it were an object. AD is an alias to this class\nFEATURES: 0. Access and modify keys (including nested keys) as if they were object attributes, supporting tab-completion. Example: self.key1.key2[0].key3 1. Keys and values are recursively converted to AttrDict instances. 2. Pretty-print the dictionary using self.pretty(). 3. Convert the entire structure to a regular dictionary at any time using self.to_dict(). 3. Recursively remove keys using self.drop(key) from a JSON object. 4. Apply a function to all values at all levels using map.\nGOTCHAS: 1. All integer keys are implicitly converted to strings due to the enforced self.key format. 2. You can still use self[int], but this internally converts the integer to a string.\nMETHODS: - items(): Return the items of the AttrDict as key-value pairs. - keys(): Return the keys of the AttrDict. - values(): Return the values of the AttrDict. - update(dict): Update the AttrDict with key-value pairs from another dictionary. - get(key, default=None): Get the value associated with a key, with an optional default value. - __iter__(): Allow iteration over the keys of the AttrDict. - __len__(): Return the number of keys in the AttrDict. - __repr__(): Return a string representation of the AttrDict. - __dir__(): List the keys of the AttrDict as attributes. - __contains__(key): Check if a key exists in the AttrDict. - __delitem__(key): Delete a key from the AttrDict. - map(func): Apply a function to all values in the AttrDict. - drop(key): Recursively remove a key and its values from the AttrDict. - to_dict(): Convert the AttrDict and its nested structure to a regular dictionary. - pretty(print_with_logger=False, *args, **kwargs): Pretty-print the AttrDict as JSON. - __eq__(other): Compare the AttrDict with another dictionary for equality. - find_address(key, current_path=\"\"): Find and return all addresses (paths) of a given key in the AttrDict. - summary(current_path='', summary_str='', depth=0, sep='  '): Generate a summary of the structure and values in the AttrDict. - write_summary(to, **kwargs): Write the summary to a file or stream. - fetch(addr): Retrieve a value at a specified address (path).\nPARAMETERS: - data (dict, optional): Initial data to populate the AttrDict.\nUSAGE: - Create an AttrDict instance by providing an optional initial dictionary, and then access and manipulate its contents as if they were object attributes.\nEXAMPLE:\nmy_dict = {'name': 'John', 'age': 30, 'address': {'city': 'New York', 'zip': '10001'}}\nattr_dict = AttrDict(my_dict)\nprint(attr_dict.name)  # Access values like attributes\nattr_dict.address.city = 'Los Angeles'  # Modify nested values\n\nxx = AttrDict({\"a\": 1, \"b\": [{\"c\": 2, \"d\": 4}, {\"e\": 3}]})\nprint(type(xx.b[0]))\nprint(type(xx.to_dict()[\"b\"][0]))\nxx.pretty()\n\n\n\n\n\n\n\n\n\n{\n    \"a\": 1,\n    \"b\": [\n        {\n            \"c\": 2,\n            \"d\": 4\n        },\n        {\n            \"e\": 3\n        }\n    ]\n}\n\n\n\n\nx = {\"abc\": {\"b\": 10, \"c\": 11}, \"d\": {\"e\": {\"f\": [2, {\"abc\": \"pqrs\"}, 2.234]}}}\n\ny = AttrDict(x)\n\nassert y.abc.b == 10\nassert y.d.e.f == [2, {\"abc\": \"pqrs\"}, 2.234]\n\ny.d.e.g = 11\n\n# del y.abc.c\n# OR\ndel y[\"abc\"][\"c\"]\n\nassert y.to_dict() == {\n    \"abc\": {\"b\": 10},\n    \"d\": {\"e\": {\"f\": [2, {\"abc\": \"pqrs\"}, 2.234], \"g\": 11}},\n}\n\ny.pretty(indent=2)\n\nassert \"abc\" in y\nassert \"def\" not in y\nprint(\"e\" in y.d)\n\n{\n  \"abc\": {\n    \"b\": 10\n  },\n  \"d\": {\n    \"e\": {\n      \"f\": [\n        2,\n        {\n          \"abc\": \"pqrs\"\n        },\n        2.234\n      ],\n      \"g\": 11\n    }\n  }\n}\n\n\n\nTrue\n\n\n\n\nx = {\"abc\": {\"b\": 10, \"c\": 11}, \"d\": {\"e\": {\"f\": [2, {\"abc\": \"pqrs\"}, 2.234]}}}\ny = AttrDict(x)\ny.abc[[\"b\", \"c\"]]\n\n{'b': 10, 'c': 11}\n\n\n\n\n\nwrite_json\n\n write_json (obj, fpath, silent=False)\n\n\n\n\nread_json\n\n read_json (fpath)\n\n\ntry:\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\")))\nexcept ModuleNotFoundError:\n    ...\n\n[12/25/23 17:20:38] INFO     loaded 8 lines                                                                                        ::6\n{\n\"a\": [\n1.0,\n2.0,\n3.0\n],\n\"b\": \"hello\"\n}\n\n\n\nd = [1, {1: 1, 2: 2}, 3]\n\npretty_json({1: 1, 2: 2})\npretty_json(d)\n\nf = write_json(d, \"/tmp/test.json\")\nprint(f)\nread_json(f)\n\n/tmp/test.json\n\n\n\n[1, {'1': 1, '2': 2}, 3]\n\n\n\n\n\nread_jsonl\n\n read_jsonl (file)\n\n\n\n\nwrite_jsonl\n\n write_jsonl (items, dest, mode='w')\n\n\n\n\nwrite_yaml\n\n write_yaml (content, fpath)\n\n\n\n\nread_yaml\n\n read_yaml (file)\n\n\n\n\nwrite_xml\n\n write_xml (data:Union[__main__.AttrDict,dict],\n            file_path:Union[str,pathlib.Path])\n\n\n\n\nread_xml\n\n read_xml (file_path:Union[str,pathlib.Path])\n\nRead xml data as a dictionary\n\ny\n\n{'abc': {'b': 10, 'c': 11}, 'd': {'e': {'f': [2, {'abc': 'pqrs'}, 2.234]}}}\n\n\n\nprint(y.summary())\n\nabc\n        b - int\n        c - int\nd\n        e\n                f - L"
   },
   {
     "objectID": "interactive_show.html",
@@ -74,7 +74,7 @@
     "href": "jupyter_notebook.html",
     "title": "Jupyter Notebooks",
     "section": "",
-    "text": "is_in_notebook\n\n is_in_notebook ()\n\n\n\n\nbackup_all_notebooks\n\n backup_all_notebooks (folder)\n\n\n\n\nbackup_this_notebook\n\n backup_this_notebook (this_file_path, save_html_to=None,\n                       override_previous_backup=False, changelog=None,\n                       exclude_input=False, force_save_notebook=True)\n\n\n\n\nsave_notebook\n\n save_notebook (file_path)\n\n\nbackup_this_notebook(\"jupyter_notebook.ipynb\")\n\n\n\n\nshow_big_dataframe\n\n show_big_dataframe (df, max_rows=30)\n\n\n\n\ndisplay_dfs_side_by_side\n\n display_dfs_side_by_side (*args, titles=, max_rows=50)\n\n\n\n\nh6\n\n h6 (text)\n\n\n\n\nh5\n\n h5 (text)\n\n\n\n\nh4\n\n h4 (text)\n\n\n\n\nh3\n\n h3 (text)\n\n\n\n\nh2\n\n h2 (text)\n\n\n\n\nh1\n\n h1 (text)\n\n\n\n\nshutdown_current_notebook\n\n shutdown_current_notebook (delay:int=None)"
+    "text": "is_in_notebook\n\n is_in_notebook ()\n\n\n\n\nbackup_all_notebooks\n\n backup_all_notebooks (folder)\n\n\n\n\nbackup_this_notebook\n\n backup_this_notebook (this_file_path, save_html_to=None,\n                       override_previous_backup=False, changelog=None,\n                       exclude_input=False, force_save_notebook=True)\n\n\n\n\nsave_notebook\n\n save_notebook (file_path)\n\n\nbackup_this_notebook(\"jupyter_notebook.ipynb\")\n\n\n\n\nshow_big_dataframe\n\n show_big_dataframe (df, max_rows=30)\n\n\n\n\ndisplay_dfs_side_by_side\n\n display_dfs_side_by_side (*args, titles=, max_rows=50)\n\n\n\n\nh6\n\n h6 (text)\n\n\n\n\nh5\n\n h5 (text)\n\n\n\n\nh4\n\n h4 (text)\n\n\n\n\nh3\n\n h3 (text)\n\n\n\n\nh2\n\n h2 (text)\n\n\n\n\nh1\n\n h1 (text)\n\n\n\n\nshutdown_current_notebook\n\n shutdown_current_notebook (delay:int=None)"
   },
   {
     "objectID": "config.html",
diff --git a/docs/sitemap.xml b/docs/sitemap.xml
index 2c71619..443f679 100644
--- a/docs/sitemap.xml
+++ b/docs/sitemap.xml
@@ -2,90 +2,90 @@
 
   
     https://sizhky.github.io/torch_snippets/decorators.html
-    2023-12-25T11:44:51.909Z
+    2023-12-25T11:50:46.216Z
   
   
     https://sizhky.github.io/torch_snippets/markups.html
-    2023-12-25T11:44:52.481Z
+    2023-12-25T11:50:46.715Z
   
   
     https://sizhky.github.io/torch_snippets/interactive_show.html
-    2023-12-25T11:44:52.991Z
+    2023-12-25T11:50:47.100Z
   
   
     https://sizhky.github.io/torch_snippets/load_defautls.html
-    2023-12-25T11:44:53.460Z
+    2023-12-25T11:50:47.480Z
   
   
     https://sizhky.github.io/torch_snippets/sklegos.html
-    2023-12-25T11:44:53.910Z
+    2023-12-25T11:50:47.870Z
   
   
     https://sizhky.github.io/torch_snippets/bounding_boxes.html
-    2023-12-25T11:44:54.433Z
+    2023-12-25T11:50:48.355Z
   
   
     https://sizhky.github.io/torch_snippets/show.html
-    2023-12-25T11:44:54.929Z
+    2023-12-25T11:50:48.816Z
   
   
     https://sizhky.github.io/torch_snippets/pdf.html
-    2023-12-25T11:44:55.380Z
+    2023-12-25T11:50:49.201Z
   
   
     https://sizhky.github.io/torch_snippets/charts.html
-    2023-12-25T11:44:55.813Z
+    2023-12-25T11:50:49.621Z
   
   
     https://sizhky.github.io/torch_snippets/paths.html
-    2023-12-25T11:44:56.307Z
+    2023-12-25T11:50:50.085Z
   
   
     https://sizhky.github.io/torch_snippets/jupyter_notebook.html
-    2023-12-25T11:44:56.702Z
+    2023-12-25T11:50:50.460Z
   
   
     https://sizhky.github.io/torch_snippets/config.html
-    2023-12-25T11:44:57.108Z
+    2023-12-25T11:50:50.967Z
   
   
     https://sizhky.github.io/torch_snippets/misc.html
-    2023-12-25T11:44:57.548Z
+    2023-12-25T11:50:51.410Z
   
   
     https://sizhky.github.io/torch_snippets/registry.html
-    2023-12-25T11:44:57.998Z
+    2023-12-25T11:50:51.813Z
   
   
     https://sizhky.github.io/torch_snippets/adapters.html
-    2023-12-25T11:44:58.470Z
+    2023-12-25T11:50:52.196Z
   
   
     https://sizhky.github.io/torch_snippets/report.html
-    2023-12-25T11:44:58.903Z
+    2023-12-25T11:50:52.606Z
   
   
     https://sizhky.github.io/torch_snippets/capsule.html
-    2023-12-25T11:44:59.339Z
+    2023-12-25T11:50:53.360Z
   
   
     https://sizhky.github.io/torch_snippets/logging.html
-    2023-12-25T11:44:59.863Z
+    2023-12-25T11:50:53.891Z
   
   
     https://sizhky.github.io/torch_snippets/inspector.html
-    2023-12-25T11:45:00.368Z
+    2023-12-25T11:50:54.310Z
   
   
     https://sizhky.github.io/torch_snippets/bokeh_plotting.html
-    2023-12-25T11:45:00.869Z
+    2023-12-25T11:50:54.697Z
   
   
     https://sizhky.github.io/torch_snippets/index.html
-    2023-12-25T11:45:01.338Z
+    2023-12-25T11:50:55.143Z
   
   
     https://sizhky.github.io/torch_snippets/imgaug_loader.html
-    2023-12-25T11:45:01.917Z
+    2023-12-25T11:50:55.695Z
   
 
diff --git a/settings.ini b/settings.ini
index f5b982f..aa083ea 100644
--- a/settings.ini
+++ b/settings.ini
@@ -8,7 +8,7 @@ author = Yeshwanth Reddy
 author_email = 1992chinna@gmail.com
 copyright = sizhky
 branch = master
-version = 0.516
+version = 0.517
 min_python = 3.8
 audience = Developers
 language = English
diff --git a/torch_snippets.egg-info/PKG-INFO b/torch_snippets.egg-info/PKG-INFO
index 06fa2a8..4082fc7 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.516
+Version: 0.517
 Summary: One line functions for common tasks
 Home-page: https://github.com/sizhky/torch_snippets/tree/master/
 Author: Yeshwanth Reddy
diff --git a/torch_snippets/__init__.py b/torch_snippets/__init__.py
index d94fa4d..6d2c153 100644
--- a/torch_snippets/__init__.py
+++ b/torch_snippets/__init__.py
@@ -1,4 +1,4 @@
-__version__ = "0.516"
+__version__ = "0.517"
 from .loader import *
 from .paths import *
 from .markup import *
diff --git a/torch_snippets/trainer/hooks.py b/torch_snippets/trainer/hooks.py
index a5bfc00..e2473a2 100644
--- a/torch_snippets/trainer/hooks.py
+++ b/torch_snippets/trainer/hooks.py
@@ -107,15 +107,33 @@ def detach_hooks(handles):
 
 @contextmanager
 def hook_context_for(module, hook_fn, **kwargs):
-    hook_fn = partial(hook_fn, **kwargs)
-    handles = attach_hooks(module, hook_fn)
-    yield module
-    detach_hooks(handles)
+    try:
+        hook_fn = partial(hook_fn, **kwargs)
+        handles = attach_hooks(module, hook_fn)
+        yield module
+        detach_hooks(handles)
+    except Exception as e:
+        Warn(f"Error: {e}")
+    finally:
+        try:
+            detach_hooks(handles)
+        except:
+            # nothing needs to be done
+            ...
 
 
 @contextmanager
 def print_module_ios_for(module, print_only=None):
-    _print_shapes_hook = partial(print_shapes_hook, keep=print_only)
-    handles = attach_hooks(module, _print_shapes_hook)
-    yield module
-    detach_hooks(handles)
+    try:
+        _print_shapes_hook = partial(print_shapes_hook, keep=print_only)
+        handles = attach_hooks(module, _print_shapes_hook)
+        yield module
+        detach_hooks(handles)
+    except Exception as e:
+        Warn(f"Error: {e}")
+    finally:
+        try:
+            detach_hooks(handles)
+        except:
+            # nothing needs to be done
+            ...