get datasets list in a flowzone using api

pritam003
pritam003 Registered Posts: 8 ✭✭✭✭

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

Best Answer

  • Alexandru
    Alexandru Dataiker, Dataiku DSS Core Designer, Dataiku DSS ML Practitioner, Dataiku DSS Adv Designer, Registered Posts: 1,227 Dataiker
    edited July 17 Answer ✓

    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.

Answers

Setup Info
    Tags
      Help me…