Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Snowplow Signals Python SDK

The Snowplow Signals Python SDK enables you to interact with the Snowplow Signals Profile API. It provides a simple interface to define, deploy, and retrieve user attributes for personalization.

Installation

pip install snowplow-signals

Quickstart

from snowplow_signals import Signals, SignalsSandbox, Attribute, Event, StreamAttributeGroup, domain_sessionid

# Initialize the SDK with BDP authentication (default)
signals = Signals(
    api_url="API_URL",
    api_key="API_KEY",
    api_key_id="API_KEY_ID",
    org_id="ORG_ID",
)

# Or initialize with SANDBOX authentication
signals = SignalsSandbox(
    api_url="API_URL",
    sandbox_token="YOUR_SANDBOX_TOKEN",
)

# Define an attribute
page_view_count = Attribute(
    name="page_view_count",
    type="int32",
    events=[
        Event(
            vendor="com.snowplowanalytics.snowplow",
            name="page_view",
            version="1-0-0",
        )
    ],
    aggregation="counter"
)

# Create and deploy a view
stream_attribute_group = StreamAttributeGroup(
    name="my_attribute_group",
    version=1,
    attribute_key=domain_sessionid,
    attributes=[page_view_count],
)
signals.publish([stream_attribute_group])

# Retrieve attributes
response = signals.get_group_attributes(
    name="my_attribute_group",
    version=1,
    attribute_key="domain_sessionid",
    attributes=["page_view_count"],
    identifier="abc-123",
)

Key Features

  • Define attributes based on Snowplow events
  • Create attribute groups for related attributes
  • Deploy attribute groups to the Profile API
  • Retrieve real-time user attributes
  • Build training datasets with session-based or custom anchors
  • Execute dataset builds server-side and preview results

Dataset Builder

Build training datasets from your Snowplow events using the dataset builder. You can generate SQL bundles locally or submit dataset builds for server-side execution.

Generate SQL bundle

from datetime import datetime, timezone
from snowplow_signals import Signals, Criteria, Criterion, TrainingSpan
from snowplow_signals.models import AtomicProperty

bundle = signals.build_dataset_with_session_anchors(
    attribute_groups=[my_attribute_group],
    goal_criteria=Criteria(
        any=[Criterion.eq(AtomicProperty(name="se_action"), "purchase")]
    ),
    training_span=TrainingSpan(
        start_time=datetime(2025, 1, 1, tzinfo=timezone.utc),
        end_time=datetime(2025, 6, 1, tzinfo=timezone.utc),
    ),
)

# Save SQL files to disk
bundle.save_to("./dataset_output")

Server-side execution

Submit a dataset build for execution on your warehouse and poll for results:

import time
from snowplow_signals import DatasetRunStatus

run = signals.submit_dataset_run_with_session_anchors(
    attribute_groups=[my_attribute_group],
    goal_criteria=Criteria(
        any=[Criterion.eq(AtomicProperty(name="se_action"), "purchase")]
    ),
    training_span=TrainingSpan(
        start_time=datetime(2025, 1, 1, tzinfo=timezone.utc),
        end_time=datetime(2025, 6, 1, tzinfo=timezone.utc),
    ),
)

# Poll for completion
while True:
    status = signals.get_dataset_run_status(run.id)
    if status.status != DatasetRunStatus.PENDING:
        break
    time.sleep(5)

# Preview results
if status.status == DatasetRunStatus.SUCCESS:
    preview = signals.get_dataset_run_preview(run.id, limit=100)
    df = preview.to_pandas()
    print(df)

Release files for snowplow-signals 0.4.8rc4

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for snowplow-signals 0.4.8rc4
File Size Uploaded
snowplow_signals-0.4.8rc4.tar.gz 39.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for snowplow-signals 0.4.8rc4
File Interpreter ABI Platform
snowplow_signals-0.4.8rc4-py3-none-any.whl Python 3 none any Details

Total release size: 87.2 kB

Release files / snowplow_signals-0.4.8rc4.tar.gz

Download URL snowplow_signals-0.4.8rc4.tar.gz
Size 39.1 kB
Tags Source
SHA-256 checksum
How to use checksums
e332ed49460f61cee8d5fda78bd5ef55e527cd6cd4eff704e221544fd35e4e75
BLAKE2b-256 checksum
How to use checksums
c95c8b74d81fc11670934b07b879244640e1e08830af210a104976b81f72e46b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.3 CPython/3.11.16 Linux/6.17.0-1022-azure

Release files / snowplow_signals-0.4.8rc4-py3-none-any.whl

Download URL snowplow_signals-0.4.8rc4-py3-none-any.whl
Size 48.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bf0111843e1cc06ee39ac2d1c999e7301bd4a7f04ac057173c6d36a48c784ba6
BLAKE2b-256 checksum
How to use checksums
bedaf19d7443d18c9f8ffd963644e7c4cae98ac422c7b4907480e2d80609deac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.4.3 CPython/3.11.16 Linux/6.17.0-1022-azure

Release history Release notifications | RSS feed

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page