Skip to content

Commit

Permalink
updates cloud message
Browse files Browse the repository at this point in the history
  • Loading branch information
edublancas committed Feb 2, 2024
1 parent f053fb5 commit 91a2870
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

## 0.2.25dev

* [Feataure] Updates cloud message

## 0.2.24 (2024-02-01)

* [Feature] Allows disabling the message that promotes Ploomber Cloud when initializing `Telemetry`
Expand Down
18 changes: 13 additions & 5 deletions src/ploomber_core/telemetry/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
from uuid import uuid4
from functools import wraps
import warnings
import random

import posthog

Expand Down Expand Up @@ -315,18 +316,25 @@ def check_cloud():
now = datetime.datetime.now()

# Check if we already notified in the last 2 days
if internal.last_cloud_check and (now - internal.last_cloud_check).days < 2:
if internal.last_cloud_check and (now - internal.last_cloud_check).days < 1:
return

print(
"Deploy AI and data apps for free on Ploomber Cloud! "
"Learn more: https://docs.cloud.ploomber.io/en/latest/quickstart/signup.html"
)
print_cloud_message()

# Update latest check date
internal.last_cloud_check = now


def print_cloud_message():
choices = ["Streamlit", "Panel", "Dash", "Flask", "FastAPI", "Shiny"]
selected = random.choice(choices)

print(
f"Deploy {selected} apps for free on Ploomber Cloud! "
"Learn more: https://ploomber.io/s/signup"
)


def _get_telemetry_info():
"""
The function checks for the local config and uid files, returns the right
Expand Down
6 changes: 4 additions & 2 deletions tests/telemetry/test_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,8 @@ def my_function(x, y, z):
],
)
def test_check_cloud(tmp_directory, monkeypatch, capsys, last_cloud_check):
monkeypatch.setattr(telemetry.random, "choice", lambda _: "NAME")

write_to_conf_file(
tmp_directory=tmp_directory,
monkeypatch=monkeypatch,
Expand All @@ -1067,8 +1069,8 @@ def test_check_cloud(tmp_directory, monkeypatch, capsys, last_cloud_check):
captured = capsys.readouterr()

expected = (
"Deploy AI and data apps for free on Ploomber Cloud!"
" Learn more: https://docs.cloud.ploomber.io/en/latest/quickstart/signup.html"
"Deploy NAME apps for free on Ploomber Cloud!"
" Learn more: https://ploomber.io/s/signup"
)

assert expected in captured.out
Expand Down

0 comments on commit 91a2870

Please sign in to comment.