Spaces:
Running
Running
Download module_resolver.py from DJ-Goanna-Coding/Oppo-TIA: direct link, hf CLI and curl.
- Browser
- Download file 2.07 kB
-
https://huggingface.co/spaces/DJ-Goanna-Coding/Oppo-TIA/resolve/main/module_resolver.py
- Command line
-
hf download hf://spaces/DJ-Goanna-Coding/Oppo-TIA/module_resolver.py
-
curl -L -o module_resolver.py https://huggingface.co/spaces/DJ-Goanna-Coding/Oppo-TIA/resolve/main/module_resolver.py
2.07 kB
| """Module Resolver — resolves and verifies import paths for the TIA backend.""" | |
| import importlib | |
| import os | |
| import sys | |
| # Ensure project root is importable. | |
| _PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__)) | |
| if _PROJECT_ROOT not in sys.path: | |
| sys.path.insert(0, _PROJECT_ROOT) | |
| # Expected import paths → class names. | |
| EXPECTED_IMPORTS = { | |
| "TIA.worker": "TIAWorker", | |
| "citadel.primeSchema": "PrimeSchema", | |
| "citadel.holo3d.ui.commandCentre": "CommandCentre", | |
| "citadel.lineage": "Lineage", | |
| "citadel.peace_vortex": "PeaceVortex", | |
| "citadel.alpha_nex": "AlphaNex", | |
| "harvester.washed_harvest": "WashedHarvest", | |
| "bio.vessel_firewall": "VesselFirewall", | |
| } | |
| def resolve(module_path: str, class_name: str): | |
| """Attempt to import *class_name* from *module_path*. | |
| Returns: | |
| The class object on success, or ``None`` on failure. | |
| """ | |
| try: | |
| mod = importlib.import_module(module_path) | |
| return getattr(mod, class_name, None) | |
| except Exception: | |
| return None | |
| def resolve_all() -> dict: | |
| """Resolve every expected import and return results. | |
| Returns: | |
| dict mapping ``"module.Class"`` to the resolved class or ``None``. | |
| """ | |
| results = {} | |
| for mod_path, cls_name in EXPECTED_IMPORTS.items(): | |
| cls = resolve(mod_path, cls_name) | |
| results[f"{mod_path}.{cls_name}"] = cls | |
| return results | |
| def verify() -> bool: | |
| """Verify that all expected imports resolve successfully. | |
| Returns: | |
| ``True`` if every import resolved, ``False`` otherwise. | |
| """ | |
| results = resolve_all() | |
| all_ok = all(v is not None for v in results.values()) | |
| print("\n=== Module Resolver Verification ===\n") | |
| for key, cls in results.items(): | |
| mark = "\u2705" if cls is not None else "\u274c" | |
| print(f" {mark} {key}") | |
| print(f"\n Result: {'ALL OK' if all_ok else 'SOME FAILED'}\n") | |
| return all_ok | |
| if __name__ == "__main__": | |
| ok = verify() | |
| sys.exit(0 if ok else 1) | |