) -> ImageBuilderResult:
new_images = []
new_image_files = []
consumed_files = []
invalid_file_errors = {}
new_folder_upload = []
def format_error(message):
return f"Tiff image builder: {message}"
loaded_files, errors = _load_gc_files(files=files, converter=pyvips)
for gc_file in loaded_files:
dzi_output = None
error = ""
if gc_file.path in errors:
error = errors[gc_file.path]
// try and load image with tiff file
try:
gc_file = _load_with_tiff(gc_file=gc_file)
except Exception as e:
error += f"Load error: {e}. "
// try and load image with open_slide
try:
dzi_output, gc_file = _load_and_create_dzi(gc_file=gc_file)
except Exception as e:
error += f"Dzi error: {e}. "
// validate
try:
gc_file.validate()
except ValidationError as e:
error += f"Validation error: {e}. "
invalid_file_errors[gc_file.path] = format_error(error)
continue
image = _create_tiff_image_entry(tiff_file=gc_file)
new_image_files = _add_image_files(
gc_file=gc_file, image=image, new_image_files=new_image_files,
)
new_folder_upload = _add_folder_uploads(
dzi_output=dzi_output,
image=image,
new_folder_upload=new_folder_upload,
)
new_images.append(image)
consumed_files.append(gc_file.path)
if gc_file.associated_files:
consumed_files += list(f for f in gc_file.associated_files)
return ImageBuilderResult(
After Change
if gc_file.associated_files:
consumed_files |= {f for f in gc_file.associated_files}
else:
consumed_files.add(gc_file.path)
return ImageBuilderResult(
consumed_files=consumed_files,
file_errors=invalid_file_errors,