Skip to content

Commit

Permalink
Add optional debug logging steps to Jupyter Notebooks (#43)
Browse files Browse the repository at this point in the history
* Add optional debug logging steps to Jupyter Notebooks

Also hide checkpoints files from git.

* Add newline to end of file
  • Loading branch information
araglu committed Jun 6, 2023
1 parent 2fbd8ae commit fb8a4a1
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -69,3 +69,6 @@ target/

# ViM Files
*.swp

# Jupyter Notebook checkpoints
.ipynb_checkpoints
28 changes: 27 additions & 1 deletion examples/auth_popup.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,32 @@
"c = uit.Client()"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## (Optional) Enable Debug Logging\n",
"\n",
"This will display every command sent to the HPC through UIT+, which login node was used, how long each command took, and a very brief stacktrace."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"handler = logging.StreamHandler()\n",
"formatter = logging.Formatter('%(asctime)s %(levelname)s:%(name)s:%(message)s')\n",
"handler.setFormatter(formatter)\n",
"logger = logging.getLogger('uit')\n",
"logger.handlers.clear()\n",
"logger.addHandler(handler)\n",
"logger.setLevel('DEBUG')\n",
"logger.debug('Test pyuit debug logging')"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -121,7 +147,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.12"
"version": "3.10.10"
}
},
"nbformat": 4,
Expand Down
34 changes: 30 additions & 4 deletions examples/pyUIT Demo.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,32 @@
"import uit"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## (Optional) Enable Debug Logging\n",
"\n",
"This will display every command sent to the HPC through UIT+, which login node was used, how long each command took, and a very brief stacktrace."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"import logging\n",
"handler = logging.StreamHandler()\n",
"formatter = logging.Formatter('%(asctime)s %(levelname)s:%(name)s:%(message)s')\n",
"handler.setFormatter(formatter)\n",
"logger = logging.getLogger('uit')\n",
"logger.handlers.clear()\n",
"logger.addHandler(handler)\n",
"logger.setLevel('DEBUG')\n",
"logger.debug('Test pyuit debug logging')"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -61,7 +87,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Next, we need to connect to a specific HPC system. Currently `onyx` is the only available system. Soon `jim` will be added, and other DSRC systems can be added in the future. "
"Next, we need to connect to a specific HPC system. Currently `onyx`, `narwhal`, and `mustang` are the available systems. Other DSRC systems can be added in the future. "
]
},
{
Expand All @@ -86,7 +112,7 @@
"source": [
"## Basic Usage\n",
"\n",
"By default, the `call` method will execute the command in the users $HOME directory. You can optionally pass in a `work_dir` argument to specify a different directory."
"By default, the `call` method will execute the command in the users $HOME directory. You can optionally pass in a `working_dir` argument to specify a different directory."
]
},
{
Expand All @@ -102,7 +128,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Notice that we passed in `c.WORKDIR` as the value for the `working_dir` argument. The `uit.Client` object has a few properties for common environment variables that are returned as `PosixPath` objects. Other environment variables that can be accesed as properties include:"
"Note that we passed in `c.WORKDIR` as the value for the `working_dir` argument. The `uit.Client` object has a few properties for common environment variables that are returned as `PosixPath` objects. Other environment variables that can be accessed as properties include:"
]
},
{
Expand Down Expand Up @@ -383,7 +409,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.12"
"version": "3.10.10"
}
},
"nbformat": 4,
Expand Down

0 comments on commit fb8a4a1

Please sign in to comment.