2

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?

  • 1
    When "it fails on the first sdeconnection.Exists(FeatureClass)", what is the precise error message? Please edit your Question to include this. – PolyGeo Jun 3 '14 at 8:13
  • 1
    Would be also nice to take a look at the line of code which you have supplied in the pseudocode (arcpy.Exists(sdeconnection\\FeatureClass) ). There might be a problem with how the path you've constructed gets modified after publishing. Go to the "C:\arcgisserver\directories\arcgissystem\arcgisinput\GPservice.GPServer\extracted\v101" and check the .py file code. – Alex Tereshenkov Jun 3 '14 at 9:47
  • Indeed, this shows something changed while publishing. Seems something new to 10.2 because I've got exactly the same code in similar services that were published before and that were not changed – GeoSolve Jun 3 '14 at 10:13
  • This behaviour is expected and it was like this since 10.1. If I remember right, the arcpy.env.packageWorkspace expects that you will have the .sde file connection file in the "C:\arcgisserver\directories\arcgissystem\arcgisinput\GPservice.GPServer\extract‌​ed\v101" folder so the GP service could access it. After copying the .sde file here, I just use "g_ESRI_variable_# = os.path.join(arcpy.env.packageWorkspace,u'sdeconn.sde'). "arcpy.env.packageWorkspace" refers to the "C:\arcgisserver\directories\arcgissystem\arcgisinput\GPservice.GPServer\extract‌​ed\v101", this is a kind of home folder. – Alex Tereshenkov Jun 3 '14 at 11:43
  • Thanks. I had one gp service where the publishing was done succesfully, giving me variables like the g_ESRI_Variable. However, this doesn't work with the structure of my script. Strange that ESRI just changes your code... Had to edit the code in the v101 folder to its original state. – GeoSolve Jun 3 '14 at 14:27
1

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.

  • Thanks! The .RLT file also didn't work locally. Changing the line of code back to its original one in the the .py file in the v101 folder made it work. I also made a new GPservice just to test DB connection. First, I had exactly the same problem as before. But after 10 versions, ArcGIS suddenly copied the connection string and added the variables "g_ESRI_variable_1 = os.path.join(arcpy.env.packageWorkspace,u'Connection to v057gis.sde\\FeatureClass')" Because of the structure of the code, this didn't work, but it seems he already did more than in my main script. – GeoSolve Jun 3 '14 at 14:15
  • Between 10.0 and 10.1 the publishing process was changed. 10.1 onwards copies everything the service will need over to that directory. Without having your complete workflow or seeing the data, I can't say why exactly it isn't working. But the g_ESRI variable is what it is suppose to do and sounds correct based on what you posted, just as long as the .SDE connection file is actually there. – KHibma Jun 3 '14 at 15:27
  • Do you maybe have a reference where I can find more info on what ESRI actually does when my service is published? I can't find anything on their what's new in 10.1-site Thanks! – GeoSolve Jun 18 '14 at 6:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.