Esri / Esri/arcgis-python-api

Issues with Cloning Map Web App from one Organization to another Organization using clone_items() method

Offen
#1,706 1 Kommentar 0 Reaktionen 1 zugewiesene Person Beansprucht von @nparavicini7 Auf GitHub ansehen
bug
Vorherrschende Sprache
Python
Sterne
2.2k
Forks
1.1k
Ø Merge
2 Std. 40 Min.
Gemergte PRs (30 T.)
2

Beschreibung

**Describe the bug**
Trying to use clone-items() method to clone Map Web App from Organization SOURCE to Organization TARGET in ArcGIS Online.
The app is in the SOURCE folder along with 5 other apps. There are 7 Maps and about 60 feature layers in the same folder.
The script runs for 10 minutes before backing out. I can see several Feature Layers in the TARGET Folder before the clone method deletes them in the back out process.

**To Reproduce**
Steps to reproduce the behavior:
```python
from arcgis.gis import GIS

# Log into Source ESRI Portal
sourceURL = "https://SOURCE.maps.arcgis.com/home/" # WriteSource ESRI Portal URL here
sourceUsername = "SourceAdmin" # Write admin username here, the script will promp for the password
sourceGis = GIS(sourceURL, sourceUsername)
print("Successfully logged in as: " + sourceGis.properties.user.username)
sourceGis

# Log into Target ESRI Portal
targetURL = "https://TARGET.maps.arcgis.com/home/" # WriteSource ESRI Portal URL here
targetUsername = "TargetAdmin" # Write admin username here, the script will promp for the password
targetGis = GIS(targetURL, targetUsername)
print("Successfully logged in as: " + targetGis.properties.user.username)
targetGis

# Cloning
webMapItem = sourceGis.content.get("c0ac61f6147c4ce2a83610a31ac31cc0")
clonedItems = targetGis.content.clone_items(items= [webMapItem], folder= 'TARGET from SOURCE', search_existing_items=True)
```
error:
```python
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
File ~\anaconda3\Lib\site-packages\arcgis\_impl\common\_clone.py:3925, in _FeatureServiceDefinition.clone(self)
3922 spatial_reference = feature_service.properties[
3923 "spatialReference"
3924 ]
-> 3925 self._add_features(
3926 new_layers,
3927 relationships,
3928 layer_field_mapping,
3929 spatial_reference,
3930 )
3932 # once copy data has taken place, do WF necessary data migration

File ~\anaconda3\Lib\site-packages\arcgis\_impl\common\_clone.py:2753, in _FeatureServiceDefinition._add_features(self, layers, relationships, layer_field_mapping, spatial_reference)
2752 is_generalized = True
-> 2753 layers[layer_id].container.manager.layers[layer_id].update_definition(
2754 {
2755 "multiScaleGeometryInfo": {"levels": []}
2756 } # {"multiScaleGeometryInfo": None}
2757 )
2758 layers[layer_id]._refresh()

IndexError: list index out of range

During handling of the above exception, another exception occurred:

_ItemCreateException Traceback (most recent call last)
Cell In[12], line 9
3 display(webMapItem)
5 #webMapItem
6
7 #clonedItems = targetGis.content.clone_items?
----> 9 clonedItems = targetGis.content.clone_items(items= [webMapItem], folder= 'TARGET from SOURCE', owner='TargetAdmin', search_existing_items=True)

File ~\anaconda3\Lib\site-packages\arcgis\gis\__init__.py:8562, in ContentManager.clone_items(self, items, folder, item_extent, use_org_basemap, copy_data, copy_global_ids, search_existing_items, item_mapping, group_mapping, owner, preserve_item_id, **kwargs)
8543 preserve_item_id = False
8545 deep_cloner = clone._DeepCloner(
8546 self._gis,
8547 items,
(...)
8560 wab_code_attach=kwargs.pop("copy_code_attachment", True),
8561 )
-> 8562 return deep_cloner.clone()

File ~\anaconda3\Lib\site-packages\arcgis\_impl\common\_clone.py:1322, in _DeepCloner.clone(self)
1318 # elif len([node for node in self._graph.values() if isinstance(node, _StoryMapDefinition)]) > 0:
1319 # return self._clone_synchronous()
1320 else:
1321 with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
-> 1322 results = executor.submit(self._clone, executor).result()
1323 return results

File ~\anaconda3\Lib\concurrent\futures\_base.py:456, in Future.result(self, timeout)
454 raise CancelledError()
455 elif self._state == FINISHED:
--> 456 return self.__get_result()
457 else:
458 raise TimeoutError()

File ~\anaconda3\Lib\concurrent\futures\_base.py:401, in Future.__get_result(self)
399 if self._exception:
400 try:
--> 401 raise self._exception
402 finally:
403 # Break a reference cycle with the exception in self._exception
404 self = None

File ~\anaconda3\Lib\concurrent\futures\thread.py:58, in _WorkItem.run(self)
55 return
57 try:
---> 58 result = self.fn(*self.args, **self.kwargs)
59 except BaseException as exc:
60 self.future.set_exception(exc)

File ~\anaconda3\Lib\site-packages\arcgis\_impl\common\_clone.py:1296, in _DeepCloner._clone(self, excecutor)
1294 if item:
1295 item.delete()
-> 1296 raise ex
1298 level += 1
1299 leaf_nodes = self._get_leaf_nodes()

File ~\anaconda3\Lib\concurrent\futures\thread.py:58, in _WorkItem.run(self)
55 return
57 try:
---> 58 result = self.fn(*self.args, **self.kwargs)
59 except BaseException as exc:
60 self.future.set_exception(exc)

File ~\anaconda3\Lib\site-packages\arcgis\_impl\common\_clone.py:3996, in _FeatureServiceDefinition.clone(self)
3994 return new_item
3995 except Exception as ex:
-> 3996 raise _ItemCreateException(
3997 "Failed to create {0} {1}: {2}".format(
3998 original_item["type"], original_item["title"], str(ex)
3999 ),
4000 new_item,
4001 )

_ItemCreateException: ('Failed to create Feature Service BMID_System: list index out of range', )
```
**Screenshots**
If applicable, add screenshots to help explain your problem.

**Expected behavior**
I expect clone_items() to copy the Map Web App, the associated Map, and associated Feature Layers from the SOURCE Organization to the TARGET Organization.
I plan to execute the same script for each one of the 6 Apps (they share Feature Layers)

**Platform (please complete the following information):**
- OS: Windows 10 Home
- Browser Firefox using Anaconda Navigator / JupyterLab
- Python API Version 2.2.0.1 using Python 3.11. (Tried with Python 3.7 and API version 1.8.4 with similar results).

**Additional context**
Add any other context about the problem here, attachments etc.

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.