Datasets:
Download load_example.py from gemmozero/mcp-tool-change-events: direct link, hf CLI and curl.
- Browser
- Download file 1.92 kB
-
https://huggingface.co/datasets/gemmozero/mcp-tool-change-events/resolve/main/load_example.py
- Command line
-
hf download hf://datasets/gemmozero/mcp-tool-change-events/load_example.py
-
curl -L -o load_example.py https://huggingface.co/datasets/gemmozero/mcp-tool-change-events/resolve/main/load_example.py
1.92 kB
| #!/usr/bin/env python3 | |
| """Exemples de chargement (local ou, après publication, depuis le Hub). | |
| pip install datasets # optionnel | |
| """ | |
| import json, sys | |
| # 1) Hugging Face `datasets` (après publication ; REPO_ID à confirmer au GO) | |
| # from datasets import load_dataset | |
| # ev = load_dataset("gemmozero/mcp-tool-change-events", "events") # splits: train / test (temporel) | |
| # bm = load_dataset("gemmozero/mcp-tool-change-events", "benchmark") # splits: train / test (par serveur) | |
| # 2) Sans dépendance : JSON Lines | |
| import os | |
| import pandas as pd | |
| ev = pd.read_parquet("data/events/train.parquet").to_dict("records") | |
| bm = pd.read_parquet("data/benchmark/test.parquet").to_dict("records") if os.path.exists("data/benchmark/test.parquet") else [] | |
| print(len(ev), "events (train);", len(bm), "benchmark rows (test)") | |
| if not bm: | |
| raise SystemExit(0) | |
| # 3) Tâche benchmark minimale : prédire `label` (added/removed/modified/unchanged) à partir de before/after, | |
| # ou `description_changed` / `schema_changed`. Baseline exacte (diff textuel) pour vérifier le chargement : | |
| correct = sum(((x["before_definition"] is None and x["label"] == "added") or (x["after_definition"] is None and x["label"] == "removed") or | |
| (x["before_definition"] is not None and x["after_definition"] is not None and | |
| (x["label"] == "unchanged") == (json.loads(x["before_definition"]).get("description") == json.loads(x["after_definition"]).get("description") and | |
| json.dumps(json.loads(x["before_definition"]).get("inputSchema"), sort_keys=True) == json.dumps(json.loads(x["after_definition"]).get("inputSchema"), sort_keys=True)))) | |
| for x in bm) | |
| print("exact-diff baseline agreement on test:", correct, "/", len(bm)) | |
| # 4) Vérifier un record hors ligne : python3 verify.py (signatures Ed25519 + preuves d'inclusion Merkle échantillonnées) | |