get datasets list in a flowzone using api

Solved!
pritam003
Level 2
get datasets list in a flowzone using api

Hi Team

 

Is there way to get the datasets name in a flow zone using API

for item in zone.items:
print(item)

this prints the zone items but not there name 

 

Thanks 

pritam

1 Solution
AlexT
Dataiker

Hi,

That's because the datasets are returned as objects. If you use something like print("Zone item: %s" % item.__dict__) it will also print the dataset_name:

import dataiku
import dataikuapi
import pandas as pd, numpy as np

client = dataiku.api_client()
project_key = 'REPLACE_PROJECT_KEY'
project = client.get_project(project_key)

# List zones

flow = project.get_flow()


for zone in flow.list_zones():
    print("Zone id=%s name=%s" % (zone.id, zone.name))

    print("Zone has the following items:")
    for item in zone.items:
        print("Zone item: %s" % item.__dict__)

 

Screenshot 2021-10-26 at 11.52.51.png

 

Let me know if that works for you.

View solution in original post

2 Replies
AlexT
Dataiker

Hi,

That's because the datasets are returned as objects. If you use something like print("Zone item: %s" % item.__dict__) it will also print the dataset_name:

import dataiku
import dataikuapi
import pandas as pd, numpy as np

client = dataiku.api_client()
project_key = 'REPLACE_PROJECT_KEY'
project = client.get_project(project_key)

# List zones

flow = project.get_flow()


for zone in flow.list_zones():
    print("Zone id=%s name=%s" % (zone.id, zone.name))

    print("Zone has the following items:")
    for item in zone.items:
        print("Zone item: %s" % item.__dict__)

 

Screenshot 2021-10-26 at 11.52.51.png

 

Let me know if that works for you.

AkshayArora1
Level 2

Can I get all the datasets in a list?

 

0 Kudos