girder / large_image

Python modules to work with large multiresolution images.
http://girder.github.io/large_image/
Apache License 2.0
190 stars 41 forks source link

Create new large images for each item in a folder #1572

Closed gabrielle6249 closed 1 month ago

gabrielle6249 commented 1 month ago

This adds an endpoint that creates large images for an entire folder, as mentioned here. It iterates through the folder's items, skips over items with a large image already and creates a large image for the items without one. It has several options, one that recurses child folders, a second that creates a job for each large image item, and another that makes the jobs local.

This does not yet retry creating large images for items with an unfinished large image, but seemed to be a good start.

manthey commented 1 month ago

I'd like to add a basic test of this. Something like

@pytest.mark.usefixtures('unbindLargeImage')
@pytest.mark.plugin('large_image')
def testFolderCreateImages(server, admin, user, fsAssetstore):
    file = utilities.uploadExternalFile('sample_image.ptif', admin, fsAssetstore)
    itemId = file['itemId']
    item = Item().load(itemId, user=admin)
    folderId = str(item['folderId'])
    # Remove the large image from this item
    ImageItem().delete(item)
    # Ask to make all items in this folder large images
    resp = server.request(
        method='PUT', path=f'/large_image/folder/{folderId}/tiles', user=admin)
    assert utilities.respStatus(resp) == 200
    assert resp.json['largeImagesCreated'] == 1
    item = Item().load(itemId, user=admin)
    # Check that this item became a large image again
    assert 'largeImage' in item

could be added to the girder/test_girder/test_large_image.py file.

A better test set would also create a subfolder and put a file there to test recursion, and would test running the process a second time doesn't create any large images since they already exist and are fine.