Shared datasets in Flow Zone

PoojaJogdand
Level 1
Shared datasets in Flow Zone

How to find shared dataset list from number of flow zone? the dataset present in default zone but used in other created zone.

0 Kudos
1 Reply
KeijiY
Dataiker

Hello @PoojaJogdand,

With the Dataiku Python API, you can use the DSSFlowZone.shared property to get a list of items which are shared to a zone.

Here is sample code to list datasets which are shared to a zone:

from collections import defaultdict
import dataiku
from dataikuapi.dss.dataset import DSSDataset


client = dataiku.api_client()
project = client.get_project(dataiku.default_project_key())
flow = project.get_flow()

shared_datasets = defaultdict(set)

for zone in flow.list_zones():
    for item in zone.shared:
        if type(item) is DSSDataset:
            shared_datasets[item.id].add(zone.name)
        
for shared_dataset in shared_datasets.items():
    print(shared_dataset)

Screen Shot 2021-10-29 at 12.08.56.pngScreen Shot 2021-10-29 at 12.09.10.png

I hope this would help.

Sincerely,
Keiji