from __future__ import annotations import inspect import json import sqlite3 import sys from pathlib import Path sys.path.insert(0, str(Path(__file__).parent.parent / "src")) from pino.thermo import vle as vle_module from pino.registry import AromaRegistry def main() -> None: print("=" * 60) print("PINO Thermodynamic Environment Audit") print("=" * 60) # 1. Registry source and format print("\n[1] Registry Source") aroma_jsonl = Path("data/aroma_chemicals.jsonl") registry_db = Path("src/pino/registry.db") if aroma_jsonl.exists(): print(f" - Found {aroma_jsonl} ({aroma_jsonl.stat().st_size / 1024:.1f} KB)") with aroma_jsonl.open("r") as f: line = f.readline().strip() sample = json.loads(line) print(f" - Top-level keys: {sorted(sample.keys())}") else: print(f" - {aroma_jsonl} NOT FOUND") if registry_db.exists(): print(f" - Found {registry_db} ({registry_db.stat().st_size / 1024:.1f} KB)") conn = sqlite3.connect(registry_db) conn.row_factory = sqlite3.Row rows = conn.execute("PRAGMA table_info(aroma_chemicals)").fetchall() print(" - SQLite columns:") for row in rows: print(f" {row['name']}: {row['type']}") count = conn.execute("SELECT COUNT(*) FROM aroma_chemicals").fetchone()[0] print(f" - Row count: {count}") else: print(f" - {registry_db} NOT FOUND") # 2. VLE module interface print("\n[2] VLE Module Interface") for name, obj in inspect.getmembers(vle_module): if inspect.isclass(obj): print(f" - class {name}") for method_name, method in inspect.getmembers(obj, predicate=inspect.isfunction): sig = inspect.signature(method) print(f" {method_name}{sig}") # 3. AromaRegistry interface print("\n[3] AromaRegistry Interface") registry = AromaRegistry() print(f" - db_path: {registry.path}") methods = [ name for name in dir(registry) if not name.startswith("_") and callable(getattr(registry, name)) ] print(f" - Public methods: {methods}") # 4. Sample rows print("\n[4] Sample Registry Rows") sample_rows = registry._conn.execute("SELECT * FROM aroma_chemicals LIMIT 3").fetchall() for row in sample_rows: record = dict(row) record["unifac_groups"] = json.loads(record.get("unifac_groups") or "{}") record["openpom_embedding"] = json.loads(record.get("openpom_embedding") or "[]") record["shape_3d_features"] = json.loads(record.get("shape_3d_features") or "[]") print(f" - {record.get('cas')}: {record.keys()}") print(f" name={record.get('name')}") print(f" smiles={record.get('smiles')}") print(f" openpom_len={len(record.get('openpom_embedding', []))}") print(f" shape_3d_len={len(record.get('shape_3d_features', []))}") print(f" unifac_groups={record.get('unifac_groups')}") print("\n" + "=" * 60) print("Audit complete.") print("=" * 60) if __name__ == "__main__": main()