Accessing files in a subfolder of a managed folder that is pointing to S3.

raghutej
raghutej Registered Posts: 10

Hi,

I am trying to access image files in a sub-folder of the managed folder that is mapped to S3.
Could you guide me how to do that?
My current code works if image is directly under managed folder but not if it is under subfolder.
For testing if i map subfolder directly to managed folder, i can access images.

Thanks,

Raghu

Tagged:

Best Answer

  • JordanB
    JordanB Dataiker, Dataiku DSS Core Designer, Dataiku DSS Adv Designer, Registered Posts: 297 Dataiker
    edited July 17 Answer ✓

    Hi,

    This should work to access the images directly:

    import dataiku
    images_folder = dataiku.Folder('folder')
    
    from PIL import Image
    plt.figure(figsize=(20,100))
    
    files = images_folder.list_paths_in_partition()
    for file in files:
        with images_folder.get_download_stream(path=file) as stream:
            img = Image.open(stream)
            plt.imshow(img)
            plt.show()
    

    Thanks!

    Jordan

Setup Info
    Tags
      Help me…