Skip to main content

Shared Python utilities for SQL, Excel, and date helpers.

Project description

analytics_toolkit

analytics_toolkit is a small utility package for:

  • AB-test related helpers
  • SQL I/O and table-loading helpers for Trino, Greenplum, and ClickHouse
  • date helpers for common period calculations
  • Excel helpers for writing pivoted tables from long-format data

Install

From PyPI:

pip install analytics-toolkit

From GitHub:

pip install git+https://github.com/Karapsin/analytics_toolkit.git

Release

PyPI publishing uses GitHub Actions trusted publishing. Before each release, run the full local tox matrix from AGENTS.md, update the changelog, and verify the package build:

python -m pip install --upgrade build twine
python -m build
python -m twine check dist/*

Run the publish workflow manually to publish the current version to TestPyPI. After the TestPyPI install check passes, create and publish a GitHub release tagged as v<pyproject.toml version>; the release event publishes to PyPI. The PyPI trusted publisher uses repository Karapsin/analytics_toolkit, workflow .github/workflows/publish.yml, and environment pypi. The TestPyPI trusted publisher uses the same repository and workflow with environment testpypi.

Quick Start

from analytics_toolkit.ab_utils import compute_test_metrics
from analytics_toolkit import sql
from analytics_toolkit.dates.dates import first_day
from analytics_toolkit.excel import break_table, pivot_and_break_table

Supported SQL imports are from analytics_toolkit import sql or import analytics_toolkit.sql as sql. Deep imports under analytics_toolkit.sql.* are internal implementation details and may change; call SQL helpers through the sql facade, for example sql.create_sql_table(...) or sql.transfer(...). Do not restore removed root implementation paths.

Configuration

SQL connection settings are read from .connections. The package searches from the current working directory upward through parent directories. Each key is the public connection alias used by analytics_toolkit.sql; each value must include type as one of gp, trino, or ch.

{
  "gp": {
    "type": "gp",
    "host": "gp.example",
    "port": 5432,
    "user": "user",
    "password": "password",
    "database": "db"
  },
  "gp_sandbox": {
    "type": "gp",
    "host": "gp-sandbox.example",
    "user": "user",
    "password": "password",
    "database": "sandbox"
  }
}

Legacy variables such as GP_HOST, TRINO_HOST, CH_HOST, SQL_CONNECTIONS, and TRINO_INSERT_CHUNK_SIZE are not read. Move connection settings into .connections; Trino insert chunk sizing is the Trino connection field insert_chunk_size.

If a Trino connection sets use_keychain_certs=true, the generated CA bundle is written to:

  • <connections_file_directory>/certs/trino-<connection-key>-keychain-ca.pem

You can override the state/output directory with MAGNIT_UTILS_HOME.

Manuals

Package Layout

  • analytics_toolkit/ab_utils: AB-test metric comparison helpers, including compute_test_metrics
  • analytics_toolkit/dates: date and period helpers
  • analytics_toolkit/excel: Excel formatting helpers
  • analytics_toolkit/sql: SQL execution, loading, and transfer helpers

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

analytics_toolkit-1.3.6.12.tar.gz (222.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

analytics_toolkit-1.3.6.12-py3-none-any.whl (192.5 kB view details)

Uploaded Python 3

File details

Details for the file analytics_toolkit-1.3.6.12.tar.gz.

File metadata

  • Download URL: analytics_toolkit-1.3.6.12.tar.gz
  • Upload date:
  • Size: 222.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for analytics_toolkit-1.3.6.12.tar.gz
Algorithm Hash digest
SHA256 ed0b5905d614c83140786b30621a57d74758651060fdfc221f3f03558542e116
MD5 10593d7373e6721829ba5a9954a13f48
BLAKE2b-256 9f8f21af27610ac0088ddd7431ecd040410d3d66f8ee34a84e8c86a1d256c169

See more details on using hashes here.

Provenance

The following attestation bundles were made for analytics_toolkit-1.3.6.12.tar.gz:

Publisher: publish.yml on Karapsin/analytics_toolkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file analytics_toolkit-1.3.6.12-py3-none-any.whl.

File metadata

File hashes

Hashes for analytics_toolkit-1.3.6.12-py3-none-any.whl
Algorithm Hash digest
SHA256 096f13f587f1920ac7a16aa341c003476b6c99d270325ecb42a14fbcd9878168
MD5 331605fc19c619d056233ac489916c2e
BLAKE2b-256 3d150fc1bf967acdcaff87c27f28de5e6e98db90a61723ee1346d6e72cd02b0f

See more details on using hashes here.

Provenance

The following attestation bundles were made for analytics_toolkit-1.3.6.12-py3-none-any.whl:

Publisher: publish.yml on Karapsin/analytics_toolkit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page