Select to view content in your preferred language

Updating hosted Feature Layer utilizing Python

283
1
07-19-2023 09:27 AM
Labels (2)
JackieFisher
New Contributor III

I've got a Python program that has been running continuously for the past 16-18 months that updates a Hosted Feature Layer within our AGOL account.

The final "write" portion of the code is

data_hold_csv = 'C:\\USGS Live\\HCT - CU\\Clients\\D4_5_Current_Rsvr_Data.csv'#Working file for filter loop
src=data_hold_csv
dst = data_omid
#dst1 = D4_D5_Crrnt_working
copyfile(src, dst)
#copyfile(src, dst1)
gis = GIS("https://www.arcgis.com", "user", "password")
print("We're in ...")
search_results = gis.content.search('title: D4-5_Current_Rsvr_Data', 'Feature Layer')
print("Found what we need ... ")
usgs_fs_item = search_results[0]
usgs_fs_item
print("Past the item ... ")
USGS_flayer_collection = FeatureLayerCollection.fromitem(usgs_fs_item)
print("Getting ready to overwrite ... ")
USGS_flayer_collection.manager.overwrite(data_hold)
print("1.5 - Feature Layer D4-5_Current_Rsvr_Data has been updated for ",client)
print("")

As of 7/14, I began getting the following error:

Selected site raw data has been extracted for rwpc
We're in ...
Found what we need ...
Past the item ...
Getting ready to overwrite ...
Traceback (most recent call last):
File "C:\USGS Live\HCT - CU\Live_USGS_220020.py", line 497, in <module>
USGS_flayer_collection.manager.overwrite(data_hold_csv)
File "C:\Users\Owner\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\features\managers.py", line 1169, in overwrite
published_item = related_data_item.publish(publish_parameters, overwrite=True)
File "C:\Users\Owner\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\gis\__init__.py", line 6852, in publish
serviceitem_id = self._check_publish_status(ret, folder)
File "C:\Users\Owner\AppData\Local\Programs\Python\Python37-32\lib\site-packages\arcgis\gis\__init__.py", line 7089, in _check_publish_status
raise Exception("Job failed.")
Exception: Job failed.

What has changed, and how do I work around it?  Thanks!

Tags (2)
0 Kudos
1 Reply
David_McRitchie
Esri Contributor

If the script has not changed then it could be the data that is causing issue. I would check that the schema to your CSV input is still the same and that the Hosted Feature Layer still exists and can be viewed/edited.

 

Hope that helps!

David

Esri UK -Technical Support Analyst
0 Kudos