-
Notifications
You must be signed in to change notification settings - Fork 297
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feature/3506: Improve Type Conversion errors, use rich to prettify er…
…ror messages (#1582) * improve input type conversion error Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com> * fix lint Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com> * fix Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com> * add tests Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com> * add tests Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com> * add rich Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com> * fix lint Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com> * remove prototyping script, update loggers Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com> * update __init__.py Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com> * update logger Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com> * update logger Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com> * fix GE and pandera tests Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com> * fix lint Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com> --------- Signed-off-by: Niels Bantilan <niels.bantilan@gmail.com>
- Loading branch information
1 parent
6e4d34c
commit e865db5
Showing
16 changed files
with
286 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,3 +32,4 @@ htmlcov | |
*.ipynb | ||
*dat | ||
docs/source/_tags/ | ||
.hypothesis |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,8 @@ | |
import os | ||
|
||
from pythonjsonlogger import jsonlogger | ||
from rich.console import Console | ||
from rich.logging import RichHandler | ||
|
||
# Note: | ||
# The environment variable controls exposed to affect the individual loggers should be considered to be beta. | ||
|
@@ -10,6 +12,7 @@ | |
# For now, assume this is the environment variable whose usage will remain unchanged and controls output for all | ||
# loggers defined in this file. | ||
LOGGING_ENV_VAR = "FLYTE_SDK_LOGGING_LEVEL" | ||
LOGGING_FMT_ENV_VAR = "FLYTE_SDK_LOGGING_FORMAT" | ||
|
||
# By default, the root flytekit logger to debug so everything is logged, but enable fine-tuning | ||
logger = logging.getLogger("flytekit") | ||
|
@@ -33,8 +36,18 @@ | |
user_space_logger = child_loggers["user_space"] | ||
|
||
# create console handler | ||
ch = logging.StreamHandler() | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
honnix
Member
|
||
ch.setLevel(logging.DEBUG) | ||
try: | ||
handler = RichHandler( | ||
rich_tracebacks=True, | ||
omit_repeated_times=False, | ||
keywords=["[flytekit]"], | ||
log_time_format="%Y-%m-%d %H:%M:%S,%f", | ||
console=Console(width=os.get_terminal_size().columns), | ||
) | ||
except OSError: | ||
handler = logging.StreamHandler() | ||
|
||
handler.setLevel(logging.DEBUG) | ||
|
||
# Root logger control | ||
# Don't want to import the configuration library since that will cause all sorts of circular imports, let's | ||
|
@@ -63,10 +76,14 @@ | |
child_logger.setLevel(logging.WARNING) | ||
|
||
# create formatter | ||
formatter = jsonlogger.JsonFormatter(fmt="%(asctime)s %(name)s %(levelname)s %(message)s") | ||
logging_fmt = os.environ.get(LOGGING_FMT_ENV_VAR, "json") | ||
if logging_fmt == "json": | ||
formatter = jsonlogger.JsonFormatter(fmt="%(asctime)s %(name)s %(levelname)s %(message)s") | ||
else: | ||
formatter = logging.Formatter(fmt="[%(name)s] %(message)s") | ||
|
||
# add formatter to ch | ||
ch.setFormatter(formatter) | ||
# add formatter to the handler | ||
handler.setFormatter(formatter) | ||
|
||
# add ch to logger | ||
logger.addHandler(ch) | ||
logger.addHandler(handler) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -73,6 +73,7 @@ | |
"numpy", | ||
"gitpython", | ||
"kubernetes>=12.0.1", | ||
"rich", | ||
], | ||
extras_require=extras_require, | ||
scripts=[ | ||
|
Oops, something went wrong.
This is unfortunately a breaking change but I guess a minor version bump (1.6.0) is fine? We might want to highlight this in release notes.