How to get the list of items of default zone using python?

Savan
Savan Dataiku DSS Core Concepts, Registered Posts: 5 ✭✭✭
image.png

This is my code and 'Data Pool' is my default zone and it has more hen 10 tables but it is not fetching the list of items for default zone. however it is working for other zones but not for this default zone.

Operating system used: Windows

Operating system used: Windows

Answers

  • Turribeach
    Turribeach Dataiku DSS Core Designer, Neuron, Dataiku DSS Adv Designer, Registered, Neuron 2023 Posts: 2,574 Neuron

    I can't copy/paste the code to test it since you uploaded as an image. Please use the code block (the </> icon) and upload your code as text. Thanks

  • Savan
    Savan Dataiku DSS Core Concepts, Registered Posts: 5 ✭✭✭
    import dataiku
    from dataiku import pandasutils as pdu
    import pandas as pd
     
    client = dataiku.api_client()
    project = client.get_default_project()
    variables = dataiku.get_custom_variables()
    flow = project.get_flow()
    connection_string = variables["sf_connection"]
    db_serv = variables["DB_SERV"]
    schema_s = variables["Tenant_ID"]
    schema_i = variables["schema_i"]
    schema_c = variables["schema_c"]
    fs_connection_string = 'filesystem_managed'
     
    flow_zone = {}
    for flow_list in flow.list_zones():
        if flow_list.name in ('Data Pool'):
            flow_zone[flow_list.name] = flow_list.id
            zone1 = flow.get_zone(flow_list.id)
        zone_datasets = []
        for items in zone1.items:
            item_dict = items.__dict__
            zone_datasets.append(item_dict['dataset_name'])
    
  • rustam213
    rustam213 Registered Posts: 1

    I'm facing with same problem. There is no way to access default zone items, but others. I believe this is problem it should be fixed by developers. Tried in many different projects, result is same. Also here more optimized code for showing items of zone.

    import dataiku

    client = dataiku.api_client()
    project = client.get_default_project()
    flow = project.get_flow()

    search_zone = flow.get_default_zone()

    print([i for i in search_zone.items])

    # also here parameters of zone to see items is really empty

    search_zone.get_settings().get_raw()

    How to mention developers to look this issue?

  • ThierryC
    ThierryC Dataiker, Registered Posts: 8 Dataiker

    The developers are looking at this to see if they can propose something.

    But as mentioned in the documentation:

    The “default” zone content is defined as all items that are not explicitly in another zone. It cannot directly be listed with the itemsproperty. To get the list of items including those in the default zone, use the get_graph() method.

    If I understand it properly, the OP's initial need was to list all the datasets of the "Data Pool" zone.

    First, you may consider creating a real zone and call it "Data Pool"

    But if you keep your default zone named "Data Pool", you can try the following code:


    import dataiku

    client = dataiku.api_client()
    project = client.get_default_project()
    flow = project.get_flow()

    all_datsets = project.list_datasets(as_type='objects')
    my_zone_datasets = [
    ds.name
    for ds in project.list_datasets(as_type='objects')
    if flow.get_zone_of_object(ds).name == "Data Pool"
    ]

    print(my_zone_datasets)

Setup Info
    Tags
      Help me…