-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Logging #127
Logging #127
Changes from 9 commits
184a614
b83d8a1
c42f4fc
f8db211
f1c599b
84a41eb
602af5f
9e6574d
1383d88
784086f
72c8cd6
889c030
604c5bc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,6 +15,7 @@ | |
""" | ||
from __future__ import annotations | ||
|
||
import logging | ||
import os | ||
import sys | ||
import warnings | ||
|
@@ -46,6 +47,7 @@ def execute_managed_notebook(cls, nb_man, kernel_name, **kwargs): | |
|
||
def get_control_dict(config_path): | ||
"""Get control dictionary from configuration file""" | ||
|
||
try: | ||
with open(config_path) as fid: | ||
control = yaml.safe_load(fid) | ||
|
@@ -93,6 +95,39 @@ def get_control_dict(config_path): | |
return control | ||
|
||
|
||
def setup_logging(config_path): | ||
""" | ||
Set up logging based on configuration file log level | ||
Returns logger object | ||
""" | ||
control = get_control_dict(config_path) | ||
log_level = control["computation_config"].get("log_level", None) | ||
if log_level: | ||
if log_level == "debug": | ||
logging.basicConfig( | ||
level=logging.DEBUG, | ||
) | ||
if log_level == "info": | ||
logging.basicConfig( | ||
level=logging.INFO, | ||
) | ||
if log_level == "warning": | ||
logging.basicConfig( | ||
level=logging.WARNING, | ||
) | ||
if log_level == "error": | ||
logging.basicConfig( | ||
level=logging.ERROR, | ||
) | ||
else: | ||
# default level is info if log level is not set in config | ||
logging.basicConfig( | ||
level=logging.INFO, | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you change line 104 to log_level = control["computation_config"].get("log_level", "info") Then you don't need the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thinking about this more, should we use if log_level == "debug":
logging.basicConfig(
level=logging.DEBUG,
)
elif log_level == "info":
logging.basicConfig(
level=logging.INFO,
)
elif log_level == "warning":
logging.basicConfig(
level=logging.WARNING,
)
elif log_level == "error":
logging.basicConfig(
level=logging.ERROR,
)
else: and trap the case when |
||
|
||
return logging.getLogger(__name__) | ||
|
||
|
||
def setup_book(config_path): | ||
"""Setup run directory and output jupyter book""" | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function is called from
create_time_series()
, which useslogger
prior to calling in... so I think we wantlogger
to be a required argument. This will let us removeat lines 370-372 (and I think also the
import cupid.util
at lines 17 & 18)