I am beginning to research the best way to take a suite of existing arcgis python tools and incorporating the python api so the tools can be enhanced to also work with feature services.
The tools are currently taking input fgdbs or egdbs, reading through them, some are editing features, many compare feature attributes to other 'rules' fgdbs... The tools are pretty complex, and I am trying to figure out which way to approach the task.
Ideally the existing tools would just be enhanced with the capabilities of the python api, but I suppose it could be the other way around that new tools are started with python api and they maybe then call the arcpy portions.
Thoughts, community?
I'm not quite following because you mention wanting to use the API for Python to work with feature services, but you explained only how your scripts use file geodatabases. What do you plan to do with feature services?
You could take a look at this thread about modularizing Python Toolboxes for inspiration. I do something similar with our Python scheduled tasks, they import a custom library with commonly used functions.
I have 50+ clients under the same umbrella, but they may all do things a bit different towards the same end with similar data and schema, some use fgdbs, some use SDE, some have migrated into feature services (apologies if my use of terminology isn't exact).
Ideally each tool that is currently written with arcpy can have the python api added to it to make it even more capable, but not sure that is possible. The existing tools may be 1000+ lines of code with some coming from separate modules.
The tools scan through the input which is usually an entire dataset of facility info organized in feature datasets. The input may also be compared to a separate input real property dataset, as well as another set of rules for specific data schema rules.
So like say a client's facility data is in a feature service, they want to run the tools against their feature service instead of a fgdb or sde, but they want all the same checks, comparisons, edits, outputs to occur that the arcpy tool is doing.
I am having trouble conceptualizing this, hence my question here.
So to put it another way, you want to have one tool that can accept inputs of a gdb feature class or feature service and perform the same logic?
yes! if possible.
Can you clarify how the feature services are hosted/accessed? (Standalone ArcGIS Server, hosted in Portal data store, uploaded to ArcGIS Online?)
I'd have to find out.
How will the different storage methods affect the code?
Some operations you can do on a feature class in a geodatabase might not be possible with a feature service. For example, you can't truncate/append, you would have to delete all rows, then insert all rows (for a traditional feature service hosted in standalone ArcGIS Server) and it would take considerably longer compared to a gdb fc. Also, you can't use something like arcpy.Editor or calculate field; although you can do more with GeoAnalytics tools if you have access to that.
So, it depends on a lot of different things. I would guess that "pretty complex" scripts have more than just some arcpy cursors making a few data edits. You'd have to find matching capabilities in the ArcGIS API for Python or the ArcGIS REST API directly.
Thank you for the explanation... helps me put my concerns into a better perspective.
Hi Blake, in your post you say that you cannot truncate/append a feature service hosted in standalone GIS Server. Is the same true if the server is federated with portal?
I have been able to truncate web layers in a hosted feature service but I am having a heck of a time appending data back into the feature service. I am missing something to "connect the dots" so to speak. Seems like this would work just fine, but I have had some mixed results when trying to do this. What is the best way to update a hosted feature service in Enterprise using Python API so that we dont overwrite all the pop up settings, etc that occurs when simply republishing the service?
Also seems if a feature service has multiple layers and layer(0) in the service is truncated, then Python API cant return the layer.item for any of the remining layers in the feature service.
Any help you can give would be greatly appreciated.