_coach_cache.py
1 """Shared cache-path helpers for the coaching pipeline. 2 3 Internal to the pipeline package -- consumed by coach_cv and export_coaching. 4 """ 5 6 __all__ = ["CACHE_DIR", "safe_id"] 7 8 import re 9 from pathlib import Path 10 11 CACHE_DIR = Path(__file__).resolve().parents[1] / "cache" / "v1" 12 # Anchored to repo root -- safe regardless of the directory from which the CLI is invoked. 13 # Version prefix so schema changes don't corrupt old cache entries. 14 15 16 def safe_id(job_id: str) -> str: 17 """Sanitize job_id for use in filesystem paths. 18 19 Args: 20 job_id: Raw job posting ID string. 21 22 Returns: 23 String with non-alphanumeric/underscore/hyphen chars replaced by '_'. 24 """ 25 return re.sub(r"[^a-zA-Z0-9_-]", "_", job_id)