Last active
August 17, 2022 14:44
-
-
Save menzenski/2c5a7575b82cbf36dfa1c67babe8d27e to your computer and use it in GitHub Desktop.
Use rich's Inspect method on an object in an AWS Glue script
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
from rich.logging import RichHandler | |
from rich._inspect import Inspect | |
import logging | |
handler = RichHandler(rich_tracebacks=True, show_path=False, locals_max_length=None, locals_max_string=None, show_level=False, show_time=False) | |
logging.basicConfig(level="NOTSET", format="%(message)s", datefmt="[%X]", handlers=[handler]) | |
# assumption - you are using AWS CloudWatch logs for AWS Glue | |
def main() -> None: | |
# script logic here | |
my_object = None # assume my_object is something more interesting | |
handler.console.size = (220, 1000) # width, height | |
handler.console.log(Inspect(my_object, all=True)) | |
# view output logs in AWS CloudWatch to see the Rich inspect logs | |
# job.commit() and other logic here | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment