I’m using the arcgis Python API to build, populate, and edit a knowledge graph. I want to be able to check for the existence of a graph prior to making one. My current approach involves a try/except where I build the graph create statement and try to make one. If there’s an exception raised then I just build the url and connect.
while this works, I wonder if there’s a more elegant solution to check for the name of that graph? Would this involve searching for all Portal graph items and then looking in that list? I suppose that would get fairly lengthy and could be expensive in itself.
thanks for any advice.
Solved! Go to Solution.
You can use gis.content.search which you can provide a query (the name of the graph you are looking for) as well as the item_type of 'Knowledge Graph'. This should return the single item if it exists. You can find more information on the parameters for search here: https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html
You can use gis.content.search which you can provide a query (the name of the graph you are looking for) as well as the item_type of 'Knowledge Graph'. This should return the single item if it exists. You can find more information on the parameters for search here: https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html