Overwrite not working, wrong number of records returned

644
12
02-05-2018 05:10 PM
Highlighted
Occasional Contributor

I'm using Python API's flc.manager.overwrite method to overwrite an existing HFS with new data from a feat class in a fgdb. Although the operation says "success" the records returned are the either the same as before or they are zero.

To test, I downloaded a hosted feature service (HFS) as a fgdb, deleted a few records in ArcMap and then specified the following for overwriting. 

flc = arcgis.features.FeatureLayerCollection.fromitem(item)
flc

lyr = flc.layers[0]
lyr.query(return_count_only=True)

Output:39

flc.manager.overwrite(r"C:\data\Data\Projects\jupyter\WDFW_JupyterNotebooks_Master\Data\test.gdb\test_county")

Output:{'success': True}

lyr = flc.layers[0]
lyr.query(return_count_only=True)

Output:39 #this should be 34 since I removed some counties from the local feature class

A second test with adding new features in ArcMap and then running method gave the "success:true" message

but results returned was zero records.

Any ideas what I'm doing wrong?

Reply
0 Kudos
12 Replies
Highlighted
Occasional Contributor

Hey Treg

Let me run some testing on this function. I'll get back to you on what I find.

John

Reply
0 Kudos
Highlighted
Occasional Contributor

Hi John,

Any luck troubleshooting this issue?

Treg

Reply
0 Kudos
Highlighted
Occasional Contributor

Hey Treg  - I'm seeing the same problem you documented in certain cases. Can you try running the `overwrite` function with a zipped up gdb as the input rather than the gdb feature class? Let me know what results you get.

Reply
0 Kudos
Highlighted
Occasional Contributor

I’m still getting the same number of records after zipping

Also, I tried to diff pathways (below…1.include zip and gdb 2 include just zip) and they both gave “success” message and both returned the original # records instead of 5 less counties from the local version.

lyr = flc.layers[0]

lyr.query(return_count_only=True)

39

#the records in local'test_county_incomplete'=34

flc.manager.overwrite(r"C:\data\Data\Projects\jupyter\WDFW_JupyterNotebooks_Master\Data\test_county.gdb.zip\test_county.gdb\test_county_incomplete")

#flc.manager.overwrite(r"C:\data\Data\Projects\jupyter\WDFW_JupyterNotebooks_Master\Data\test_county.gdb.zip\test_county_incomplete")

{'success': True}

lyr = flc.layers[0]

lyr.query(return_count_only=True)

39

Reply
0 Kudos
Highlighted
Occasional Contributor

Hey treg‌ -

I'm seeing similiar behavior to what you've documented with the FeatureLayerCollection.manager. We've logged this issue internally and are investigating the featurelayercollection.manager.overwrite() method.  Will the item.publish(overwrite=True) work in your scenario?

Highlighted
Occasional Contributor

Thanks for looking into this further John. Your suggested workaround “item.publish(overwrite=True)” might work fine. I won’t have time to test anytime soon though. One of our eventual needs is to have some version of overwrite working so we can we can make major schema changes on existing Hosted Feature Services that are used by a survey123 form (but was published initially from a feature class…not created in S123). I’ll post a response to GeoNet when I have some time to investigate your workaround.

Thanks,

Treg

Reply
0 Kudos
Highlighted
New Contributor III

I'm having the same issue. The overwrite method essentially restores the Feature Service to its state when initially published, or last overwritten via desktop tools. I can delete all the features from a feature layer (from Pro, or from a Web Map), run the overwrite method, and my feature layer is back to the way it was prior to the deletes.

John, are you able to provide a basic sample using the publish method? I'm have some trouble with the publish_parameters.

Reply
0 Kudos
Highlighted
New Contributor II

I am having the same issue as Treg.  Has the esri team investigated the issues with the featurelayercollection.manager.overwrite() method?

Reply
0 Kudos
Highlighted
Occasional Contributor

This still wasn't working about a month ago but there must have been a recent update because I can confirm that this is working now (Py API 1.4.1):

##delete all features via truncate
tblTaxo.manager.truncate()

Pre-overwriteFeature count: 0

from arcgis.features import FeatureLayerCollection
tblTaxo_flayer_collection = FeatureLayerCollection.fromitem(items)

#call the overwrite() method which can be accessed using the manager property
tblTaxo_flayer_collection.manager.overwrite(tblTaxoGeolib)

Post-Overwrite Feature count: 2431



Reply
0 Kudos