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

Method extract_metadata_from_batch

walrus/methods/input/upload.py:52–73  ·  view source on GitHub ↗
(self, input, input_batch_id, file_name)

Source from the content-addressed store, hash-verified

50 return result
51
52 def extract_metadata_from_batch(self, input, input_batch_id, file_name):
53 input_batch = InputBatch.get_by_id(self.session, id = input_batch_id)
54 pre_labels = input_batch.pre_labeled_data
55 if pre_labels is None:
56 return input
57 uuid = None
58 file_data = None
59 if self.request:
60 uuid = self.request.form.get('uuid')
61 file_data = pre_labels.get(uuid)
62 if file_data is None:
63 # Try finding the pre_labels with the file_name as a backup
64 file_data = pre_labels.get(file_name)
65 if file_data is None:
66 logger.warning(f"Input: {input.id} File {file_name} has no pre_labeled data associated")
67 return
68
69 if file_data.get('file_metadata'):
70 file_metadata = file_data.get('file_metadata')
71 input.file_metadata = file_metadata
72
73 return input
74
75 def extract_instance_list_from_batch(self, input, input_batch_id, file_name):
76 if input_batch_id is None:

Callers 1

create_inputMethod · 0.95

Calls 2

get_by_idMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected