Spaces:
Runtime error
Runtime error
File size: 584 Bytes
2756582 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import json
from edu_assistant.learning_tasks.coding_problem import CodingProblem
def load_problems(file_path: str):
"""load problems from json file and insert into redis orm.
Args:
file_path (str): file path to json file.
"""
with open(file_path, "r", encoding="utf-8") as f:
problems_data = json.load(f)
CodingProblem.enable_redis_orm()
problems = [CodingProblem.parse_obj(problem_data) for problem_data in problems_data]
CodingProblem.insert(problems)
if __name__ == "__main__":
load_problems("examples/coding_problems.json")
|