Skip to content

Commit 751a7a6

Browse files
authored
Merge pull request #1657 from mbana641/meg10359/knowledge_guide_update
add create_service instructions for knowledge graph guide
2 parents 4ef7037 + 062dd04 commit 751a7a6

File tree

1 file changed

+79
-14
lines changed

1 file changed

+79
-14
lines changed

guide/17-working-with-knowledge-graphs/part1_introduction_to_knowledge_graphs.ipynb

Lines changed: 79 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
{
22
"cells": [
33
{
4-
"attachments": {},
54
"cell_type": "markdown",
65
"metadata": {},
76
"source": [
87
"# Introduction to Knowledge Graphs"
98
]
109
},
1110
{
12-
"attachments": {},
1311
"cell_type": "markdown",
1412
"metadata": {},
1513
"source": [
@@ -23,14 +21,14 @@
2321
" </ul>\n",
2422
" </li>\n",
2523
" <li><span><a href=\"#Connect\" data-toc-modified-id=\"Connect-2\">Connect</a></span></li>\n",
26-
" <li><span><a href=\"#Data-Model\" data-toc-modified-id=\"Data-Model-3\">Data Model</a></span></li>\n",
27-
" <li><span><a href=\"#Path-Forward\" data-toc-modified-id=\"Path-Forward-4\">Path Forward</a></span></li>\n",
24+
" <li><span><a href=\"#Create\" data-toc-modified-id=\"Create-3\">Create</a></span></li>\n",
25+
" <li><span><a href=\"#Data-Model\" data-toc-modified-id=\"Data-Model-4\">Data Model</a></span></li>\n",
26+
" <li><span><a href=\"#Path-Forward\" data-toc-modified-id=\"Path-Forward-5\">Path Forward</a></span></li>\n",
2827
" </ul>\n",
2928
"</div>"
3029
]
3130
},
3231
{
33-
"attachments": {},
3432
"cell_type": "markdown",
3533
"metadata": {},
3634
"source": [
@@ -42,7 +40,6 @@
4240
]
4341
},
4442
{
45-
"attachments": {},
4643
"cell_type": "markdown",
4744
"metadata": {},
4845
"source": [
@@ -59,7 +56,6 @@
5956
]
6057
},
6158
{
62-
"attachments": {},
6359
"cell_type": "markdown",
6460
"metadata": {},
6561
"source": [
@@ -83,15 +79,79 @@
8379
]
8480
},
8581
{
86-
"attachments": {},
8782
"cell_type": "markdown",
8883
"metadata": {},
8984
"source": [
9085
"A knowledge graph service is composed of two primary resources, the data and data model. The data contains entities and relationships with their associated properties. "
9186
]
9287
},
9388
{
94-
"attachments": {},
89+
"cell_type": "markdown",
90+
"metadata": {},
91+
"source": [
92+
"## Create\n",
93+
"Using the ArcGIS API for Python, you can create a new Knowledge Graph using [create_service()](https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.ContentManager.create_service)."
94+
]
95+
},
96+
{
97+
"cell_type": "code",
98+
"execution_count": null,
99+
"metadata": {},
100+
"outputs": [],
101+
"source": [
102+
"gis = GIS(\"home\")\n",
103+
"result = gis.content.create_service(\n",
104+
" name=\"myKnowledgeGraph\",\n",
105+
" capabilities=\"Query,Editing,Create,Update,Delete\",\n",
106+
" service_type=\"KnowledgeGraph\",\n",
107+
")"
108+
]
109+
},
110+
{
111+
"cell_type": "markdown",
112+
"metadata": {},
113+
"source": [
114+
"Services can also be created using create parameters to choose more service options."
115+
]
116+
},
117+
{
118+
"cell_type": "code",
119+
"execution_count": null,
120+
"metadata": {},
121+
"outputs": [],
122+
"source": [
123+
"result = gis.content.create_service(\n",
124+
" name=\"\",\n",
125+
" service_type=\"KnowledgeGraph\",\n",
126+
" create_params={\n",
127+
" \"name\": \"myKnowledgeGraph\",\n",
128+
" \"capabilities\": \"Query\",\n",
129+
" \"jsonProperties\": {\n",
130+
" \"supportsProvenance\": False,\n",
131+
" \"arcgisManagedData\": False,\n",
132+
" \"dataSourceItemID\": \"f63a6725058c4c05a63480521acffe01\",\n",
133+
" },\n",
134+
" },\n",
135+
")"
136+
]
137+
},
138+
{
139+
"cell_type": "markdown",
140+
"metadata": {},
141+
"source": [
142+
"Finally, the result from create_service can be used to initialize the KnowledgeGraph."
143+
]
144+
},
145+
{
146+
"cell_type": "code",
147+
"execution_count": null,
148+
"metadata": {},
149+
"outputs": [],
150+
"source": [
151+
"knowledge_graph = KnowledgeGraph(url=result.url, gis=gis)"
152+
]
153+
},
154+
{
95155
"cell_type": "markdown",
96156
"metadata": {},
97157
"source": [
@@ -110,7 +170,6 @@
110170
]
111171
},
112172
{
113-
"attachments": {},
114173
"cell_type": "markdown",
115174
"metadata": {},
116175
"source": [
@@ -248,7 +307,6 @@
248307
]
249308
},
250309
{
251-
"attachments": {},
252310
"cell_type": "markdown",
253311
"metadata": {},
254312
"source": [
@@ -260,15 +318,22 @@
260318
],
261319
"metadata": {
262320
"kernelspec": {
263-
"display_name": "Python 3",
321+
"display_name": "Python 3 (ipykernel)",
264322
"language": "python",
265323
"name": "python3"
266324
},
267325
"language_info": {
326+
"codemirror_mode": {
327+
"name": "ipython",
328+
"version": 3
329+
},
330+
"file_extension": ".py",
331+
"mimetype": "text/x-python",
268332
"name": "python",
269-
"version": "3.9.13"
333+
"nbconvert_exporter": "python",
334+
"pygments_lexer": "ipython3",
335+
"version": "3.9.16"
270336
},
271-
"orig_nbformat": 4,
272337
"vscode": {
273338
"interpreter": {
274339
"hash": "d622b5871f1605057390dea3c8b45e995d0d19bef8604acd7f5b2e1066a85139"

0 commit comments

Comments
 (0)