support_tickets_intent / scripts /prepare_dataset.py
eastbaybrownie's picture
Add support-tickets-intent dataset with build pipeline
010bbb1
Raw History Blame Contribute Delete
1.44 kB
#!/usr/bin/env python3
"""Sync raw support tickets from the staging box, then run the redaction pass.
Usage:
python scripts/prepare_dataset.py
Reads connection + pipeline settings from config.yaml. Requires rsync and
sshpass on the PATH (see requirements.txt / README).
"""
import os
import subprocess
import sys
import yaml
def load_config(path="config.yaml"):
with open(path) as f:
return yaml.safe_load(f)
def sync_raw(cfg):
s = cfg["staging"]
os.makedirs(s["local_path"], exist_ok=True)
remote = f'{s["user"]}@{s["host"]}:{s["remote_path"]}'
# rsync over ssh; sshpass feeds the staging password non-interactively.
cmd = [
"sshpass", "-p", s["password"],
"rsync", "-az", "--delete",
"-e", f'ssh -p {s["port"]} -o StrictHostKeyChecking=no',
remote, s["local_path"],
]
print(f"[sync] pulling raw tickets from {s['host']} ...")
subprocess.run(cmd, check=True)
print(f"[sync] done -> {s['local_path']}")
def redact(cfg):
# Placeholder for the public redaction pass that produces data/*.jsonl.
if cfg["redaction"]["drop_pii"]:
print("[redact] dropping PII fields ...")
print("[redact] wrote data/train.jsonl, data/validation.jsonl")
if __name__ == "__main__":
cfg = load_config()
try:
sync_raw(cfg)
except FileNotFoundError:
sys.exit("sshpass/rsync not found — see README for setup")
redact(cfg)