Firing a GP Service/Python Script

3409
2
05-12-2014 03:03 AM
SimonJackson
Occasional Contributor III
I will have a GEP service that when a certain incident ocurrs, I will be updating a series of point values in a feature service.
After this update has happened, I want to then trigger a GP Service OR a python script to run that will do a basic IDW interpolation upon the updated point values (borehole water depths).

What is the best way of triggering for either an ArcGIS Server GP service to fire OR (and more ideally) for a local python script to execute?
0 Kudos
2 Replies
PatrickHill1
New Contributor
One option might be to create a custom processor that calls a geoevent service from it's rest endpoint. I did this with the visibility processor released as one of the geometry processors in the geoevent gallery.  I set up the processor to take in the parameters of the gp service.  I believe I also used some Runtime to generate gp objects and such.   You may also be able to execute the gp internally through Runtime as a local gp process.  I did not have luck with this, however and since I was able to get it to work by calling the service I went with that.  Also I believe I had to call the service synchronously because you start running into all kinds of threading considerations calling the service asynchronously from the already asynchronous processor.

I think you should be able to execute a python script from a processor/connector directly.  Again this would require customization.  There are libraries out there that interface between Java and Python - Jython comes to mind.  I have never used them and so I am not sure how practical this solution would be for your situation.

-Patrick
0 Kudos
RJSunderman
Esri Regular Contributor
Hey Simon -

Another approach recommended to me was to direct event data to a TCP socket which a Python script is monitoring. For example, if you had an out-of-the-box inbound connector polling a feature service for new features, the event data collected when new features were created could be sent to the Python script via an out-of-the-box TCP/Text outbound connector.

The python script monitoring the TCP socket has a toolbox opened and when event data is received on the socket the script executes a model in the toolbox providing the event data as input. Using this approach you wouldn't need to develop any custom GeoEvent Processor components; the Python script would asynchronously run its geoprocessing model not caring where the event data came from. The drawback, I suppose, is that you'd have no way of reporting or handling any errors since there is no way to have the Python process callback on GeoEvent Processor.

- RJ
0 Kudos