|
1 |
| -### Eppo Metrics Sync |
| 1 | +# Eppo Metrics Sync |
2 | 2 |
|
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 | +[](https://badge.fury.io/py/eppo-metrics-sync) |
| 4 | +[](https://github.com/Eppo-exp/eppo-metrics-sync/actions) |
4 | 5 |
|
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/). |
6 | 7 |
|
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. |
0 commit comments