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

Solved!
raghutej
Level 2
Accessing files in a subfolder of a managed folder that is pointing to S3.

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

0 Kudos
1 Solution
JordanB
Dataiker

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

 

View solution in original post

1 Reply
JordanB
Dataiker

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