forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathframe_request_retention_job.py
More file actions
38 lines (27 loc) · 1.13 KB
/
Copy pathframe_request_retention_job.py
File metadata and controls
38 lines (27 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
"""Independent Cloud Run Job entrypoint for frame-request retention."""
from __future__ import annotations
import json
import logging
import os
import firebase_admin
from services.frame_request_retention import run_frame_request_retention_maintenance
logging.basicConfig(level=logging.INFO)
logger = logging.getLogger(__name__)
def _init_firebase() -> None:
service_account_json = os.getenv("SERVICE_ACCOUNT_JSON")
if service_account_json:
credentials = firebase_admin.credentials.Certificate(json.loads(service_account_json))
firebase_admin.initialize_app(credentials) # type: ignore[reportUnknownMemberType]
else:
firebase_admin.initialize_app() # type: ignore[reportUnknownMemberType]
def main() -> None:
_init_firebase()
logger.info("Starting frame-request-retention-job...")
result = run_frame_request_retention_maintenance()
if result["accounts_with_errors"]:
raise RuntimeError(
"frame-request-retention-job completed with "
f"{result['accounts_with_errors']} account error(s); retry queue persisted"
)
if __name__ == "__main__":
main()