Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clone_items() fails with timeout error #2190

Open
DanaAbuMourh-MAG opened this issue Jan 14, 2025 · 1 comment
Open

clone_items() fails with timeout error #2190

DanaAbuMourh-MAG opened this issue Jan 14, 2025 · 1 comment
Labels

Comments

@DanaAbuMourh-MAG
Copy link

DanaAbuMourh-MAG commented Jan 14, 2025

Describe the bug
I have an ArcGIS Online Hosted Feature Layer, its size is 255 MB, it has attachments with size: 12.53 GB. It's failing to clone (clone_items) due to time out after about 15-20 minutes.

Smaller Feature Layers clone without issues.

Is there a limit to the size of the items we can clone? If there is, is there a way to work around this?

To Reproduce
Steps to reproduce the behavior:

from arcgis.gis import GIS

gis = GIS("https://arcgis.com", "username", "password", expiration=9999)
layer = gis.content.get("featureserviceid")
gis.content.clone_items([layer], "Test Folder")

error:

Your request has timed out. : (Error Code: 504)', <Item title:"item_title" type:Feature Layer Collection owner:username>)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\_impl\common\_clone.py", line 4270, in clone
    raise _ItemCreateException(
arcgis._impl.common._clone._ItemCreateException: ('Failed to create Feature Service service_name: Your request has timed out. (Error Code: 504)', <Item title:"item_title" type:Feature Layer Collection owner:username>)

Platform:

  • OS: Windows 11
  • Browser Edge
  • Python API Version 2.4.0
@adoezema
Copy link

adoezema commented Apr 2, 2025

I am having the same/similar issue cloning an Experience Builder App.

from arcgis.gis import GIS
target = GIS("home")

source = GIS(_sourceURL, _username, _password)

exb_item = source.content.get(to_clone_itemid)

target.content.clone_items(items=[exb_item], search_existing_items=False, copy_data=False, folder='WSL Public Site')

Error:

---------------------------------------------------------------------------
Exception                                 Traceback (most recent call last)
File /opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_clone.py:4050, in _FeatureServiceDefinition.clone(self)
   4047             spatial_reference = feature_service.properties[
   4048                 "spatialReference"
   4049             ]
-> 4050         self._add_features(
   4051             new_layers,
   4052             relationships,
   4053             layer_field_mapping,
   4054             spatial_reference,
   4055             keep_edits=self._track_edits,
   4056         )
   4058 del item_properties["url"]

File /opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_clone.py:2889, in _FeatureServiceDefinition._add_features(self, layers, relationships, layer_field_mapping, spatial_reference, keep_edits)
   2888 if is_generalized:
-> 2889     layers[layer_id].container.manager.layers[layer_id].update_definition(
   2890         {"multiScaleGeometryInfo": {"levels": []}}
   2891     )
   2892     layers[layer_id]._refresh()

File /opt/conda/lib/python3.11/site-packages/arcgis/features/managers.py:3749, in FeatureLayerManager.update_definition(self, json_dict, future)
   3747 u_url = self._url + "/updateDefinition"
-> 3749 res = self._con.post(u_url, params)
   3750 if future and "statusURL" in res:

File /opt/conda/lib/python3.11/site-packages/arcgis/gis/_impl/_con/_connection.py:1504, in Connection.post(self, path, params, files, **kwargs)
   1503     return resp
-> 1504 return self._handle_response(
   1505     resp=resp,
   1506     out_path=out_path,
   1507     file_name=file_name,
   1508     try_json=try_json,
   1509     force_bytes=kwargs.pop("force_bytes", False),
   1510 )

File /opt/conda/lib/python3.11/site-packages/arcgis/gis/_impl/_con/_connection.py:979, in Connection._handle_response(self, resp, file_name, out_path, try_json, force_bytes, ignore_error_key)
    978     errorcode = data["error"]["code"] if "code" in data["error"] else 0
--> 979     self._handle_json_error(data["error"], errorcode)
    980 return data

File /opt/conda/lib/python3.11/site-packages/arcgis/gis/_impl/_con/_connection.py:1002, in Connection._handle_json_error(self, error, errorcode)
   1001 errormessage = errormessage + "\n(Error Code: " + str(errorcode) + ")"
-> 1002 raise Exception(errormessage)

Exception: Your request has timed out.
(Error Code: 504)

During handling of the above exception, another exception occurred:

_ItemCreateException                      Traceback (most recent call last)
Cell In[4], line 1
----> 1 target.content.clone_items(items=[exb_item], search_existing_items=False, copy_data=False, folder='WSL Public Site')

File /opt/conda/lib/python3.11/site-packages/arcgis/gis/__init__.py:8757, 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, export_service, preserve_editing_info, **kwargs)
   8736     preserve_item_id = False
   8738 deep_cloner = clone._DeepCloner(
   8739     self._gis,
   8740     items,
   (...)
   8755     wab_code_attach=kwargs.pop("copy_code_attachment", True),
   8756 )
-> 8757 return deep_cloner.clone()

File /opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_clone.py:1347, in _DeepCloner.clone(self)
   1343 # elif len([node for node in self._graph.values() if isinstance(node, _StoryMapDefinition)]) > 0:
   1344 #    return self._clone_synchronous()
   1345 else:
   1346     with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
-> 1347         results = executor.submit(self._clone, executor).result()
   1348         return results

File /opt/conda/lib/python3.11/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 /opt/conda/lib/python3.11/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 /opt/conda/lib/python3.11/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 /opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_clone.py:1321, in _DeepCloner._clone(self, excecutor)
   1319                     item.protected = False
   1320                 item.delete()
-> 1321         raise ex
   1323 level += 1
   1324 leaf_nodes = self._get_leaf_nodes()

File /opt/conda/lib/python3.11/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 /opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_itemdef/_expbuilder.py:181, in _WebExperience.clone(self)
    179     new_item.resources.add(self.resources, archive=True)
    180 config_dict = self.portal_item.resources.get("config/config.json")
--> 181 new_dict = _clone_dict(
    182     config_dict,
    183     self.portal_item._gis,
    184     self.target,
    185     self._search_existing,
    186 )
    187 with tempfile.NamedTemporaryFile(
    188     mode="w+", suffix=".json", delete=False
    189 ) as tfile:
    190     json.dump(new_dict, tfile)

File /opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_itemdef/_expbuilder.py:145, in _WebExperience.clone.<locals>._clone_dict(data_dict, source, target, search_ex)
    142             continue
    144 # if not, try cloning item
--> 145 clone_result = target.content.clone_items(
    146     [item],
    147     search_existing_items=search_ex,
    148     folder=self.folder,
    149     owner=self.owner,
    150     item_extent=self.item_extent,
    151     preserve_item_id=self._preserve_item_id,
    152 )
    153 if clone_result:
    154     for cloned in clone_result:

File /opt/conda/lib/python3.11/site-packages/arcgis/gis/__init__.py:8757, 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, export_service, preserve_editing_info, **kwargs)
   8736     preserve_item_id = False
   8738 deep_cloner = clone._DeepCloner(
   8739     self._gis,
   8740     items,
   (...)
   8755     wab_code_attach=kwargs.pop("copy_code_attachment", True),
   8756 )
-> 8757 return deep_cloner.clone()

File /opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_clone.py:1347, in _DeepCloner.clone(self)
   1343 # elif len([node for node in self._graph.values() if isinstance(node, _StoryMapDefinition)]) > 0:
   1344 #    return self._clone_synchronous()
   1345 else:
   1346     with concurrent.futures.ThreadPoolExecutor(max_workers=20) as executor:
-> 1347         results = executor.submit(self._clone, executor).result()
   1348         return results

File /opt/conda/lib/python3.11/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 /opt/conda/lib/python3.11/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 /opt/conda/lib/python3.11/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 /opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_clone.py:1321, in _DeepCloner._clone(self, excecutor)
   1319                     item.protected = False
   1320                 item.delete()
-> 1321         raise ex
   1323 level += 1
   1324 leaf_nodes = self._get_leaf_nodes()

File /opt/conda/lib/python3.11/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 /opt/conda/lib/python3.11/site-packages/arcgis/_impl/common/_clone.py:4270, in _FeatureServiceDefinition.clone(self)
   4268     return new_item
   4269 except Exception as ex:
-> 4270     raise _ItemCreateException(
   4271         "Failed to create {0} {1}: {2}".format(
   4272             original_item["type"], original_item["title"], str(ex)
   4273         ),
   4274         new_item,
   4275     )

_ItemCreateException: ('Failed to create Feature Service Parcel_Limited: Your request has timed out.\n(Error Code: 504)', <Item title:"Parcel_Limited" type:Feature Layer Collection owner:_username>)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants