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

Method update

shared/database/video/sequence.py:289–348  ·  view source on GitHub ↗
(
            session,
            project,
            video_mode,
            instance,
            video_file)

Source from the content-addressed store, hash-verified

287
288 @staticmethod
289 def update(
290 session,
291 project,
292 video_mode,
293 instance,
294 video_file):
295
296 if video_mode is not True:
297 return None
298
299 if instance.frame_number is None:
300 return None
301
302 sequence = None # edge case, we usually expect to return sequence object
303 is_new_sequence = False
304
305 # Default case, instance already had a sequence id
306 logger.debug(f"Updating sequence for sequence id {instance.sequence_id}")
307 if instance.sequence_id:
308 sequence = Sequence.update_single_existing_sequence(
309 session = session,
310 instance = instance,
311 video_file = video_file
312 )
313
314 if not instance.sequence_id:
315 logger.debug(f"No ID checking for number {instance.number}")
316 # Most common case for new instances
317 # We have a number from UI but we don't have it mapped To a sequence
318
319 if instance.number is not None:
320
321 sequence = Sequence.get_from_video_label_number(
322 session = session,
323 video_file_id = video_file.id,
324 label_file_id = instance.label_file_id,
325 number = instance.number
326 )
327
328 if sequence:
329 session.add(sequence)
330
331 if not sequence:
332 sequence = Sequence.new(
333 number = instance.number,
334 video_file_id = video_file.id,
335 label_file = instance.label_file
336 )
337
338 # it needs instance to do things like crop the image
339 is_new_sequence = True
340 session.add(sequence)
341 session.flush()
342
343 sequence.has_changes = True
344 instance.sequence_id = sequence.id
345
346 session.add(instance)

Callers 15

test_updateMethod · 0.45
archive_related_tasksFunction · 0.45
update_discussion_coreFunction · 0.45
add_orbit_controlsMethod · 0.45
center_camera_to_meshMethod · 0.45
constructorMethod · 0.45
handleMouseMoveRotateMethod · 0.45
handleMouseMoveDollyMethod · 0.45
handleMouseMovePanMethod · 0.45
handleMouseWheelMethod · 0.45

Calls 4

addMethod · 0.45
newMethod · 0.45

Tested by 2

test_updateMethod · 0.36