Skip to content

Commit

Permalink
Migrate user feedback to use display module (#735)
Browse files Browse the repository at this point in the history
* Empty-Commit

* Empty-Commit

* changelog

* commit

* commit

* commit

* commit

* commit

---------

Co-authored-by: Anupam <[email protected]>
  • Loading branch information
anupam-tiwari and Anupam authored Jul 16, 2023
1 parent f467202 commit c1f9cdf
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* [Doc] Re-organized sections. Adds section showing how to share notebooks via Ploomber Cloud
* [Fix] Adding `--with` back because of issues with sqlglot query parser (#684)
* [Fix] Improving << parsing logic (#610)
* [Fix] Migrate user feedback to use display module (#548)

## 0.7.9 (2023-06-19)

Expand Down
2 changes: 1 addition & 1 deletion src/sql/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ def close_all(cls, verbose=False):
conn.close(key)

if verbose:
print(f"Closing {key}")
display.message(f"Closing {key}")

cls.connections = {}

Expand Down
10 changes: 6 additions & 4 deletions src/sql/magic.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ def __init__(self, shell):
@validate("displaylimit")
def _valid_displaylimit(self, proposal):
if proposal["value"] is None:
print("displaylimit: Value None will be treated as 0 (no limit)")
display.message("displaylimit: Value None will be treated as 0 (no limit)")
return 0
try:
value = int(proposal["value"])
Expand All @@ -188,7 +188,9 @@ def _mutex_autopandas_autopolars(self, change):
other = "autopolars" if change["name"] == "autopandas" else "autopandas"
if getattr(self, other):
setattr(self, other, False)
print(f"Disabled '{other}' since '{change['name']}' was enabled.")
display.message(
f"Disabled '{other}' since '{change['name']}' was enabled."
)

def check_random_arguments(self, line="", cell=""):
# check only for cell magic
Expand Down Expand Up @@ -411,7 +413,7 @@ def interactive_execute_wrapper(**kwargs):
interactive_dict = {}
for key in args.interact:
interactive_dict[key] = local_ns[key]
print(
display.message(
"Interactive mode, please interact with below "
"widget(s) to control the variable"
)
Expand Down Expand Up @@ -527,7 +529,7 @@ def interactive_execute_wrapper(**kwargs):
result = result.dict()

if self.feedback:
print(
display.message(
"Returning data to local variables [{}]".format(", ".join(keys))
)

Expand Down
12 changes: 7 additions & 5 deletions src/sql/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from sql.util import flatten
from sqlalchemy.exc import ProgrammingError
from sql import exceptions
from sql import exceptions, display

try:
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -666,7 +666,7 @@ def _bar(table, column, with_=None, conn=None):
x_ = column[0]
height_ = column[1]

print(f"Removing NULLs, if there exists any from {x_} and {height_}")
display.message(f"Removing NULLs, if there exists any from {x_} and {height_}")
template_ = """
select "{{x_}}" as x,
"{{height_}}" as height
Expand All @@ -685,7 +685,7 @@ def _bar(table, column, with_=None, conn=None):
query = template.render(table=table, x_=x_, height_=height_)

else:
print(f"Removing NULLs, if there exists any from {column}")
display.message(f"Removing NULLs, if there exists any from {column}")
template_ = """
select "{{column}}" as x,
count("{{column}}") as height
Expand Down Expand Up @@ -850,7 +850,9 @@ def _pie(table, column, with_=None, conn=None):
labels_ = column[0]
size_ = column[1]

print(f"Removing NULLs, if there exists any from {labels_} and {size_}")
display.message(
f"Removing NULLs, if there exists any from {labels_} and {size_}"
)
template_ = """
select "{{labels_}}" as labels,
"{{size_}}" as size
Expand All @@ -865,7 +867,7 @@ def _pie(table, column, with_=None, conn=None):
query = template.render(table=table, labels_=labels_, size_=size_)

else:
print(f"Removing NULLs, if there exists any from {column}")
display.message(f"Removing NULLs, if there exists any from {column}")
template_ = """
select "{{column}}" as x,
count("{{column}}") as height
Expand Down
2 changes: 1 addition & 1 deletion src/sql/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ def _commit(conn, config, manual_commit):
with Session(conn.session) as session:
session.commit()
except sqlalchemy.exc.OperationalError:
print("The database does not support the COMMIT command")
display.message("The database does not support the COMMIT command")


def is_postgres_or_redshift(dialect):
Expand Down
4 changes: 2 additions & 2 deletions src/sql/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import difflib
from sql.connection import Connection
from sql.store import store, _get_dependents_for_key
from sql import exceptions
from sql import exceptions, display
import json

SINGLE_QUOTE = "'"
Expand Down Expand Up @@ -182,7 +182,7 @@ def strip_multiple_chars(string: str, chars: str) -> str:

def is_saved_snippet(table: str) -> bool:
if table in list(store):
print(f"Plotting using saved snippet : {table}")
display.message(f"Plotting using saved snippet : {table}")
return True
return False

Expand Down

0 comments on commit c1f9cdf

Please sign in to comment.