MCPcopy
hub / github.com/diffgram/diffgram / annotation_export_core

Function annotation_export_core

shared/export/export_generation.py:151–287  ·  view source on GitHub ↗

Generic method to export a file list

(
    session,
    project,
    export,
    file_list)

Source from the content-addressed store, hash-verified

149
150
151def annotation_export_core(
152 session,
153 project,
154 export,
155 file_list):
156 """
157 Generic method to export a file list
158 """
159
160 images_dir = f"{settings.PROJECT_IMAGES_BASE_DIR + str(project.id)}/"
161
162 export.file_list_length = len(file_list)
163
164 errors_result = check_for_errors(
165 export = export,
166 session = session)
167 if errors_result is False:
168 return False, None
169
170 # If we build annotations directly then we could return them
171 # If tf records than not
172 # But some clean up stuff (ie marking complete) that's joint
173 # Also not clear where we would be using a return dict of annotations here
174 # Ohhh it returns annotations since we upload in YAML or JSON format for that
175 # Maybe that should just be part of that process (instead of returning with a
176 # seperate flag?)
177
178 annotations = None
179
180 # This is here as it's shared with with masks and
181 # not masks, but needs to run before masks if masks
182
183 # So we can have mask values increase in series
184 # instead of using ids for example
185
186 # Careful, want to use project default directory for labels for now
187
188 label_file_list = WorkingDirFileLink.file_list(
189 session = session,
190 working_dir_id = export.project.directory_default_id,
191 limit = None,
192 type = "label"
193 )
194
195 if export.kind == "TF Records":
196 label_dict = data_tools.label_dict_builder(
197 file_list = label_file_list)
198
199 export_label_map = {}
200 for label_file in label_file_list:
201 export_label_map[label_file.id] = label_file.label.name
202
203 # TODO masks if not part of TF records is not really handled great right now
204 # TODO pass export object to track it?
205
206 """
207
208 Would be good to allow masks for regular records / JSON

Callers 1

new_external_exportFunction · 0.85

Calls 13

generate_mask_coreMethod · 0.95
check_for_errorsFunction · 0.85
build_label_colour_mapFunction · 0.85
build_packetFunction · 0.85
declare_export_failedFunction · 0.85
file_listMethod · 0.80
serialize_readmeMethod · 0.80
try_to_commitFunction · 0.70
label_dict_builderMethod · 0.45

Tested by

no test coverage detected