Download core/metric_schema.py from s-b3/LifeStack: direct link, hf CLI and curl.
- Browser
- Download file 867 Bytes
-
https://huggingface.co/spaces/s-b3/LifeStack/resolve/main/core/metric_schema.py
- Command line
-
hf download hf://spaces/s-b3/LifeStack/core/metric_schema.py
-
curl -L -o metric_schema.py https://huggingface.co/spaces/s-b3/LifeStack/resolve/main/core/metric_schema.py
867 Bytes
| from core.life_state import LifeMetrics | |
| VALID_METRIC_PATHS = tuple(sorted(LifeMetrics().flatten().keys())) | |
| LEGACY_METRIC_ALIASES = { | |
| "physical_health.exercise_routine": "physical_health.fitness", | |
| } | |
| def normalize_metric_path(path: str) -> str: | |
| """Map legacy or malformed metric names onto the current LifeMetrics schema.""" | |
| if not isinstance(path, str): | |
| return "" | |
| path = path.strip() | |
| return LEGACY_METRIC_ALIASES.get(path, path) | |
| def is_valid_metric_path(path: str) -> bool: | |
| return normalize_metric_path(path) in VALID_METRIC_PATHS | |
| def format_valid_metrics() -> str: | |
| grouped = {} | |
| for path in VALID_METRIC_PATHS: | |
| domain, metric = path.split(".", 1) | |
| grouped.setdefault(domain, []).append(metric) | |
| return "\n".join( | |
| f"{domain}: {', '.join(metrics)}" for domain, metrics in grouped.items() | |
| ) | |