Spaces:
Runtime error
Runtime error
Download examples/coding_problem_orm.py from codedog-ai/edu-assistant: direct link, hf CLI and curl.
- Browser
- Download file 584 Bytes
-
https://huggingface.co/spaces/codedog-ai/edu-assistant/resolve/main/examples/coding_problem_orm.py
- Command line
-
hf download hf://spaces/codedog-ai/edu-assistant/examples/coding_problem_orm.py
-
curl -L -o coding_problem_orm.py https://huggingface.co/spaces/codedog-ai/edu-assistant/resolve/main/examples/coding_problem_orm.py
584 Bytes
| 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") | |