Skip to content
This repository was archived by the owner on May 17, 2024. It is now read-only.

Commit 101a488

Browse files
authored
Merge pull request #665 from datafold/LAB-118_2
add a one time message about vscode extension
2 parents f80dc58 + 8a66040 commit 101a488

File tree

3 files changed

+25
-2
lines changed

3 files changed

+25
-2
lines changed

data_diff/__main__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ def _get_log_handlers(is_dbt: Optional[bool] = False) -> Dict[str, logging.Handl
4848
rich_handler.setLevel(logging.WARN)
4949
handlers["rich_handler"] = rich_handler
5050

51-
# only use log_status_handler in a terminal
52-
if rich_handler.console.is_terminal and is_dbt:
51+
# only use log_status_handler in an interactive terminal session
52+
if rich_handler.console.is_interactive and is_dbt:
5353
log_status_handler = LogStatusHandler()
5454
log_status_handler.setFormatter(logging.Formatter(log_format_status, datefmt=date_format))
5555
log_status_handler.setLevel(logging.DEBUG)

data_diff/dbt.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
from .format import jsonify, jsonify_error
2424
from .tracking import (
2525
bool_ask_for_email,
26+
bool_notify_about_extension,
2627
create_email_#_event_json,
2728
set_entrypoint_name,
2829
set_dbt_user_id,
@@ -48,6 +49,7 @@
4849

4950
logger = getLogger(__name__)
5051
CLOUD_DOC_URL = "https://docs.datafold.com/development_testing/cloud"
52+
EXTENSION_INSTALL_URL = "https://get.datafold.com/datafold-vs-code-install"
5153

5254

5355
class TDiffVars(pydantic.BaseModel):
@@ -155,6 +157,8 @@ def dbt_diff(
155157
for thread in diff_threads:
156158
thread.join()
157159

160+
_extension_notification()
161+
158162

159163
def _get_diff_vars(
160164
dbt_parser: "DbtParser",
@@ -517,3 +521,10 @@ def _email_#() -> None:
517521
if email:
518522
event_json = create_email_#_event_json(email)
519523
run_as_daemon(send_event_json, event_json)
524+
525+
526+
def _extension_notification() -> None:
527+
if bool_notify_about_extension():
528+
rich.print(
529+
f"\n\nHaving a good time diffing? :heart_eyes-emoji:\nMake sure to check out the free [bold]Datafold VS Code extension[/bold] for more a more seamless diff experience:\n{EXTENSION_INSTALL_URL}"
530+
)

data_diff/tracking.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import urllib.request
1212
from uuid import uuid4
1313
import toml
14+
from rich import get_console
1415

1516
from .version import __version__
1617

@@ -61,6 +62,17 @@ def bool_ask_for_email() -> bool:
6162
return False
6263

6364

65+
def bool_notify_about_extension() -> bool:
66+
profile = _load_profile()
67+
console = get_console()
68+
if "notified_about_extension" not in profile and console.is_interactive:
69+
profile["notified_about_extension"] = ""
70+
with open(DEFAULT_PROFILE, "w") as conf:
71+
toml.dump(profile, conf)
72+
return True
73+
return False
74+
75+
6476
g_tracking_enabled = True
6577
g_anonymous_id = None
6678

0 commit comments

Comments
 (0)