Add pipeline.py for combined extract+dedup
Browse files- pipeline.py +75 -0
pipeline.py
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env -S uv run
|
| 2 |
+
# /// script
|
| 3 |
+
# requires-python = ">=3.10"
|
| 4 |
+
# dependencies = [
|
| 5 |
+
# "datasets",
|
| 6 |
+
# "huggingface_hub",
|
| 7 |
+
# ]
|
| 8 |
+
# ///
|
| 9 |
+
"""
|
| 10 |
+
MCP Clients Pipeline
|
| 11 |
+
|
| 12 |
+
Runs the full extract → deduplicate pipeline for the MCP clients dataset.
|
| 13 |
+
|
| 14 |
+
Usage:
|
| 15 |
+
uv run https://huggingface.co/datasets/evalstate/mcp-clients/resolve/main/pipeline.py
|
| 16 |
+
|
| 17 |
+
The pipeline:
|
| 18 |
+
1. Extracts unique clients from evalstate/hf-mcp-logs
|
| 19 |
+
2. Pushes to evalstate/mcp-clients (raw split)
|
| 20 |
+
3. Creates deduplicated view
|
| 21 |
+
4. Pushes to evalstate/mcp-clients (deduplicated split)
|
| 22 |
+
"""
|
| 23 |
+
|
| 24 |
+
import subprocess
|
| 25 |
+
import sys
|
| 26 |
+
from datetime import datetime
|
| 27 |
+
|
| 28 |
+
|
| 29 |
+
def run_script(url: str, args: list[str]) -> bool:
|
| 30 |
+
"""Run a script via uv run and return success status."""
|
| 31 |
+
cmd = ["uv", "run", url] + args
|
| 32 |
+
print(f"[{datetime.now().isoformat()}] Running: {' '.join(cmd)}", file=sys.stderr)
|
| 33 |
+
|
| 34 |
+
result = subprocess.run(cmd, capture_output=False)
|
| 35 |
+
|
| 36 |
+
if result.returncode == 0:
|
| 37 |
+
print(f"[{datetime.now().isoformat()}] Success", file=sys.stderr)
|
| 38 |
+
return True
|
| 39 |
+
else:
|
| 40 |
+
print(f"[{datetime.now().isoformat()}] Failed with exit code {result.returncode}", file=sys.stderr)
|
| 41 |
+
return False
|
| 42 |
+
|
| 43 |
+
|
| 44 |
+
def main():
|
| 45 |
+
base_url = "https://huggingface.co/datasets/evalstate/mcp-clients/resolve/main"
|
| 46 |
+
|
| 47 |
+
print(f"[{datetime.now().isoformat()}] Starting MCP clients pipeline...", file=sys.stderr)
|
| 48 |
+
|
| 49 |
+
# Step 1: Extract to raw split
|
| 50 |
+
print(f"[{datetime.now().isoformat()}] Step 1: Extracting clients from hf-mcp-logs...", file=sys.stderr)
|
| 51 |
+
success = run_script(
|
| 52 |
+
f"{base_url}/extract_mcp_clients.py",
|
| 53 |
+
["--push-to-hub", "--split", "raw"]
|
| 54 |
+
)
|
| 55 |
+
|
| 56 |
+
if not success:
|
| 57 |
+
print(f"[{datetime.now().isoformat()}] Pipeline failed at extract step", file=sys.stderr)
|
| 58 |
+
sys.exit(1)
|
| 59 |
+
|
| 60 |
+
# Step 2: Deduplicate to deduplicated split
|
| 61 |
+
print(f"[{datetime.now().isoformat()}] Step 2: Creating deduplicated view...", file=sys.stderr)
|
| 62 |
+
success = run_script(
|
| 63 |
+
f"{base_url}/deduplicate_clients.py",
|
| 64 |
+
["--push-to-hub"]
|
| 65 |
+
)
|
| 66 |
+
|
| 67 |
+
if not success:
|
| 68 |
+
print(f"[{datetime.now().isoformat()}] Pipeline failed at dedup step", file=sys.stderr)
|
| 69 |
+
sys.exit(1)
|
| 70 |
+
|
| 71 |
+
print(f"[{datetime.now().isoformat()}] Pipeline complete!", file=sys.stderr)
|
| 72 |
+
|
| 73 |
+
|
| 74 |
+
if __name__ == "__main__":
|
| 75 |
+
main()
|