Skip to content

Commit

Permalink
feat: update task_set_doc_index in every task set data sync
Browse files Browse the repository at this point in the history
  • Loading branch information
atnanahidiw committed Nov 17, 2023
1 parent e520701 commit 1e1c255
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions utils/scripts/update_bebras_task_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@
initialize_app(creds)

firestore_client = firestore.client()
col_ref = firestore_client.collection("task_set")
configuration_coll_ref = firestore_client.collection("configuration")
taskset_coll_ref = firestore_client.collection("task_set")

task_set_doc_index = []
file_list = glob("data/bebras_task/*/*/*.json")
for file in file_list:
with open(file, "r") as f:
Expand All @@ -20,4 +22,13 @@
content["challenge_group"] = file_ref[-3]

name = "{}_{}".format(file_ref[-3], file_ref[-1])
col_ref.document(name).set(content)
taskset_coll_ref.document(name).set(content)
task_set_doc_index.append({
"doc_id": name,
"title": content["title"],
"challenge_group": content["challenge_group"],
})

configuration_coll_ref.document('global_variables').update({
"task_set_doc_index": task_set_doc_index
})

0 comments on commit 1e1c255

Please sign in to comment.