Friday, 10 January 2020

arcgis desktop - Connecting Geoprocessing Service to ArcSDE?



Recently we updated from ArcMap 10.1 to 10.2.2. ArcGIS Server is still on 10.1. We have numerous GP and Mapservices that were published on ArcMap 10.1 and are still running without problems. I also published a Map service from ArcMap 10.2, with data in an Enterprise GDB that is registered, without any problems. Now I have a python script that uses data from the same DB and works perfectly in ArcMap 10.2. I can publish it but when I run it, it returns false on the first


arcpy.Exists(sdeconnection\\FeatureClass).

According to this link I should however be able to publish form 10.2.2 to 10.1 without too many problems.


Any ideas on what could be wrong? I guess it should be the data connection. But my Map service uses the same SDE, so my data should still be accessible.


In the original file, my workspace was defined as follows:


arcpy.env.workspace = "\\\\v057GIS\\Data\\Connection to v057gis.sde"

After publishing, this line changed suddenly to:


arcpy.env.workspace = arcpy.env.packageWorkspace


I can open the "C:\arcgisserver\directories\arcgissystem\arcgisinput\GPservice.GPServer\extract‌​ed\v101" file in python IDE, change the line and run it correctly. I'm however not able to save it. I read Modifying script published as Geoprocessing Service in ArcGIS for Server? about how to do it, but am a bit afraid of doing it since we only have production server.


Is there a workaround for that? Maybe directly in packageWorkspace?



Answer



As pointed out by Alex in a comment,



arcpy.env.packageWorkspace



is an expected update in your script if you look at where the GP Service is deployed. The packageWorkspace is the directory itself. When publishing a service that uses SDE data, and you've referenced the SDE database in your datastore, a copy of the connection file (.sde) gets moved into the directory and your script is updated to reference that. This is expected and how its supposed to work.


You're right about "generally" speaking per your link different versions will work together:




According to this link I should however be able to publish form 10.2.2 to 10.1 without too many problems.



I do want to point out times though this wont be true. There have been a few tools which have been enhanced between 10.1 and 10.2.2. These tools can only be publish when each product is at the same version. (this is just a general note, this point wont be your issue).


There have also been some bugs fixed between the versions, mostly related to script update and data paths. Again, generally speaking most should work, but there could be cases that they dont. I dont have enough information about your workflow to say that updating Server to 10.2.2 will solve the problem (so I'm not suggesting that).


Your best test is with ArcMap, to navigate down into the v101 folder and find the .RLT (result) file. Drag that into your map. Open the Results window and under the "shared" node, run that. Thats basically like running the service, but running it locally, not via ArcGIS Server. If that works, its Server having problems connecting to SDE. If it doesn't work, its not resolving the path to your SDE connection file and I'd sort of expect the version differences perhaps messing something up. The easy "test" to prove that would be to hack the script in that directory to point to the connection file explicitly.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...