Skip to content

Commit 96e6242

Browse files
authored
Merge pull request #26 from Eppo-exp/emiel/add-publish-workflow
Emiel/add publish workflow
2 parents c4e03f4 + c9d98ff commit 96e6242

File tree

4 files changed

+191
-20
lines changed

4 files changed

+191
-20
lines changed

.github/workflows/publish.yml

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Publish to PyPi
2+
3+
on:
4+
release:
5+
types: [published]
6+
workflow_dispatch:
7+
8+
jobs:
9+
build:
10+
name: Build distribution 📦
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- uses: actions/checkout@v4
15+
- name: Set up Python
16+
uses: actions/setup-python@v5
17+
with:
18+
python-version: "3.x"
19+
- name: Install pypa/build
20+
run: >-
21+
python3 -m
22+
pip install
23+
build
24+
--user
25+
- name: Build a binary wheel and a source tarball
26+
run: python3 -m build
27+
- name: Store the distribution packages
28+
uses: actions/upload-artifact@v4
29+
with:
30+
name: python-package-distributions
31+
path: dist/*
32+
33+
publish-to-pypi:
34+
name: >-
35+
Publish Python 🐍 distribution 📦 to PyPI
36+
and Sign with Sigstore
37+
if: startsWith(github.ref, 'refs/tags/')
38+
needs:
39+
- build
40+
runs-on: ubuntu-latest
41+
environment:
42+
name: pypi
43+
url: https://pypi.org/p/eppo-metrics-sync/
44+
permissions:
45+
id-token: write
46+
contents: write
47+
48+
steps:
49+
- name: Download all the dists
50+
uses: actions/download-artifact@v4
51+
with:
52+
name: python-package-distributions
53+
path: dist/
54+
- name: Publish distribution 📦 to PyPI
55+
uses: pypa/gh-action-pypi-publish@release/v1
56+
- name: Sign the dists with Sigstore
57+
uses: sigstore/[email protected]
58+
with:
59+
inputs: >-
60+
./dist/*.tar.gz
61+
./dist/*.whl

README.md

Lines changed: 115 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,118 @@
1-
### Eppo Metrics Sync
1+
# Eppo Metrics Sync
22

3-
This Python package allows to post a directory of yaml files to Eppo's API. Documentation is available in Eppo's [documentation page](https://docs.geteppo.com/data-management/certified-metrics/).
3+
[![PyPI version](https://badge.fury.io/py/eppo-metrics-sync.svg)](https://badge.fury.io/py/eppo-metrics-sync)
4+
[![Tests](https://github.com/Eppo-exp/eppo-metrics-sync/actions/workflows/run_tests.yml/badge.svg)](https://github.com/Eppo-exp/eppo-metrics-sync/actions)
45

5-
#### Deploying the package
6+
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](https://docs.geteppo.com/data-management/certified-metrics/).
67

7-
Note: this section is intended for Eppo package maintainers.
8-
- Bump version in ```setup.py```
9-
- Install required tools:```python3 -m pip install --upgrade setuptools wheel twine```
10-
- Generate distribution packages:```python3 setup.py sdist bdist_wheel```
11-
- Use Twine to upload the package:```python3 -m twine upload dist/*```
12-
You'll be prompted for your PyPI username and password as well as the API key that is available in 1Password.
8+
## Features
9+
10+
- Sync metrics and fact sources to Eppo
11+
- Validate metric definitions locally
12+
- Support for dbt models
13+
- Dry-run capability for testing
14+
- Prefix support for testing in shared workspaces
15+
16+
## Installation
17+
18+
```bash
19+
pip install eppo-metrics-sync
20+
```
21+
22+
## Usage
23+
24+
### Basic usage
25+
26+
1. Set required environment variables:
27+
28+
```bash
29+
export EPPO_API_KEY="your-api-key"
30+
31+
export EPPO_SYNC_TAG="your-sync-tag" # optional
32+
```
33+
34+
2. Create your metrics YAML files (see [Documentation](#documentation))
35+
36+
3. Run the sync:
37+
38+
```bash
39+
python -m eppo_metrics_sync path/to/yaml/directory
40+
```
41+
42+
### CLI Options
43+
44+
```bash
45+
python -m eppo_metrics_sync [OPTIONS] DIRECTORY
46+
```
47+
48+
Options:
49+
50+
- `--dryrun` Validate files without syncing to Eppo
51+
- `--schema` Schema type: eppo (default) or dbt-model
52+
- `--sync-prefix` Prefix for fact/metric names (useful for testing)
53+
- `--dbt-model-prefix` Warehouse/schema prefix for dbt models
54+
55+
## Documentation
56+
57+
For detailed information about metric configuration and available options, see Eppo's [documentation page](https://docs.geteppo.com/data-management/certified-metrics/).
58+
59+
### Example YAML Configuration
60+
61+
```yaml
62+
fact_sources:
63+
- name: Revenue
64+
sql: |
65+
SELECT ts, user_id, amount
66+
FROM revenue_table
67+
timestamp_column: ts
68+
entities:
69+
- entity_name: User
70+
column: user_id
71+
facts:
72+
- name: Revenue
73+
column: amount
74+
75+
metrics:
76+
- name: Total Revenue
77+
description: Sum of Total Purchase Value in Purchases Fact Table
78+
entity: User
79+
numerator:
80+
fact_name: Revenue
81+
operation: sum
82+
```
83+
84+
## Development
85+
86+
### Setup
87+
88+
#### Create a virtual environment
89+
90+
```bash
91+
python -m venv .venv
92+
source .venv/bin/activate
93+
```
94+
95+
#### Install dependencies
96+
97+
```bash
98+
pip install -r requirements.txt
99+
```
100+
101+
### Running the tests
102+
103+
```bash
104+
pytest tests
105+
```
106+
107+
### Building and Publishing
108+
109+
For package maintainers:
110+
111+
1. Update version in `pyproject.toml`
112+
2. Build the package:
113+
114+
```bash
115+
python -m build
116+
```
117+
118+
3. The package will be automatically published to PyPI when a new release is created on GitHub.

pyproject.toml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
11
[build-system]
22
requires = ["setuptools>=61.0"]
33
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "eppo_metrics_sync"
7+
version = "0.1.3"
8+
description = "Sync metrics to Eppo"
9+
readme = "README.md"
10+
requires-python = ">=3.7"
11+
dependencies = [
12+
"PyYAML",
13+
"jsonschema",
14+
"requests",
15+
]
16+
17+
[tool.setuptools]
18+
include-package-data = true

setup.py

Lines changed: 0 additions & 11 deletions
This file was deleted.

0 commit comments

Comments
 (0)