-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpush_to_firestore.py
More file actions
31 lines (25 loc) · 905 Bytes
/
push_to_firestore.py
File metadata and controls
31 lines (25 loc) · 905 Bytes
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
import argparse
import compile_statement
from dotenv import load_dotenv
import firebase_admin
from firebase_admin import firestore
import os
import json
load_dotenv()
def main(problem_id, no_compile=False):
if not no_compile:
res = compile_statement.main(problem_id)
if res:
return res
db = firestore.client()
with open(os.path.join(problem_id, "statement.json")) as f:
data = json.load(f)
doc_ref = db.collection('problems').document(problem_id)
doc_ref.set(data)
if __name__ == '__main__':
parser = argparse.ArgumentParser("Push a contest problem to firebase")
parser.add_argument("problem_id", help="The problem id. Usually it's just the name of the folder")
parser.add_argument('--no-compile', "-N", action="store_true", default=False)
args = parser.parse_args()
firebase_admin.initialize_app()
exit(main(args.problem_id, no_compile=args.no_compile))