MCPcopy Create free account
hub / github.com/chidiwilliams/buzz / load_json_tasks

Method load_json_tasks

buzz/cache.py:39–59  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

37 return []
38
39 def load_json_tasks(self) -> List[FileTranscriptionTask]:
40 task_ids: List[int]
41 try:
42 with open(self.tasks_list_file_path) as file:
43 task_ids = json.load(file)
44 except json.JSONDecodeError:
45 logging.debug(
46 "Got JSONDecodeError while reading tasks list file path, "
47 "resetting cache..."
48 )
49 task_ids = []
50
51 tasks = []
52 for task_id in task_ids:
53 try:
54 with open(self.get_task_path(task_id=task_id)) as file:
55 tasks.append(FileTranscriptionTask.from_json(file.read()))
56 except (FileNotFoundError, json.JSONDecodeError):
57 pass
58
59 return tasks
60
61 def save_json_tasks(self, tasks: List[FileTranscriptionTask]):
62 json_str = json.dumps([task.id for task in tasks])

Callers 1

loadMethod · 0.95

Calls 2

get_task_pathMethod · 0.95
loadMethod · 0.45

Tested by

no test coverage detected