From f8e2fe500d019d60f47b4ffbf97f2cb4da577ca7 Mon Sep 17 00:00:00 2001 From: Robin Linacre Date: Fri, 12 Feb 2021 15:23:20 +0000 Subject: [PATCH 1/5] add logging --- pydbtools/wrangler.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pydbtools/wrangler.py b/pydbtools/wrangler.py index 8f8a568..7e46094 100644 --- a/pydbtools/wrangler.py +++ b/pydbtools/wrangler.py @@ -3,6 +3,8 @@ import os import sqlparse import warnings +import logging +import pprint import inspect import functools @@ -17,6 +19,9 @@ replace_temp_database_name_reference, ) + +logger = logging.getLogger(__name__) + # Wrapper used to set parameters in the athena wrangler functions # before they are called def init_athena_params(func=None, *, allow_boto3_session=False): @@ -110,6 +115,7 @@ def wrapper(*args, **kwargs): else: argmap["database"] = None + logger.debug(pprint.pprint(dict(argmap))) return func(**argmap) return wrapper From 9facda6ac00a33e321b6295b64d58711548625ca Mon Sep 17 00:00:00 2001 From: Robin Linacre Date: Fri, 12 Feb 2021 15:27:22 +0000 Subject: [PATCH 2/5] bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 8508bed..3096bb6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [tool] [tool.poetry] name = "pydbtools" -version = "3.0.0" +version = "3.0.1" description = "A python package to query data via amazon athena and bring it into a pandas df" license = "MIT" authors = ["Karik Isichei "] From 6e2f65b54caccfb9647275a9af2485a7f997dae5 Mon Sep 17 00:00:00 2001 From: Robin Linacre Date: Fri, 12 Feb 2021 15:28:42 +0000 Subject: [PATCH 3/5] changelog --- CHANGELOG.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b0ebad..985cb2a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## v3.0.1 - 2021-02-12 + +### Changed +- The `wrangler.py` module now has logging. To observe the arguments and sql queries being run, turn on logging at DEBUG level using e.g. + +``` +import logging +logging.basicConfig() +logging.getLogger("pydbtools").setLevel(logging.DEBUG) +``` ## v3.0.0 - 2021-01-26 ### Changed From 1e40955c7147570ce842e6d3baee4d900a88ec49 Mon Sep 17 00:00:00 2001 From: Robin Linacre Date: Fri, 12 Feb 2021 15:32:11 +0000 Subject: [PATCH 4/5] log function name --- pydbtools/wrangler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydbtools/wrangler.py b/pydbtools/wrangler.py index 7e46094..e959f4c 100644 --- a/pydbtools/wrangler.py +++ b/pydbtools/wrangler.py @@ -114,7 +114,7 @@ def wrapper(*args, **kwargs): argmap["database"] = temp_db_name else: argmap["database"] = None - + logger.debug(f"Modifying function {func.__name__}") logger.debug(pprint.pprint(dict(argmap))) return func(**argmap) From 5edf667a597655695c842cd91a9cf5de655fba9a Mon Sep 17 00:00:00 2001 From: Robin Linacre Date: Mon, 15 Feb 2021 09:17:17 +0000 Subject: [PATCH 5/5] format not print --- pydbtools/wrangler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pydbtools/wrangler.py b/pydbtools/wrangler.py index e959f4c..5a7986c 100644 --- a/pydbtools/wrangler.py +++ b/pydbtools/wrangler.py @@ -31,7 +31,7 @@ def init_athena_params(func=None, *, allow_boto3_session=False): Args: func (Callable): An function from wr.athena that requires - boto3_session. If the func has an s3_output this is also + boto3_session. If the func has an s3_output this is also standardised. Returns: @@ -115,7 +115,7 @@ def wrapper(*args, **kwargs): else: argmap["database"] = None logger.debug(f"Modifying function {func.__name__}") - logger.debug(pprint.pprint(dict(argmap))) + logger.debug(pprint.pformat(dict(argmap))) return func(**argmap) return wrapper