Skip to content

Commit

Permalink
feat(eda.report): allow disabling the progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
dovahcrow committed Sep 8, 2020
1 parent e1e0c8d commit 2a90f7f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 4 additions & 1 deletion dataprep/eda/create_report/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def create_report(
df: pd.DataFrame,
title: Optional[str] = "DataPrep Report",
mode: Optional[str] = "basic",
progress: bool = True,
) -> Report:
"""
This function is to generate and render element in a report object.
Expand All @@ -34,6 +35,8 @@ def create_report(
mode: Optional[str], default "basic"
This controls what type of report to be generated.
Currently only the 'basic' is fully implemented.
progress
Whether to show the progress bar.
Examples
--------
Expand All @@ -48,7 +51,7 @@ def create_report(
context = {
"resources": INLINE.render(),
"title": title,
"components": format_report(df, mode),
"components": format_report(df, mode, progress),
}
template_base = ENV_LOADER.get_template("base.html")
report = template_base.render(context=context)
Expand Down
8 changes: 5 additions & 3 deletions dataprep/eda/create_report/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@


def format_report(
df: Union[pd.DataFrame, dd.DataFrame], mode: Optional[str]
df: Union[pd.DataFrame, dd.DataFrame], mode: Optional[str], progress: bool = True
) -> Dict[str, Any]:
"""
Format the data and figures needed by report
Expand All @@ -42,9 +42,11 @@ def format_report(
----------
df
The DataFrame for which data are calculated.
mode: Optional[str]
mode
This controls what type of report to be generated.
Currently only the 'basic' is fully implemented.
progress
Whether to show the progress bar.
Returns
-------
Expand All @@ -53,7 +55,7 @@ def format_report(
This variable acts like an API in passing data to the template engine.
"""
# pylint: disable=too-many-locals,too-many-statements
with ProgressBar(minimum=1):
with ProgressBar(minimum=1, disable=not progress):
df = to_dask(df)
if mode == "basic":
comps = format_basic(df)
Expand Down

0 comments on commit 2a90f7f

Please sign in to comment.