MCPcopy Create free account
hub / github.com/diffgram/diffgram / delete_sequence_shared

Function delete_sequence_shared

default/methods/video/sequence.py:151–181  ·  view source on GitHub ↗

We don't want to hard delete a sequence because it can cause foreign key issues. ie the instance sticks around or relates to the id, it then attempts to save it, but the sequence doesnt' exist also if we want todo recovery things in the future this could have issues too...

(session, file, label_file_id, sequence_id)

Source from the content-addressed store, hash-verified

149
150
151def delete_sequence_shared(session, file, label_file_id, sequence_id):
152 """
153 We don't want to hard delete a sequence because it can cause
154 foreign key issues. ie the instance sticks around or relates to the id,
155 it then attempts to save it, but the sequence doesnt' exist
156 also if we want todo recovery things in the future this could have issues too...
157
158 """
159
160 if label_file_id is None or sequence_id is None:
161 return "a required argument is none", 400, {'ContentType': 'application/json'}
162
163 # There are multiple sequences per video and per label, so need ID too
164 # Could of course just do by ID but feels like an extra "check" that other stuff matches too
165
166 sequence = session.query(Sequence).filter(
167 Sequence.video_file_id == file.id,
168 Sequence.label_file_id == label_file_id,
169 Sequence.id == sequence_id).first()
170
171 if sequence is None:
172 return jsonify("Not found"), 400
173
174 for instance in sequence.instance_list:
175 instance.do_soft_delete()
176 session.add(instance)
177
178 sequence.archived = True
179 session.add(sequence)
180
181 return jsonify(success = True), 200
182
183
184#### UPDATE

Callers 2

delete_sequenceFunction · 0.85

Calls 2

do_soft_deleteMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected