Select to view content in your preferred language

Building a knowledge graph using python API

978
4
Jump to solution
07-17-2023 03:25 PM
Labels (1)
DariusBost
New Contributor

I am currently attempting to link to and fill in a knowledge graph (KG) using the python API. I initially was trying to follow the instructions from this demo "Building Web Applications and Notebooks with ArcGIS Knowledge" https://mediaspace.esri.com/media/t/1_6f3u6m9c . 

 

I'm using api version '2.1.0.3' and connecting to a KG hosted on ArcGIS Enterprise. 

------

import sys
from arcgis.gis import GIS
from arcgis.graph import KnowledgeGraph

gis = GIS("https://arcgis.edc.renci.org/portal",'#######',verify_cert=False)
kg = KnowledgeGraph("https://arcgis.edc.renci.org/server/rest/services/Hosted/GFloat/KnowledgeGraphServer",gis = gis)

-------

This works fine but when I try to see if the KG is empty

-------

for types in kg.datamodel['entity_types']:
print(types)
for types in kg.datamodel['relationship_types']:
print(types)

--------

and ready for inputs (expect Document and HasDocument to be returned) I only get this error.
AttributeError: 'NoneType' object has no attribute 'to_value_object'

Am I doing something wrong or is the dev summit video already obsolete?

1 Solution

Accepted Solutions
MeganBanaski1
Esri Contributor

The documentation for arcgis.graph is here: https://developers.arcgis.com/python/api-reference/arcgis.graph.html

2.1.0 and beyond are only compatible with ArcGIS Enterprise 11.1 and beyond and editing is only available in the python api 2.1.0.3 and beyond, so you will not be able to edit a knowledge graph in enterprise 11.0.

View solution in original post

4 Replies
MeganBanaski1
Esri Contributor

Thanks for your question @DariusBost, which version of ArcGIS Enterprise are you using? There were breaking changes in 11.1, so the python API at 2.1.0.3 will only work with ArcGIS Enterprise 11.1+. This blog post has more information: https://community.esri.com/t5/arcgis-knowledge-blog/notice-breaking-changes-in-arcgis-knowledge-q1/b...

dariusmb
New Contributor

Thank you so much for your feedback. I apologize for not responding sooner, there were some licensing issues that just got resolved to allow me even to access enterprise to check versions. We have version 11.0 and the python API that is loaded with Pro is 2.0.1. Is there any documentation with examples for that version of the api? Specifically around building and manipulating knowledge graphs?

0 Kudos
dariusmb
New Contributor

I had attempted to match the API version shown (via a new conda environment) in the dev summit not knowing it was on a newer version of the of enterprise. 

0 Kudos
MeganBanaski1
Esri Contributor

The documentation for arcgis.graph is here: https://developers.arcgis.com/python/api-reference/arcgis.graph.html

2.1.0 and beyond are only compatible with ArcGIS Enterprise 11.1 and beyond and editing is only available in the python api 2.1.0.3 and beyond, so you will not be able to edit a knowledge graph in enterprise 11.0.