If the type is a video, we assume the front end will pass the correct frame_number to be used. We get the image file using the frame id and the task.file_id as the parent.
(task_id)
| 50 | @routes.route('/api/v1/task/<int:task_id>/annotation/update', methods = ['POST']) |
| 51 | @Permission_Task.by_task_id(apis_user_list = ["builder_or_trainer"]) |
| 52 | def task_annotation_update_api(task_id): |
| 53 | # None for now since may be empty if no changes |
| 54 | """ |
| 55 | If the type is a video, we assume the front end will pass the correct frame_number |
| 56 | to be used. We get the image file using the frame id and the task.file_id as the |
| 57 | parent. |
| 58 | |
| 59 | """ |
| 60 | |
| 61 | spec_list = [{"instance_list": None}, |
| 62 | {"and_complete": bool}, |
| 63 | {"child_file_save_id": { |
| 64 | "required": False, |
| 65 | "kind": int |
| 66 | }}, |
| 67 | {"video_data": { |
| 68 | 'kind': dict, |
| 69 | 'default': None |
| 70 | } |
| 71 | }] |
| 72 | |
| 73 | log, input, untrusted_input = regular_input.master(request = request, |
| 74 | spec_list = spec_list) |
| 75 | if len(log["error"].keys()) >= 1: |
| 76 | return jsonify(log = log), 400 |
| 77 | |
| 78 | # MAIN |
| 79 | with sessionMaker.session_scope() as session: |
| 80 | member = get_member(session = session) |
| 81 | new_file, annotation_update = task_annotation_update( |
| 82 | session = session, |
| 83 | task_id = task_id, |
| 84 | input = input, |
| 85 | member = member, |
| 86 | untrusted_input = untrusted_input, |
| 87 | log = log) |
| 88 | |
| 89 | if len(log["error"].keys()) >= 1: |
| 90 | return jsonify(log = log), 400 |
| 91 | |
| 92 | if len(annotation_update.log["error"].keys()) >= 1: |
| 93 | return jsonify(log = annotation_update.log), 400 |
| 94 | |
| 95 | sequence = None |
| 96 | if annotation_update.sequence: |
| 97 | sequence = annotation_update.sequence.serialize_for_label_subset( |
| 98 | session = session) |
| 99 | |
| 100 | new_sequence_list = [] |
| 101 | if annotation_update.new_created_sequence_list: |
| 102 | new_sequence_list = [seq.serialize_for_label_subset(session = session) for seq in annotation_update.new_created_sequence_list] |
| 103 | |
| 104 | deleted_instances = annotation_update.new_deleted_instances |
| 105 | added_instances = annotation_update.new_added_instances |
| 106 | # We need to serialize all the instances for the frontend to render them correctly. |
| 107 | added_instances = [x.serialize() for x in added_instances] |
| 108 | |
| 109 | return jsonify( |
nothing calls this directly
no test coverage detected