| 12345678910111213141516171819202122232425262728 |
- """Metric constants for the Web backend - derived from the single source
- of truth in the platform core (src/afmcore/metrics.py).
- THIS FILE MUST NOT define its own metric lists. All definitions, aliases,
- labels, directions and required-metric rules live in src/afmcore/metrics.py.
- If you add a metric, edit src/afmcore/metrics.py only.
- Deployment note: when the Web backend is packaged without the repository
- tree, make src/afmcore importable (e.g. pip install -e ., or copy
- src/afmcore into the backend as a package) so this module keeps resolving.
- """
- import os
- import sys
- # Make the repository src/ importable when running from a checkout.
- _BACKEND_APP_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- # web/backend/app/metrics_constants.py -> <repo>/src
- _SRC_DIR = os.path.normpath(os.path.join(_BACKEND_APP_DIR, "..", "..", "src"))
- if _SRC_DIR not in sys.path and os.path.isdir(_SRC_DIR):
- sys.path.insert(0, _SRC_DIR)
- from afmcore.metrics import ( # noqa: E402
- METRIC_KEYS,
- METRIC_LABELS,
- METRIC_UNITS,
- METRIC_DIRECTIONS,
- REQUIRED_METRICS,
- )
|