Select to view content in your preferred language

Receiving error when using clone_items()

3531
5
Jump to solution
01-17-2018 08:34 AM
CourtneyClaessens
Frequent Contributor

Hi, 

I'm receiving the following error when attempting to clone items: 

Traceback (most recent call last):

  File "<ipython-input-92-d5f15aa1088b>", line 1, in <module>
    gis.content.clone_items(['4ef',  '5ef'])

  File "/Users/cour7816/anaconda3/lib/python3.6/site-packages/arcgis/gis/__init__.py", line 2483, in clone_items
    clone._get_item_definitions(item, item_definitions)

  File "/Users/cour7816/anaconda3/lib/python3.6/site-packages/arcgis/_impl/common/_clone.py", line 1556, in _get_item_definitions
    source = item._gis

AttributeError: 'str' object has no attribute '_gis'‍‍‍‍‍‍‍‍‍‍‍‍

This is my simple code:

from arcgis.gis import GIS 
from arcgis.gis import ContentManager as content

gis = GIS("https://www.arcgis.com", "", "")

gis.content.clone_items(['4ef', '5ef'])

(Where 4ef and 5ef are my full item ids)

Am I doing something wrong here? Thanks!

0 Kudos
1 Solution

Accepted Solutions
by Anonymous User
Not applicable

Hi Courtney,

The list of items you pass into gis.content.clone_items needs to be a list of Item objects, not a list of their item ids. 

Like this:

item = source_gis.content.get("703892c0e9774b0bbdd74e59ef7aef68")
target_gis.content.clone_items([item])

View solution in original post

5 Replies
by Anonymous User
Not applicable

Hi Courtney,

The list of items you pass into gis.content.clone_items needs to be a list of Item objects, not a list of their item ids. 

Like this:

item = source_gis.content.get("703892c0e9774b0bbdd74e59ef7aef68")
target_gis.content.clone_items([item])

CourtneyClaessens
Frequent Contributor

Perfect, thank you and thanks for your ultra-rapid response!

0 Kudos
FraserHand1
Esri Contributor

Hi,

Have you seen this before:

item = gis.content.get('0063eabbf6b94220a6c671b898c454b9')

gis2.content.clone_items([item])

RuntimeError                              Traceback (most recent call last)<ipython-input-15-000e99e9d2b6> in <module>()----> 1 gis2.content.clone_items([item])C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\gis\__init__.py in clone_items(self, items, folder, item_extent, use_org_basemap, copy_data, search_existing_items, item_mapping, group_mapping)   3119             wgs84_extent = clone._wgs84_envelope(service_extent)   3120         deep_cloner = clone._DeepCloner(self._gis, items, folder, wgs84_extent, service_extent, use_org_basemap, copy_data, search_existing_items, item_mapping, group_mapping)-> 3121         return deep_cloner.clone()   3122    3123     def _bulk_update(self, itemids, properties):C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\_impl\common\_clone.py in clone(self)    523             asyncio.set_event_loop(asyncio.new_event_loop())    524             loop = asyncio.get_event_loop()--> 525             results = loop.run_until_complete(self._clone(executor))    526             loop.close()    527             return results C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\asyncio\base_events.py in run_until_complete(self, future)    453         future.add_done_callback(_run_until_complete_cb)    454         try:--> 455             self.run_forever()    456         except:    457             if new_task and future.done() and not future.cancelled():C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\asyncio\base_events.py in run_forever(self)    407         self._check_closed()    408         if self.is_running():--> 409             raise RuntimeError('This event loop is already running')    410         if events._get_running_loop() is not None:    411             raise RuntimeError( RuntimeError: This event loop is already running

Thanks

Fraser

EDIT: actually looks like an issue with Notebook environment - works fine from an IDE such as Pycharm

See Can't invoke asyncio event_loop after tornado 5.0 update · Issue #3397 · jupyter/notebook · GitHub 

0 Kudos
SamLibby
Esri Contributor

I was able to work around this by forcibly installing an earlier version of tornado:

pip install tornado==4.5.3

AshleySeim
Occasional Contributor

Installing tornado 4.5.3 also resolved this for me.  I used conda.

For a Jupyter install via ArcGIS Pro 2.2 use conda to install tornado 4.5.3

In Command Prompt as Admin

Navigate to cd /d C:\Program Files\ArcGIS\Pro\bin\Python\Scripts

Type conda install tornado=4.5.3 -n arcgispro-py3