Sync metrics to Eppo
Project description
Eppo Metrics Sync
A Python package for syncing metric definitions with Eppo's API. Manage your Eppo metrics as code using YAML files. Documentation is available in Eppo's documentation page.
Features
- Sync metrics and fact sources to Eppo
- Validate metric definitions locally
- Support for dbt models
- Dry-run capability for testing
- Prefix support for testing in shared workspaces
Installation
pip install eppo-metrics-sync
Usage
Basic usage
- Set required environment variables:
export EPPO_API_KEY="your-api-key"
export EPPO_SYNC_TAG="your-sync-tag" # optional
export EPPO_REFERENCE_URL="your-reference-url" # optional
-
Create your metrics YAML files (see Documentation)
-
Run the sync:
python -m eppo_metrics_sync path/to/yaml/directory
CLI Options
python -m eppo_metrics_sync [OPTIONS] DIRECTORY
Options:
--dryrunValidate files without syncing to Eppo--schemaSchema type: eppo (default) or dbt-model--sync-prefixPrefix for fact/metric names (useful for testing)--dbt-model-prefixWarehouse/schema prefix for dbt models--allow-upgradesAllow existing non-certified metrics/fact sources to become certified
When to use --allow-upgrades
The --allow-upgrades flag is useful in the following scenarios:
- Promoting existing metrics to certified status: If you have existing metrics or fact sources in Eppo that are not currently certified, this flag allows them to be upgraded to certified status during the sync process.
- Migrating from manual to code-managed metrics: When transitioning from manually created metrics in the Eppo UI to managing them through YAML files, this flag enables the promotion of those metrics to certified status.
- Avoiding conflicts during migration: Without this flag, attempting to sync metrics that already exist in a non-certified state may result in conflicts or the sync process not upgrading their certification status.
Validation Rules & Constraints
The following validation rules are enforced when syncing metrics. Understanding these constraints upfront can help avoid validation errors during development:
Winsorization Constraints
Winsorization parameters (winsorization_lower_percentile, winsorization_upper_percentile) can only be used with these aggregation operations:
- ✅
sum - ✅
count - ✅
count_distinct - ✅
last_value - ✅
first_value
Not supported for:
- ❌
distinct_entity- Binary metrics don't need winsorization - ❌
threshold- Threshold logic handles outliers differently - ❌
retention- Binary retention metrics don't need winsorization - ❌
conversion- Binary conversion metrics don't need winsorization
Advanced Aggregation Parameters
Each advanced aggregation type requires its specific parameter and cannot use others:
Threshold Metrics
- Required:
threshold_metric_settingsobject with:comparison_operator: "gt" or "gte"aggregation_type: "sum" or "count" (not count_distinct)breach_value: numeric threshold value
- Cannot use:
retention_threshold_days,conversion_threshold_days - Cannot use: Timeframe parameters (
aggregation_timeframe_start_value,aggregation_timeframe_end_value,aggregation_timeframe_unit)
Retention Metrics
- Required:
retention_threshold_days(numeric) - Cannot use:
threshold_metric_settings,conversion_threshold_days
Conversion Metrics
- Required:
conversion_threshold_days(numeric) - Cannot use:
threshold_metric_settings,retention_threshold_days - Cannot use: Timeframe parameters (
aggregation_timeframe_start_value,aggregation_timeframe_end_value)
Timeframe Parameters
When using aggregation timeframe parameters:
- Required:
aggregation_timeframe_unitmust be specified if any timeframe parameters are used - Supported units: "minutes", "hours", "days", "weeks", "calendar_days"
- Not supported for:
conversionoperations (useconversion_threshold_daysinstead)
Denominator Constraints
For ratio metrics, denominators can only use these operations:
- ✅
sum,count,count_distinct,distinct_entity,last_value,first_value - ❌ Cannot use:
threshold,retention,conversion
Guardrail Cutoff Signs
When using guardrail metrics (is_guardrail: true with guardrail_cutoff):
- If
desired_change: "increase"→guardrail_cutoffmust be negative - If
desired_change: "decrease"→guardrail_cutoffmust be positive
Note: The validation uses the metric's desired_change if specified, otherwise it falls back to the fact's desired_change. This allows you to override the fact-level direction when creating guardrail metrics.
Documentation
For detailed information about metric configuration, available options and constraints, see Eppo's documentation page.
Example YAML Configuration
fact_sources:
- name: Revenue
sql: |
SELECT ts, user_id, amount
FROM revenue_table
timestamp_column: ts
entities:
- entity_name: User
column: user_id
facts:
- name: Revenue
column: amount
metrics:
- name: Total Revenue
description: Sum of Total Purchase Value in Purchases Fact Table
entity: User
numerator:
fact_name: Revenue
operation: sum
desired_change: increase
Development
Setup
Create a virtual environment
python -m venv .venv
source .venv/bin/activate
Install dependencies
pip install -r requirements.txt
Running the tests
pytest tests
Running the package
export EPPO_API_KEY="your-api-key"
export EPPO_SYNC_TAG="your-sync-tag"
export EPPO_REFERENCE_URL="your-reference-url"
python -m eppo_metrics_sync path/to/yaml/directory
Building and Publishing
For package maintainers:
- Update version in
pyproject.toml - Build the package:
python -m build
- The package will be automatically published to PyPI when a new release is created on GitHub.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eppo_metrics_sync-0.1.15.tar.gz.
File metadata
- Download URL: eppo_metrics_sync-0.1.15.tar.gz
- Upload date:
- Size: 19.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7edab4104bfe76ec705ed726471c75f65b339db3a49258797144252d7a59f31f
|
|
| MD5 |
9f85e5d2cf91b1b639fa9ad113d6e06b
|
|
| BLAKE2b-256 |
371f1a2c61465dd57843f66ce3e954ffea4beb0c3d732d6d9d2cb382af289719
|
Provenance
The following attestation bundles were made for eppo_metrics_sync-0.1.15.tar.gz:
Publisher:
publish.yml on Eppo-exp/eppo-metrics-sync
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eppo_metrics_sync-0.1.15.tar.gz -
Subject digest:
7edab4104bfe76ec705ed726471c75f65b339db3a49258797144252d7a59f31f - Sigstore transparency entry: 743381366
- Sigstore integration time:
-
Permalink:
Eppo-exp/eppo-metrics-sync@01b6bf58812c1573924759cfac702c820043cf41 -
Branch / Tag:
refs/tags/v0.1.15 - Owner: https://github.com/Eppo-exp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01b6bf58812c1573924759cfac702c820043cf41 -
Trigger Event:
release
-
Statement type:
File details
Details for the file eppo_metrics_sync-0.1.15-py3-none-any.whl.
File metadata
- Download URL: eppo_metrics_sync-0.1.15-py3-none-any.whl
- Upload date:
- Size: 14.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3ec068ab11ca1b04b043c8fe26ecd862cc11ac8ffef90a30c4a9c602da9b1ffd
|
|
| MD5 |
fb049144009ba8321caebebdab7cd859
|
|
| BLAKE2b-256 |
7de5c82654ccadd3b9a626a6dfddee3b82461fefe23c8df1b1c870a46c09fa0b
|
Provenance
The following attestation bundles were made for eppo_metrics_sync-0.1.15-py3-none-any.whl:
Publisher:
publish.yml on Eppo-exp/eppo-metrics-sync
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
eppo_metrics_sync-0.1.15-py3-none-any.whl -
Subject digest:
3ec068ab11ca1b04b043c8fe26ecd862cc11ac8ffef90a30c4a9c602da9b1ffd - Sigstore transparency entry: 743381374
- Sigstore integration time:
-
Permalink:
Eppo-exp/eppo-metrics-sync@01b6bf58812c1573924759cfac702c820043cf41 -
Branch / Tag:
refs/tags/v0.1.15 - Owner: https://github.com/Eppo-exp
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@01b6bf58812c1573924759cfac702c820043cf41 -
Trigger Event:
release
-
Statement type: