c7c47bbaf9c48c1919d3f7b928614d9f1300b7d3,app/grandchallenge/cases/image_builders/tiff.py,,image_builder_tiff,#,372

Before Change


) -> 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


) -> ImageBuilderResult:
    new_images = set()
    new_image_files = set()
    consumed_files = set()
    invalid_file_errors = {}
    new_folders = set()

    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_images.add(image)
        new_image_files |= _new_image_files(gc_file=gc_file, image=image,)
        new_folders |= _new_folder_uploads(dzi_output=dzi_output, image=image,)

        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,
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 4

Instances


Project Name: comic/grand-challenge.org
Commit Name: c7c47bbaf9c48c1919d3f7b928614d9f1300b7d3
Time: 2020-06-27
Author: 12661555+jmsmkn@users.noreply.github.com
File Name: app/grandchallenge/cases/image_builders/tiff.py
Class Name:
Method Name: image_builder_tiff


Project Name: raghakot/keras-vis
Commit Name: 9f221345e7a58804e347f2a1879b06922222413b
Time: 2017-07-03
Author: ragha@outlook.com
File Name: docs/md_autogen.py
Class Name: MarkdownAPIGenerator
Method Name: module2md