-
Notifications
You must be signed in to change notification settings - Fork 300
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
Feature/3506: Improve Type Conversion errors, use rich to prettify error messages #1582
Merged
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
e3f3313
improve input type conversion error
cosmicBboy 36c9af2
fix lint
cosmicBboy e0ecea8
fix
cosmicBboy 70c9675
add tests
cosmicBboy ec38dde
add tests
cosmicBboy 2a49fd4
add rich
cosmicBboy 7850f74
fix lint
cosmicBboy e2ace05
remove prototyping script, update loggers
cosmicBboy 4ec2b71
update __init__.py
cosmicBboy 3d923e6
update logger
cosmicBboy 369ce04
update logger
cosmicBboy 2769ded
fix GE and pandera tests
cosmicBboy 686d1cf
fix lint
cosmicBboy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,7 +1,10 @@ | ||
import logging | ||
import os | ||
import shutil | ||
|
||
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 +13,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 +37,18 @@ | |
user_space_logger = child_loggers["user_space"] | ||
|
||
# create console handler | ||
ch = logging.StreamHandler() | ||
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=shutil.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 +77,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") | ||
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. so no change in the default case right? 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. correct, will update the logging format in a different PR |
||
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
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=[ | ||
|
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 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.
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.
Cc @wild-endeavor / @eapolinario