composite_runtime.py 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. from __future__ import annotations
  2. from pathlib import Path
  3. from typing import Any
  4. from content_agent.interfaces import RuntimeStore
  5. class CompositeRuntimeStore:
  6. def __init__(self, primary: RuntimeStore, export: RuntimeStore) -> None:
  7. self.primary = primary
  8. self.export = export
  9. def prepare_run(self, run_id: str) -> Path:
  10. self.primary.prepare_run(run_id)
  11. return self.export.prepare_run(run_id)
  12. def run_dir(self, run_id: str) -> Path:
  13. return self.export.run_dir(run_id)
  14. def write_json(self, run_id: str, filename: str, data: dict[str, Any]) -> Path:
  15. self.primary.write_json(run_id, filename, data)
  16. return self.export.write_json(run_id, filename, data)
  17. def update_json(self, run_id: str, filename: str, data: dict[str, Any]) -> Path:
  18. self.primary.update_json(run_id, filename, data)
  19. return self.export.update_json(run_id, filename, data)
  20. def append_jsonl(self, run_id: str, filename: str, rows: list[dict[str, Any]]) -> Path:
  21. self.primary.append_jsonl(run_id, filename, rows)
  22. return self.export.append_jsonl(run_id, filename, rows)
  23. def read_json(self, run_id: str, filename: str) -> dict[str, Any]:
  24. return self.export.read_json(run_id, filename)
  25. def read_jsonl(self, run_id: str, filename: str) -> list[dict[str, Any]]:
  26. return self.export.read_jsonl(run_id, filename)
  27. def file_status(self, run_id: str) -> dict[str, bool]:
  28. return self.export.file_status(run_id)
  29. def create_run_record(self, record: dict[str, Any]) -> None:
  30. self.primary.create_run_record(record)
  31. self.export.create_run_record(record)
  32. def update_run_record(self, run_id: str, updates: dict[str, Any]) -> None:
  33. self.primary.update_run_record(run_id, updates)
  34. self.export.update_run_record(run_id, updates)
  35. def record_policy_run(self, record: dict[str, Any]) -> None:
  36. self.primary.record_policy_run(record)
  37. self.export.record_policy_run(record)
  38. def append_run_event_records(
  39. self,
  40. run_id: str,
  41. policy_run_id: str,
  42. rows: list[dict[str, Any]],
  43. ) -> None:
  44. self.primary.append_run_event_records(run_id, policy_run_id, rows)
  45. self.export.append_run_event_records(run_id, policy_run_id, rows)
  46. def write_publish_jobs(
  47. self,
  48. run_id: str,
  49. policy_run_id: str,
  50. rows: list[dict[str, Any]],
  51. ) -> None:
  52. self.primary.write_publish_jobs(run_id, policy_run_id, rows)
  53. self.export.write_publish_jobs(run_id, policy_run_id, rows)
  54. def write_author_assets(self, rows: list[dict[str, Any]]) -> None:
  55. self.primary.write_author_assets(rows)
  56. self.export.write_author_assets(rows)
  57. def write_author_asset_roles(self, rows: list[dict[str, Any]]) -> None:
  58. self.primary.write_author_asset_roles(rows)
  59. self.export.write_author_asset_roles(rows)
  60. def write_search_clue_assets(self, rows: list[dict[str, Any]]) -> None:
  61. self.primary.write_search_clue_assets(rows)
  62. self.export.write_search_clue_assets(rows)
  63. def write_search_clue_asset_evidence(self, rows: list[dict[str, Any]]) -> None:
  64. self.primary.write_search_clue_asset_evidence(rows)
  65. self.export.write_search_clue_asset_evidence(rows)
  66. def read_performance_feedback(
  67. self,
  68. run_id: str,
  69. policy_run_id: str,
  70. ) -> list[dict[str, Any]]:
  71. return self.primary.read_performance_feedback(run_id, policy_run_id)