MCPcopy Index your code
hub / github.com/diffgram/diffgram / task_annotation_update

Function task_annotation_update

shared/annotation.py:2188–2243  ·  view source on GitHub ↗
(
    session,
    task_id: int,
    input,
    untrusted_input,
    task = None,
    member = None,
    log = regular_log.default())

Source from the content-addressed store, hash-verified

2186
2187
2188def task_annotation_update(
2189 session,
2190 task_id: int,
2191 input,
2192 untrusted_input,
2193 task = None,
2194 member = None,
2195 log = regular_log.default()):
2196 # In context of already having the {task} object,
2197 # ie for newly created stuff... (to prevent race conditions)
2198 if not task:
2199 task = Task.get_by_id(session = session,
2200 task_id = task_id)
2201 if not task:
2202 return False
2203
2204 # TODO Why are we adding this to session here? not clear
2205 session.add(task)
2206 child_file_save_id = input.get('child_file_save_id')
2207 project = task.project
2208
2209 instance_list_new = untrusted_input.get('instance_list', None)
2210 gold_standard_file = untrusted_input.get('gold_standard_file', None)
2211 try:
2212 if child_file_save_id is None:
2213 file = File.get_by_id(session = session, file_id = task.file_id)
2214 else:
2215 file = File.get_by_id(session = session, file_id = child_file_save_id)
2216 except Exception as e:
2217 trace = traceback.format_exc()
2218 logger.error(f"File {task.file_id} is Locked")
2219 logger.error(trace)
2220 log['error']['file_locked'] = 'File is being saved by another process, please try again later.'
2221 return False, None
2222 annotation_update = Annotation_Update(
2223 session = session,
2224 task = task,
2225 file = file,
2226 project = project,
2227 member = member,
2228 instance_list_new = instance_list_new,
2229 video_data = input['video_data'],
2230 do_init_existing_instances = True
2231 )
2232
2233 new_file = annotation_update.main()
2234
2235 if input['and_complete'] is True:
2236 result, new_file = task_complete.task_complete(
2237 session = session,
2238 task = task,
2239 new_file = new_file,
2240 project = project,
2241 member = member)
2242
2243 return new_file.serialize_with_type(session), annotation_update
2244
2245

Callers 1

Calls 6

mainMethod · 0.95
Annotation_UpdateClass · 0.85
serialize_with_typeMethod · 0.80
get_by_idMethod · 0.45
addMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected