I'm trying to publish a python script as a geoprocessing service using Arcmap and Server 10.4.1.
The script essentially exports a pdf and returns the url of the output to the user.
My issue is that, when trying to publish the GP tool, the analysis and publishing takes an extremely long time.
I did some tests, I created a script that had basically nothing in it but importing arcpy and adding an arcpy.AddMessage line. This published quite quickly. I added in other lines, such as importing other modules, to test, and the slowness seems to kick in when I introduce a reference to a database connection, like so:
fc1= r"Database Connections\MYSDEFILE.sde\MYDATABASE.DBO.FC1"
fc2= r"Database Connections\MYSDEFILE.sde\MYDATABASE.DBO.FC2"
As soon as I do this, the analysis takes approx. an extra 1-2 minutes for each feature class. With 15-20 feature classes/layers used within the script, publishing the script takes easily half an hour.
This makes any troubleshooting extremely difficult and time-consuming.
Can anyone shed any light on what might be going on here and any suggestions on speeding it up?
I'm wondering if something is corrupted or wrong, as the other thing that I'm finding is that the SDE file that gets copied and packaged up for the GP service doesn't seem to work, but if I manually replace it (once the service has finished publishing) with a copy from the database connections folder then the GP service works.
Any suggestions welcome, thanks.