<GD.CN> team we noticed that the <GD.CN> UI when c...
# gooddata-cn
p
GD.CN team we noticed that the GD.CN UI when creating an insight and dragging attributes, is able to show a message showing the number of unrelated data items (see screenshot below), is there a similar API in the python-sdk that we can leverage that we can use to get the attributes related to a specific attribute ? cc: @Kshirod Mohanty @James Lee @rohit
j
It is possible to do this with Python SDK. I implemented (and open sourced) an example here: https://gitlab.com/patrikbraborec/gooddata-data-pipeline/-/blob/main/apps/streamlit/gooddata/catalog.py?ref_type=heads#L249 This is the core method you have to call to get only objects valid for a specific context = specific report definition = what objects you can add to a specific context. You can review the whole Streamlit application and how I utilize the result of this call in the broader context.
p
Thanks @Jan Soubusta we will take a look at the example and come back with any questions we might have
c
hi @Jan Soubusta, what would be the JS SDK equivalent for this?
j
@Andy @Dan Homola could you help, please?
I've messed with this a bit, and it seems like it's correct for this use case. Quick question though, what's the correct way to add filters to this request?
Copy code
await catalog
  .availableItems()
  .forItems([item] as IAttribute[])
  .load();
d
Hi @Cayce Collins, you are correct, this is the proper API for doing this:
Copy code
// load the full catalog once
const catalog = await backend.workspace(WORKSPACE).catalog().load()
// use it to load different subsets based on different measures and/or attributes
const availableItemsCatalog = await catalog.availableItems().forItems([attr1, measure1]).load()
there is no way of adding the filters, because they should not influence the availability of the catalog objects, only attributes and facts do. Why do you want to include the filters? 🙂
c
thanks @Dan Homola! For the filters, we have a scenario which we our users may have multiple dates and we are trying to determine which filters will work together to produce a valid result. I also noticed when making the above SDK request, an empty
filters: []
is passed in the request so I was curious. I think we are going to attempt a different approach, where we lookup the correct dates to use per attribute/measure/metric, and use a default date as a fallback (which the tenant can choose). Thanks for the assistance!
d
No problem 🙂 good catch with the filters being sent! I looked at the backend code and it seems to be ignored in the actual computation, but we will have another look possibly optimizing this in a future GoodData.UI release 🙂
👍 1