databrickslabs / dbldatagen

Generate relevant synthetic data quickly for your projects. The Databricks Labs synthetic data generator (aka `dbldatagen`) may be used to generate large simulated / synthetic data sets for test, POCs, and other uses in Databricks environments including in Delta Live Tables pipelines
https://databrickslabs.github.io/dbldatagen
Other
302 stars 57 forks source link

Fix final calls to root logger #205

Closed MarvinSchenkel closed 1 year ago

MarvinSchenkel commented 1 year ago

Proposed changes

This PR changes the last calls to the root logger of the logging package. This will make sure only one handler is used when the dbldatagen package is used in downstream projects.

Before

import logging
date_format = "%Y-%m-%d %H:%M:%S"
log_format = "%(asctime)s %(levelname)-8s  %(message)s"
formatter = logging.Formatter(log_format, date_format)
handler = logging.StreamHandler()
handler.setFormatter(formatter)
logger = logging.getLogger(__name__)
logger.setLevel(level=logging.INFO)
logger.addHandler(handler)
logger.info("Info message")
# Prints: 2023-03-08 14:18:59 INFO      Info message
from dbldatagen import DataGenerator
# Prints: INFO: Version : VersionInfo(major='0', minor='3', patch='1', release='', build='')
logger.info("Info message")
# Prints:
# 2023-03-08 14:18:59 INFO      Info message
# INFO: Info message

After

import logging
date_format = "%Y-%m-%d %H:%M:%S"
log_format = "%(asctime)s %(levelname)-8s  %(message)s"
formatter = logging.Formatter(log_format, date_format)
handler = logging.StreamHandler()
handler.setFormatter(formatter)
logger = logging.getLogger(__name__)
logger.setLevel(level=logging.INFO)
logger.addHandler(handler)
logger.info("Info message")
# Prints: 2023-03-08 14:18:59 INFO      Info message
from dbldatagen import DataGenerator
logger.info("Info message")
# Prints:
# 2023-03-08 14:18:59 INFO      Info message

Types of changes

What types of changes does your code introduce to dbldatagen? Put an x in the boxes that apply

Checklist

Put an x in the boxes that apply. You can also fill these out after creating the PR. If you're unsure about any of them, don't hesitate to ask. We're here to help! This is simply a reminder of what we are going to look for before merging your code.

Further comments

If this is a relatively large or complex change, kick off the discussion by explaining why you chose the solution you did and what alternatives you considered, etc...

codecov[bot] commented 1 year ago

Codecov Report

Merging #205 (03580b4) into master (615c56b) will not change coverage. The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #205   +/-   ##
=======================================
  Coverage   91.90%   91.90%           
=======================================
  Files          22       22           
  Lines        2642     2642           
  Branches      449      449           
=======================================
  Hits         2428     2428           
  Misses        127      127           
  Partials       87       87           
Impacted Files Coverage Δ
dbldatagen/column_generation_spec.py 91.95% <ø> (-0.02%) :arrow_down:
dbldatagen/_version.py 100.00% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.