Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
test:
strategy:
matrix:
python-version: [3.7, 3.8, 3.9, '3.10', '3.11']
python-version: [3.8, 3.9, '3.10', '3.11']
os: [ubuntu-latest, macos-latest, windows-latest]

runs-on: ${{ matrix.os }}
Expand Down Expand Up @@ -87,4 +87,4 @@ jobs:
TAG: ${{ github.ref_name }}
run: |
echo "tag is $TAG"
pkgmt release $TAG --production --yes
pkgmt release $TAG --production --yes
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.26dev

* [Feature] New optional custom telemetry `api_key`

## 0.2.25 (2024-02-01)

* [Feature] Updates cloud message
Expand Down
4 changes: 2 additions & 2 deletions src/ploomber_core/telemetry/telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -420,12 +420,12 @@ def __init__(self, api_key, package_name, version, *, print_cloud_message=True):
self.print_cloud_message = print_cloud_message

@classmethod
def from_package(cls, package_name, *, print_cloud_message=True):
def from_package(cls, package_name, *, print_cloud_message=True, api_key=None):
"""
Initialize a Telemetry client with the default configuration for
a package with the given name
"""
default_api_key = "phc_P9SpSeypyPwxrMdFn2edOOEooQioF2axppyEeDwtMSP"
default_api_key = api_key or "phc_P9SpSeypyPwxrMdFn2edOOEooQioF2axppyEeDwtMSP"
version = get_package_version(package_name)
return cls(
api_key=default_api_key,
Expand Down
10 changes: 9 additions & 1 deletion tests/telemetry/test_telemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -1080,11 +1080,19 @@ def test_check_cloud(tmp_directory, monkeypatch, capsys, last_cloud_check):
def test_from_package():
_telemetry = telemetry.Telemetry.from_package("ploomber-core")

assert _telemetry.api_key
assert _telemetry.api_key == "phc_P9SpSeypyPwxrMdFn2edOOEooQioF2axppyEeDwtMSP"
assert _telemetry.version
assert _telemetry.package_name == "ploomber-core"


def test_from_package_custom_api_key():
_telemetry = telemetry.Telemetry.from_package(
"ploomber-core", api_key="test_custom_key"
)

assert _telemetry.api_key == "test_custom_key"


def test_runs_check_cloud(monkeypatch):
mock = Mock()
monkeypatch.setattr(telemetry, "check_cloud", mock)
Expand Down
Loading