Feature Layer clone_items issue with multiScaleGeometry?

191
3
3 weeks ago
anotgrass_007
New Contributor

I've been tasked with cloning some items from one AGO to another AGO, and running into an issue, seemingly from features that have multiScaleGeometryInfo: True

I'm getting the IDs from the source AGO, passing them to the clone_items function

cloned_list = target_gis.content.clone_items(items=[source_item],folder="New Folder",search_existing_items=True)

After a lot of debugging, it seems that Feature Layers with no multiScaleGeometry will clone fine, but if they do have it, I get an error.

Has anyone encountered this, or this error before?

('Failed to create Feature Service FEAUTRE_LAYER: list index out of range', <Item title:"FEAUTRE_LAYER" type:Feature Layer Collection owner:newowner>)

I had help tracing this error down to the _clone.py script, line 2753 "layers[layer_id].container.manager.layers[layer_id].update_definition. 

With the debugger running, the layer_id showed 156 when hovering over it (which was the correct layer ID from the service) but in the variables window, it showed that 0.  So it seems like that is the issue?

Capture.JPGfullerror.JPGNot entirely sure how to go about fixing that.

0 Kudos
3 Replies
EarlMedina
Esri Regular Contributor

As you noted, the problem seems to be with the line "layers[layer_id].container.manager.layers[layer_id].update_definition"

 

Are there actually 150+ layers in the feature layer collection? the error seems to imply layers is a list and the index value (in this case 156) is out of range

0 Kudos
anotgrass_007
New Contributor

There is just one layer in the service.  I believe the layer was published individually from a Pro project which is why the ID is 156 rather than 0

0 Kudos
EarlMedina
Esri Regular Contributor

Okay, so the problem seems to be the logic used to get layer - it doesn't account for the case you mentioned where the id could be higher than the length of the list. I believe this is a valid bug you can log in the repo: Issues · Esri/arcgis-python-api · GitHub

To fix this, you might just be able to adjust the for loop to use enumerate.

So, in the source it would change to:

for index, layer_id in enumerate(layer_ids):

And then you would replace the point where it fails with layers[index]

You might need to do that in a few places.

0 Kudos