Skip to content

Commit 617469e

Browse files
authored
Merge pull request #2020 from Esri/jy-rvw-gis-guides1
Remove output warnings and update group sharing
2 parents 8b89cbe + 50cfbc8 commit 617469e

File tree

2 files changed

+45
-46
lines changed

2 files changed

+45
-46
lines changed

guide/03-the-gis/accessing-and-creating-content.ipynb

Lines changed: 33 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
},
2929
{
3030
"cell_type": "code",
31-
"execution_count": null,
31+
"execution_count": 2,
3232
"metadata": {},
3333
"outputs": [],
3434
"source": [
@@ -51,9 +51,9 @@
5151
"cell_type": "markdown",
5252
"metadata": {},
5353
"source": [
54-
"As mentioned in the [`gis module`](https://developers.arcgis.com/python/guide/the-gis-module/) guide, the Python API uses [Resource Manager classes](https://developers.arcgis.com/python/guide/the-gis-module/) to manage Web GIS users, groups, datastores, and content. You access the [`UserManager`](https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.UserManager), [`GroupManager`](https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#groupmanager) and [`ContentManager`](https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#arcgis.gis.ContentManager) classes as the `users`, `groups`, and `content` properties of the [`GIS`](https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#gis), respectively. (See [`Helper objects`](https://developers.arcgis.com/python/api-reference/arcgis.gis.toc.html#gis) for details.)\n",
54+
"As mentioned in the [`gis module`](/python/guide/the-gis-module/) guide, the Python API uses [Resource Manager classes](/python/guide/the-gis-module/) to manage Web GIS users, groups, datastores, and content. You access the [`UserManager`](/python/api-reference/arcgis.gis.toc.html#arcgis.gis.UserManager), [`GroupManager`](/python/api-reference/arcgis.gis.toc.html#groupmanager) and [`ContentManager`](/python/api-reference/arcgis.gis.toc.html#arcgis.gis.ContentManager) classes as the `users`, `groups`, and `content` properties of the [`GIS`](/python/api-reference/arcgis.gis.toc.html#gis), respectively.\n",
5555
"\n",
56-
"Each resource manager implements the [ArcGIS REST API](https://developers.arcgis.com/rest/users-groups-and-items/search.htm) `search` operation as a method. For example, `gis.content.search()`. It's important to understand that the `search` mechanism uses many different inputs to find possible matches, ranks them and returns appropriate results. The `search` becomes ideal for human interaction, but `fuzzy` when looking for specific records programmatically. The search results are non-deterministic. Using `search` may not necessarily be the best approach for finding specific items, but more a group of items from which to further filter. \n",
56+
"Each searchj resource manager, for example _gis.content.search(), implements the [ArcGIS REST API](/rest/users-groups-and-items/search.htm) `search` operation. It's important to understand that the `search` mechanism uses many different inputs to find possible matches, ranks them and returns appropriate results. The `search` becomes ideal for human interaction, but `fuzzy` when looking for specific records programmatically. The search results are non-deterministic. Using `search` may not necessarily be the best approach for finding specific items, but more a group of items from which to further filter. \n",
5757
"\n",
5858
"It's also important to know that using `search` programmatically, like with the Python API, does not correspond identically to searching with an application written in a different language. The various `search` options in the ArcGIS Online or Portal for ArcGIS Enterprise interfaces work differently than the Python API resource managers' `search`. Different applications may use different inputs. The relationship between a content `search` in one application, like a Portal or ArcGIS Online viewer, is not one-to-one with a content search using the Python API even when logged in as the same user.\n",
5959
"\n",
@@ -62,7 +62,7 @@
6262
},
6363
{
6464
"cell_type": "code",
65-
"execution_count": 2,
65+
"execution_count": 3,
6666
"metadata": {},
6767
"outputs": [],
6868
"source": [
@@ -190,12 +190,12 @@
190190
},
191191
{
192192
"cell_type": "code",
193-
"execution_count": 4,
193+
"execution_count": 37,
194194
"metadata": {},
195195
"outputs": [],
196196
"source": [
197-
"day_start = dt.datetime(2019, 5, 30, 0, 0, 0, 0)\n",
198-
"day_end = dt.datetime(2019, 5, 30, 23, 59, 59, 999999)\n",
197+
"day_start = dt.datetime(2023, 9, 21, 0, 0, 0, 0)\n",
198+
"day_end = dt.datetime(2023, 9, 21, 23, 59, 59, 999999)\n",
199199
"\n",
200200
"start_timestamp = int(day_start.timestamp() * 1000)\n",
201201
"end_timestamp = int(day_end.timestamp() * 1000)"
@@ -210,16 +210,17 @@
210210
},
211211
{
212212
"cell_type": "code",
213-
"execution_count": 5,
213+
"execution_count": 40,
214214
"metadata": {},
215215
"outputs": [],
216216
"source": [
217-
"content_published_53019 = [item\n",
218-
" for item in gis.content.search(query=\"* AND \\\n",
219-
" owner:\" + gis.users.me.username,\n",
220-
" max_items=50)\n",
221-
" if item.created > start_timestamp \n",
222-
" and item.created < end_timestamp]"
217+
"content_published_92123 = [\n",
218+
" item\n",
219+
" for item in gis.content.search(\n",
220+
" query=f\"owner:{gis.users.me.username}\",\n",
221+
" max_items=100) \n",
222+
" if item.created > start_timestamp\n",
223+
" and item.created < end_timestamp]"
223224
]
224225
},
225226
{
@@ -231,7 +232,7 @@
231232
},
232233
{
233234
"cell_type": "code",
234-
"execution_count": 6,
235+
"execution_count": 41,
235236
"metadata": {},
236237
"outputs": [],
237238
"source": [
@@ -241,14 +242,16 @@
241242
},
242243
{
243244
"cell_type": "code",
244-
"execution_count": 7,
245+
"execution_count": 45,
245246
"metadata": {},
246247
"outputs": [
247248
{
248249
"name": "stdout",
249250
"output_type": "stream",
250251
"text": [
251-
"Item Title Item Type Published \n"
252+
"Item Title Item Type Published \n",
253+
"425e9ee3dd774bbe8d472b73e9cadbd2 File Geodatabase September 21 2023 at 10:45.47 AM \n",
254+
"ad37530ecc3744e8b3a9db52adde6408 File Geodatabase September 21 2023 at 10:43.44 AM \n"
252255
]
253256
}
254257
],
@@ -258,8 +261,8 @@
258261
"publish = \"Published\"\n",
259262
"print(f\"{title:40}{item_type:25}{publish:40}\")\n",
260263
"\n",
261-
"for content in content_published_53019:\n",
262-
" print(f\" {content.title:<40} {content.type:25} {readable_date(content.created):40}\")"
264+
"for content in content_published_92123:\n",
265+
" print(f\"{content.title:<40}{content.type:25}{readable_date(content.created):40}\")"
263266
]
264267
},
265268
{
@@ -1480,8 +1483,11 @@
14801483
"thumbnail_path = os.path.join(data_path, \"earthquake.png\")\n",
14811484
"\n",
14821485
"root_folder = gis.content.folders.get()\n",
1483-
"earthquake_csv_item = root_folder.add(item_properties=csv_properties, data=csv_path,\n",
1484-
" thumbnail = thumbnail_path).result()"
1486+
"earthquake_csv_item = root_folder.add(\n",
1487+
" item_properties=csv_properties, \n",
1488+
" data=csv_path,\n",
1489+
" thumbnail = thumbnail_path\n",
1490+
").result()"
14851491
]
14861492
},
14871493
{
@@ -1605,7 +1611,10 @@
16051611
{
16061612
"cell_type": "markdown",
16071613
"metadata": {
1608-
"collapsed": true
1614+
"collapsed": true,
1615+
"jupyter": {
1616+
"outputs_hidden": true
1617+
}
16091618
},
16101619
"source": [
16111620
"<a id=\"importing-data-from-a-pandas-data-frame\"></a>\n",
@@ -2454,14 +2463,6 @@
24542463
"execution_count": 38,
24552464
"metadata": {},
24562465
"outputs": [
2457-
{
2458-
"name": "stderr",
2459-
"output_type": "stream",
2460-
"text": [
2461-
"C:\\Users\\tar12555\\AppData\\Local\\ESRI\\conda\\envs\\pyapi-dev\\lib\\site-packages\\IPython\\core\\interactiveshell.py:3553: DeprecatedWarning: create_folder is deprecated as of 2.3.0 and has be removed in 3.0.0. Use `gis.content.folders.create` instead.\n",
2462-
" exec(code_obj, self.user_global_ns, self.user_ns)\n"
2463-
]
2464-
},
24652466
{
24662467
"data": {
24672468
"text/plain": [
@@ -2540,14 +2541,6 @@
25402541
"execution_count": 41,
25412542
"metadata": {},
25422543
"outputs": [
2543-
{
2544-
"name": "stderr",
2545-
"output_type": "stream",
2546-
"text": [
2547-
"C:\\Users\\tar12555\\AppData\\Local\\ESRI\\conda\\envs\\pyapi-dev\\lib\\site-packages\\IPython\\core\\interactiveshell.py:3553: DeprecatedWarning: delete_folder is deprecated as of 2.3.0 and has be removed in 3.0.0. Use `Folder.delete()` instead.\n",
2548-
" exec(code_obj, self.user_global_ns, self.user_ns)\n"
2549-
]
2550-
},
25512544
{
25522545
"data": {
25532546
"text/plain": [
@@ -2589,7 +2582,7 @@
25892582
"name": "python",
25902583
"nbconvert_exporter": "python",
25912584
"pygments_lexer": "ipython3",
2592-
"version": "3.9.16"
2585+
"version": "3.11.0"
25932586
},
25942587
"toc": {
25952588
"base_numbering": 1,
@@ -2635,5 +2628,5 @@
26352628
}
26362629
},
26372630
"nbformat": 4,
2638-
"nbformat_minor": 1
2631+
"nbformat_minor": 4
26392632
}

guide/03-the-gis/accessing-and-managing-groups.ipynb

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,10 @@
7171
{
7272
"cell_type": "markdown",
7373
"metadata": {
74-
"collapsed": true
74+
"collapsed": true,
75+
"jupyter": {
76+
"outputs_hidden": true
77+
}
7578
},
7679
"source": [
7780
"The `search()` method returns a list of objects of type `arcgis.gis.Group`. When using the Jupyter notebook environment, `Group` objects can be represented in rich HTML with their thumbnail and metadata information."
@@ -433,7 +436,10 @@
433436
" 'tags':['geocaching', 'searching', 'hikes', 'POI'],\n",
434437
" 'snippet':'Points containing treasures for geocaching activity'}\n",
435438
"root_folder = gis.content.folders.get()\n",
436-
"fc_item = root_folder.add(item_properties, data='../../samples/05_content_publishers/data/hidden_treasures_geocaching.csv').result()"
439+
"fc_item = root_folder.add(\n",
440+
" item_properties, \n",
441+
" data='../../samples/05_content_publishers/data/hidden_treasures_geocaching.csv'\n",
442+
").result()"
437443
]
438444
},
439445
{
@@ -471,7 +477,7 @@
471477
{
472478
"data": {
473479
"text/plain": [
474-
"{'notSharedWith': [], 'itemId': '538a4c39061043828f5d7a4d2a09c30b'}"
480+
"True"
475481
]
476482
},
477483
"execution_count": 162,
@@ -481,7 +487,7 @@
481487
],
482488
"source": [
483489
"# let us share it to the group so other enthusiasts can enjoy this map\n",
484-
"fc_item.share(groups=[geocaching_group])"
490+
"fc_item.sharing.groups.add(group=geocaching_group)"
485491
]
486492
},
487493
{
@@ -941,7 +947,7 @@
941947
"name": "python",
942948
"nbconvert_exporter": "python",
943949
"pygments_lexer": "ipython3",
944-
"version": "3.9.16"
950+
"version": "3.11.0"
945951
},
946952
"toc": {
947953
"base_numbering": 1,
@@ -958,5 +964,5 @@
958964
}
959965
},
960966
"nbformat": 4,
961-
"nbformat_minor": 1
967+
"nbformat_minor": 4
962968
}

0 commit comments

Comments
 (0)