Unified toolkit to fetch, normalize, score, and export OSS contribution metrics.
Project description
oss-metrics-kit
Toolkit to fetch, normalize, score, and export OSS contribution data — end to end.
Status: early stage; CLI and core models are available and expanding.
What you can do in 5 minutes
- Analyze a GitHub user’s activity and get a simple score summary.
- Save scores into SQLite or Postgres for dashboards.
- Export scores to Parquet for data tools.
- Optionally, let an LLM suggest a rules TOML from your events.
Quick Start (Beginner-friendly)
- Install the package (pick one)
- pip (recommended for users):
pip install oss-metrics-kit - uv (recommended for devs):
uv venv .venv && source .venv/bin/activate && uv sync --dev
- Set a GitHub token (read-only is enough)
export GITHUB_TOKEN=ghp_xxx # or GH_TOKEN
- Analyze your account and print results
ossmk analyze-user <your_github_login> --since 90d --api auto --out -
- Save scores (SQLite for a quick try)
ossmk analyze-user <your_github_login> --out scores.json
ossmk save sqlite:///./metrics.db --input scores.json
- Export scores to Parquet (for data tools)
pip install "oss-metrics-kit[exporters-parquet]"
ossmk analyze-user <your_github_login> --out parquet:./scores.parquet
That’s it. See Getting Started for more step‑by‑step details.
Getting Started (Step-by-step)
If you are new to Python tools or GitHub APIs, read:
- docs/getting-started.md — a gentle, copy‑paste tutorial with expected outputs.
- docs/usage.md — command reference with CI examples.
Install (development)
Use a virtual environment (venv/conda/uv) and install editable:
pip install -e .orpython -m pip install -e .- Check CLI help with
ossmk --help
Note: Running ossmk requires installation. For direct runs during development, either install editable or set PYTHONPATH=src and run the entry point.
Dev environment (uv recommended)
- Install uv
- macOS/Linux:
curl -LsSf https://astral.sh/uv/install.sh | sh - Homebrew:
brew install uv - pipx:
pipx install uv
- Create venv and sync deps
uv venv .venv→source .venv/bin/activateuv sync --dev- All extras:
uv sync --dev --extra all
- Run
ossmk --help(in venv) oruv run ossmk --help
Install from PyPI (users)
- Stable:
pip install oss-metrics-kit - With Postgres exporter:
pip install "oss-metrics-kit[exporters-postgres]"
Examples
- Persist scores to Postgres:
export OSSMK_PG_DSN="postgresql://user:pass@host:5432/db"
ossmk analyze-user <your_github_login> --save-pg
- Load proprietary rules (TOML):
export OSSMK_RULES_FILE=/absolute/path/to/private/rules.toml
ossmk analyze-user <your_github_login> --out -
Usage (overview)
- Version:
ossmk version - Analyze GitHub user (parallel fetch, since/GraphQL aware):
ossmk analyze-user <login> --since 90d --api auto --out - - Fetch repo events:
ossmk fetch --provider github --repo owner/name --since 30d --out - - Save scores:
ossmk save postgresql://... --input scores.jsonorossmk save sqlite:///./metrics.db --input scores.json
Storage is selected via DSN (Postgres/SQLite). Parquet output is available as an optional exporter.
LLM-assisted rules (optional)
- Suggest rules:
ossmk rules-llm --input events.json --provider openai --model gpt-4o-mini --out rules.toml - Extras:
pip install "oss-metrics-kit[llm-openai]"oross-metrics-kit[llm-anthropic] - See
docs/LLM_RULES.md
Security & operations
- Keep tokens in env (
GITHUB_TOKEN/GH_TOKEN) and never log them. - Rate limiting is a backend responsibility; a simple example is provided at
ossmk.security.ratelimit.RateLimiter(use Redis for production). - Store private rule TOMLs outside the repo and point
OSSMK_RULES_FILEto them.rules=auto|defaultwill load it. - Optional features (Postgres/Parquet/LLM) are separated as extras.
See docs/INTEGRATION.md for backend integration. Development typing/lint policy: docs/dev.md. Detailed usage: docs/usage.md. A beginner tutorial is in docs/getting-started.md.
Python API (import)
The canonical import is:
import ossmk
For convenience, the underscore variant also works and maps to the same package:
import oss_metrics_kit as ossmk
Environment variables
GITHUB_TOKENorGH_TOKEN: GitHub API token (required)OSSMK_RULES_FILE: path to a private rules TOML (optional)OSSMK_PG_DSNorDATABASE_URL: Postgres DSN (if persisting)REDIS_URL: Redis rate limiter (optional)OSSMK_MAX_SINCE_DAYS: max backward window forsince(default 180)
Publishing to PyPI (maintainers)
See docs/RELEASING.md for the full release flow (versioning, tagging, CI-based publish, and manual alternatives).
Design highlights
src/layout withpy.typedfor type distribution.- Thin CLI with Typer; business logic in
ossmk.core. - Providers/exporters/storage/rules via entry points.
Troubleshooting
-
pip._vendor.tomli.TOMLDecodeError: Invalid initial character...- Cause: malformed leading section in
pyproject.toml - Fix: ensure first section is
[build-system], reinstallpip install -e .
- Cause: malformed leading section in
-
ossmk: command not found- Cause: not installed or wrong environment activated.
- Fix:
pip install -e .in the repo, and activate the same environment. - With uv:
uv sync --devthensource .venv/bin/activate, oruv run ossmk --help.
License
Apache-2.0
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
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 oss_metrics_kit-0.1.1.tar.gz.
File metadata
- Download URL: oss_metrics_kit-0.1.1.tar.gz
- Upload date:
- Size: 36.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c1d1891b4c1114410c53b28bacdefe638b74a49bb53565a54fb7f017261c5c0
|
|
| MD5 |
f7c5d201142b5d439289aec3523348cf
|
|
| BLAKE2b-256 |
74fb50b9d38aef38dfb9b6526f24c40107a3681d94582fe3222a420f3286d878
|
Provenance
The following attestation bundles were made for oss_metrics_kit-0.1.1.tar.gz:
Publisher:
publish.yml on refactoring-my-path/oss-metrics-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oss_metrics_kit-0.1.1.tar.gz -
Subject digest:
0c1d1891b4c1114410c53b28bacdefe638b74a49bb53565a54fb7f017261c5c0 - Sigstore transparency entry: 529677605
- Sigstore integration time:
-
Permalink:
refactoring-my-path/oss-metrics-kit@6272b6960504da0b57f1a93fee9b9ddac87292b5 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/refactoring-my-path
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6272b6960504da0b57f1a93fee9b9ddac87292b5 -
Trigger Event:
release
-
Statement type:
File details
Details for the file oss_metrics_kit-0.1.1-py3-none-any.whl.
File metadata
- Download URL: oss_metrics_kit-0.1.1-py3-none-any.whl
- Upload date:
- Size: 34.4 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 |
5f42405217f6d751180c7f414ee68e6cf79a7f86409e52f616bbe651aba14eae
|
|
| MD5 |
808bfcb01a83efbce0726aa21e4f9352
|
|
| BLAKE2b-256 |
840641351bf473c2819018b8ebe8fe264d610ae41d3b63cae50a3403c39b2c64
|
Provenance
The following attestation bundles were made for oss_metrics_kit-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on refactoring-my-path/oss-metrics-kit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
oss_metrics_kit-0.1.1-py3-none-any.whl -
Subject digest:
5f42405217f6d751180c7f414ee68e6cf79a7f86409e52f616bbe651aba14eae - Sigstore transparency entry: 529677622
- Sigstore integration time:
-
Permalink:
refactoring-my-path/oss-metrics-kit@6272b6960504da0b57f1a93fee9b9ddac87292b5 -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/refactoring-my-path
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@6272b6960504da0b57f1a93fee9b9ddac87292b5 -
Trigger Event:
release
-
Statement type: