MCPcopy
hub / github.com/cft0808/edict / get_task_data_dir

Function get_task_data_dir

dashboard/server.py:117–134  ·  view source on GitHub ↗

自动选择当前任务数据目录,并缓存结果以保持一次服务期内稳定。

()

Source from the content-addressed store, hash-verified

115
116
117def get_task_data_dir():
118 """自动选择当前任务数据目录,并缓存结果以保持一次服务期内稳定。"""
119 global _ACTIVE_TASK_DATA_DIR
120 if _ACTIVE_TASK_DATA_DIR and _ACTIVE_TASK_DATA_DIR.is_dir():
121 return _ACTIVE_TASK_DATA_DIR
122 best_dir = DATA
123 best_score = (-1, -1, -1, -1)
124 for d in _iter_task_data_dirs():
125 tf = d / 'tasks_source.json'
126 if not tf.exists():
127 continue
128 score = _task_source_score(tf)
129 if score > best_score:
130 best_score = score
131 best_dir = d
132 _ACTIVE_TASK_DATA_DIR = best_dir
133 log.info(f'任务数据源: {_ACTIVE_TASK_DATA_DIR}')
134 return _ACTIVE_TASK_DATA_DIR
135
136
137def load_tasks():

Callers 5

load_tasksFunction · 0.85
save_tasksFunction · 0.85
_trigger_refreshFunction · 0.85
modify_tasksFunction · 0.85
do_GETMethod · 0.85

Calls 2

_iter_task_data_dirsFunction · 0.85
_task_source_scoreFunction · 0.85

Tested by

no test coverage detected