Spaces:
Runtime error
Runtime error
| 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") | |