Skip to content

Commit

Permalink
Changelog + notebook note on logger
Browse files Browse the repository at this point in the history
  • Loading branch information
CBroz1 committed Dec 21, 2023
1 parent 63eec83 commit a01d2d7
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 16 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
- Refactor restriction use in `delete_downstream_merge` #703
- Add `cautious_delete` to Mixin class, initial implementation. #711
- Add `deprecation_factory` to facilitate table migration. #717
- Add Spyglass logger. #730

### Pipelines

Expand Down
24 changes: 14 additions & 10 deletions notebooks/00_Setup.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"1. [Python 3.9](https://wiki.python.org/moin/BeginnersGuide/Download).\n",
"2. [mamba](https://mamba.readthedocs.io/en/latest/installation.html) as a\n",
" replacement for conda. Spyglass installation is significantly faster with\n",
" mamba. \n",
" mamba.\n",
" ```bash\n",
" wget \"https://github.com/conda-forge/miniforge/releases/latest/download/Miniforge3-$(uname)-$(uname -m).sh\"\n",
" bash Miniforge3-$(uname)-$(uname -m).sh\n",
Expand Down Expand Up @@ -133,7 +133,7 @@
"```\n",
"\n",
"Members of the lab can run the `dj_config.py` helper script to generate a config\n",
"like the one below. \n",
"like the one below.\n",
"\n",
"```bash\n",
"cd spyglass\n",
Expand All @@ -148,17 +148,16 @@
"[docs](https://lorenfranklab.github.io/spyglass/0.4/installation/) for more\n",
"information on subdirectories.\n",
"\n",
"A different `output_filename` will save different files: \n",
"A different `output_filename` will save different files:\n",
"\n",
"- `dj_local_conf.json`: Recommended. Used for tutorials. A file in the current\n",
" directory DataJoint will automatically recognize when a Python session is\n",
" launched from this directory.\n",
"- `.datajoint_config.json` or no input: A file in the user's home directory \n",
"- `.datajoint_config.json` or no input: A file in the user's home directory\n",
" that will be referenced whenever no local version (see above) is present.\n",
"- Anything else: A custom name that will need to be loaded (e.g.,\n",
" `dj.load('x')`) for each python session.\n",
"\n",
"\n",
"The config will be a `json` file like the following.\n",
"\n",
"```json\n",
Expand All @@ -170,6 +169,7 @@
" \"database.use_tls\": true,\n",
" \"enable_python_native_blobs\": true,\n",
" \"filepath_checksum_size_limit\": 1 * 1024**3,\n",
" \"loglevel\": \"INFO\",\n",
" \"stores\": {\n",
" \"raw\": {\n",
" \"protocol\": \"file\",\n",
Expand All @@ -190,14 +190,18 @@
"}\n",
"```\n",
"\n",
"Spyglass will use the log level present in your DataJoint config to decide the\n",
"appropriate logging level for this session. To change the messages you see,\n",
"select from one of [these options](https://docs.python.org/3/library/logging.html#levels).\n",
"\n",
"If you see an error saying `Could not find SPYGLASS_BASE_DIR`, try loading your\n",
"config before importing Spyglass.\n",
"\n",
"```python\n",
"import datajoint as dj\n",
"dj.load('/path/to/config')\n",
"import spyglass\n",
"```"
"```\n"
]
},
{
Expand Down Expand Up @@ -226,8 +230,8 @@
" ```\n",
"\n",
"_Note_: For this demo, MySQL version won't matter. Some\n",
" [database management](https://lorenfranklab.github.io/spyglass/latest/misc/database_management/#mysql-version)\n",
" features of Spyglass, however, expect MySQL >= 8.\n",
"[database management](https://lorenfranklab.github.io/spyglass/latest/misc/database_management/#mysql-version)\n",
"features of Spyglass, however, expect MySQL >= 8.\n",
"\n",
"- When run, this is referred to as a 'Docker container'\n",
"- Next start the container with a couple additional pieces of info...\n",
Expand Down Expand Up @@ -277,7 +281,7 @@
"source": [
"### Loading the config\n",
"\n",
"We can check that the paths are correctly set up by loading the config from \n",
"We can check that the paths are correctly set up by loading the config from\n",
"the main Spyglass directory.\n"
]
},
Expand Down Expand Up @@ -471,7 +475,7 @@
"id": "13fd64af",
"metadata": {},
"source": [
"# Up Next"
"# Up Next\n"
]
},
{
Expand Down
13 changes: 9 additions & 4 deletions notebooks/py_scripts/00_Setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
# - Anything else: A custom name that will need to be loaded (e.g.,
# `dj.load('x')`) for each python session.
#
#
# The config will be a `json` file like the following.
#
# ```json
Expand All @@ -147,6 +146,7 @@
# "database.use_tls": true,
# "enable_python_native_blobs": true,
# "filepath_checksum_size_limit": 1 * 1024**3,
# "loglevel": "INFO",
# "stores": {
# "raw": {
# "protocol": "file",
Expand All @@ -167,6 +167,10 @@
# }
# ```
#
# Spyglass will use the log level present in your DataJoint config to decide the
# appropriate logging level for this session. To change the messages you see,
# select from one of [these options](https://docs.python.org/3/library/logging.html#levels).
#
# If you see an error saying `Could not find SPYGLASS_BASE_DIR`, try loading your
# config before importing Spyglass.
#
Expand All @@ -175,6 +179,7 @@
# dj.load('/path/to/config')
# import spyglass
# ```
#

# ### Running your own database
#
Expand All @@ -192,8 +197,8 @@
# ```
#
# _Note_: For this demo, MySQL version won't matter. Some
# [database management](https://lorenfranklab.github.io/spyglass/latest/misc/database_management/#mysql-version)
# features of Spyglass, however, expect MySQL >= 8.
# [database management](https://lorenfranklab.github.io/spyglass/latest/misc/database_management/#mysql-version)
# features of Spyglass, however, expect MySQL >= 8.
#
# - When run, this is referred to as a 'Docker container'
# - Next start the container with a couple additional pieces of info...
Expand Down Expand Up @@ -244,7 +249,6 @@

# +
import os

import datajoint as dj

if os.path.basename(os.getcwd()) == "notebooks":
Expand All @@ -270,6 +274,7 @@
# -

# # Up Next
#

# Next, we'll try [inserting data](./01_Insert_Data.ipynb)
#
5 changes: 3 additions & 2 deletions src/spyglass/utils/logging.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"""Logging configuration based on datajoint/logging.py"""
import logging
import os
import sys

import datajoint as dj

logger = logging.getLogger(__name__.split(".")[0])

log_level = os.getenv("DJ_LOG_LEVEL", "info").upper()
log_level = dj.config.get("loglevel", "INFO").upper()

log_format = logging.Formatter(
"[%(asctime)s][%(levelname)s] Spyglass: %(message)s", datefmt="%H:%M:%S"
Expand Down

0 comments on commit a01d2d7

Please sign in to comment.