basic_check.py 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. from pathlib import Path
  2. ROOT = Path(__file__).resolve().parents[1]
  3. def main():
  4. required = [
  5. "README.md",
  6. "docker-compose.yml",
  7. "ontology/global-shipment.ttl",
  8. "ontology/ai-market-demo-extension.ttl",
  9. "data/qingdao-export-sample.ttl",
  10. "data/ai-market-demo.ttl",
  11. "data/ai-market-scenarios.ttl",
  12. "queries/order-status.rq",
  13. "queries/risk-orders.rq",
  14. "queries/supplier-product-quotes.rq",
  15. "queries/product-performance.rq",
  16. "queries/ai-market-recommended-prices.rq",
  17. "queries/supplier-share-governance.rq",
  18. "app/main.py",
  19. "app/repository.py",
  20. "app/market/service.py",
  21. "app/mock_data.py",
  22. ]
  23. for path in required:
  24. if not (ROOT / path).exists():
  25. raise SystemExit(f"缺少文件: {path}")
  26. ontology = (ROOT / "ontology/global-shipment.ttl").read_text(encoding="utf-8")
  27. sample = (ROOT / "data/qingdao-export-sample.ttl").read_text(encoding="utf-8")
  28. required_terms = [
  29. "gesli:GlobalShipmentOntology",
  30. "gesli:ServiceBrand",
  31. "gesli:ServiceProduct",
  32. "gesli:ProductPerformanceProfile",
  33. "gesli:SupplierProductOffering",
  34. "gesli:ScheduledServiceInstance",
  35. "gesli:SolutionPlan",
  36. "gesli:AIRecommendedPrice",
  37. "gesli:SupplierShareGovernanceStrategy",
  38. ]
  39. for term in required_terms:
  40. if term not in ontology:
  41. raise SystemExit(f"本体缺少核心定义: {term}")
  42. count = sample.count("a gesli:QingdaoExportOrder")
  43. if count < 2:
  44. raise SystemExit("样本订单不足。")
  45. offering_count = sample.count("a gesli:SupplierProductOffering")
  46. if offering_count < 5:
  47. raise SystemExit("供应商产品关系样本不足。")
  48. if "sample:Maersk a gesli:Carrier" in sample:
  49. raise SystemExit("马士基品牌仍被错误建模为平台供应商。")
  50. print(
  51. f"基础检查通过。当前有 {count} 票青岛出口样本订单,"
  52. f"{offering_count} 条供应商产品关系。"
  53. )
  54. if __name__ == "__main__":
  55. main()