File size: 2,322 Bytes
c125779
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/usr/bin/env -S uv run
# /// script
# requires-python = ">=3.10"
# dependencies = [
#     "datasets",
#     "huggingface_hub",
# ]
# ///
"""
MCP Clients Pipeline

Runs the full extract → deduplicate pipeline for the MCP clients dataset.

Usage:
    uv run https://huggingface.co/datasets/evalstate/mcp-clients/resolve/main/pipeline.py

The pipeline:
    1. Extracts unique clients from evalstate/hf-mcp-logs
    2. Pushes to evalstate/mcp-clients (raw split)
    3. Creates deduplicated view
    4. Pushes to evalstate/mcp-clients (deduplicated split)
"""

import subprocess
import sys
from datetime import datetime


def run_script(url: str, args: list[str]) -> bool:
    """Run a script via uv run and return success status."""
    cmd = ["uv", "run", url] + args
    print(f"[{datetime.now().isoformat()}] Running: {' '.join(cmd)}", file=sys.stderr)
    
    result = subprocess.run(cmd, capture_output=False)
    
    if result.returncode == 0:
        print(f"[{datetime.now().isoformat()}] Success", file=sys.stderr)
        return True
    else:
        print(f"[{datetime.now().isoformat()}] Failed with exit code {result.returncode}", file=sys.stderr)
        return False


def main():
    base_url = "https://huggingface.co/datasets/evalstate/mcp-clients/resolve/main"
    
    print(f"[{datetime.now().isoformat()}] Starting MCP clients pipeline...", file=sys.stderr)
    
    # Step 1: Extract to raw split
    print(f"[{datetime.now().isoformat()}] Step 1: Extracting clients from hf-mcp-logs...", file=sys.stderr)
    success = run_script(
        f"{base_url}/extract_mcp_clients.py",
        ["--push-to-hub", "--split", "raw"]
    )
    
    if not success:
        print(f"[{datetime.now().isoformat()}] Pipeline failed at extract step", file=sys.stderr)
        sys.exit(1)
    
    # Step 2: Deduplicate to deduplicated split
    print(f"[{datetime.now().isoformat()}] Step 2: Creating deduplicated view...", file=sys.stderr)
    success = run_script(
        f"{base_url}/deduplicate_clients.py",
        ["--push-to-hub"]
    )
    
    if not success:
        print(f"[{datetime.now().isoformat()}] Pipeline failed at dedup step", file=sys.stderr)
        sys.exit(1)
    
    print(f"[{datetime.now().isoformat()}] Pipeline complete!", file=sys.stderr)


if __name__ == "__main__":
    main()