Survey banner
The Dataiku Community is moving to a new home! We are temporary in read only mode: LEARN MORE

FInding flow zones by tag name?

Solved!
info-rchitect
Level 6
FInding flow zones by tag name?

Hi,

Would like to be able to find flow zones by tag name using the Python DSS, such that users can select matching flow zones for execution using their own parameterized variables.  Is this possible?

thx


Operating system used: Windows 10

0 Kudos
1 Solution
Turribeach

This should give you enough to find out what you want:

import dataiku
client = dataiku.api_client()
project = client.get_project('some_project_key')
flow = project.get_flow()
zones = flow.list_zones()
for zone in zones:
    zone_handle = flow.get_zone(zone.id)
    print("Zone id=%s Zone name=%s" % (zone.id, zone.name))
    zone_tags = zone.get_settings().get_raw()['tags']
    for zone_tag in zone_tags:
        print(zone_tag)

 

View solution in original post

3 Replies
Turribeach

This should give you enough to find out what you want:

import dataiku
client = dataiku.api_client()
project = client.get_project('some_project_key')
flow = project.get_flow()
zones = flow.list_zones()
for zone in zones:
    zone_handle = flow.get_zone(zone.id)
    print("Zone id=%s Zone name=%s" % (zone.id, zone.name))
    zone_tags = zone.get_settings().get_raw()['tags']
    for zone_tag in zone_tags:
        print(zone_tag)

 

PS: If you are going to be doing these searches over your whole projects it will highly advisable to create a cache table with all the projects/zones/tags and refresh it every hour or whatever you consider approapiate so you can perform quick tag=>zone lookups. 

info-rchitect
Level 6
Author

@Turribeach  I did have to add a `try-except` enhancement due to some flow zones not being accessible to me:

for p in projects :
    project_key = p["projectKey"]
    project = client.get_project(project_key)
    flow = project.get_flow()
    zones = []
    try:
        zones = flow.list_zones()
    except Exception as e:
        print(e)
        continue

Labels

?
Labels (2)

Setup info

?
A banner prompting to get Dataiku