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

Function create_file

shared/tests/test_utils/data_mocking.py:362–399  ·  view source on GitHub ↗
(file_data, session)

Source from the content-addressed store, hash-verified

360
361
362def create_file(file_data, session):
363 file = File(
364 project_id = file_data.get('project_id'),
365 job_id = file_data.get('job_id'),
366 original_filename = file_data.get('original_filename', get_random_string(6)),
367 parent_id = file_data.get('parent_id'),
368 type = file_data.get('type', 'image'),
369 state = file_data.get('state', 'added'),
370 frame_number = file_data.get('frame_number'),
371 video_parent_file_id = file_data.get('video_parent_file_id'),
372 )
373 file.type = file_data.get('type', 'image')
374 if file.type == 'video':
375 video = Video(
376 filename = file_data.get('video', {'name': 'test video'}).get('name'),
377 frame_rate = file_data.get('video', {'frame_rate': 60}).get('frame_rate'),
378 frame_count = file_data.get('video', {'frame_count': 100}).get('frame_count'),
379 width = file_data.get('video', {'width': 800}).get('width'),
380 height = file_data.get('video', {'height': 800}).get('height'),
381 parent_video_split_duration = 30,
382 root_blob_path_to_frames = '/test/',
383 )
384 session.add(video)
385 regular_methods.commit_with_rollback(session)
386 file.video = video
387 file.video_parent_file_id = video.id
388 elif file.type in ['image', 'frame']:
389 image = Image()
390 session.add(image)
391 regular_methods.commit_with_rollback(session)
392 file.image = image
393 file.image_id = image.id
394 elif file.type == 'label':
395 label = create_label({'name': 'test_label'}, session)
396 file.label_id = label.id
397 session.add(file)
398 regular_methods.commit_with_rollback(session)
399 return file
400
401
402def create_job_launch(job_launch_data, session):

Callers

nothing calls this directly

Calls 7

FileClass · 0.90
VideoClass · 0.90
ImageClass · 0.90
get_random_stringFunction · 0.85
create_labelFunction · 0.85
getMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected