1

I have encountered something kind of odd and I'm not sure what's causing it. I have published a geoprocessing service and it's duplicating the SDE connection file during publishing. The code is very simple, all it's doing is checking that a database connection can be made and then unzipping the uploaded file. The service works, but I'd like to understand why it's duplicating the SDE connection file.

The python code:

import arcpy, zipfile

db_con = r'Database Connections\HbMonitoringTest_nbcidb_HabitatTestWriter.sde'
arcpy.AddMessage(db_con)
if arcpy.Exists(db_con):
  arcpy.AddMessage("your db connection worked")
else:
  arcpy.AddMessage("your db connection sucks")
try:
  myZipFile = arcpy.GetParameterAsText(0)
  arcpy.AddMessage(myZipFile)
  scratch = arcpy.env.scratchFolder
  arcpy.AddMessage(scratch)
  zip_ref = zipfile.ZipFile(myZipFile, 'r')
  zip_ref.extractall(scratch)
  zip_ref.close()
  arcpy.AddMessage("success")
except:
  arcpy.AddMessage("fail")

When I publish this as a geoprocessing service it does this in the /extracted/v101 directory:

enter image description here

Other info: When I use the service via javascript API, it uses the duplicate database connection (HbMonitoringTest_nbcidb_HabitatTestWriter1.sde). When I run the service in Desktop, it uses the catalog connection which is to be expected (this is the connection without the 1 on the end). This database is registered with the server under the same name (HbMonitoringTest_nbcidb_HabitatTestWriter). The server and publishing machine are two different machines. Server settings do not allow data to be copied to the server. ArcGIS Server 10.4.1, ArcGIS Desktop 10.6.

  • If you look at the .PY file that gets put down on the server, do you see a reference to both the 1 and no-number .sde file? – KHibma Mar 27 '18 at 19:52
  • You need to be careful with both relative and absolute paths in geoprocessing services, since the distributed architecture and running the service as a different user can wreak havoc with such things. – Vince Mar 28 '18 at 0:06
  • @KHibma - It only references the HbMonitoringTest sde file with the 1 appended to the end. Part of me thinks this could just be ArcGIS being finicky since I'm publishing from Desktop 10.6 to Server 10.4.1 – MKF Mar 28 '18 at 11:43
  • @Vince - could you expand a little more? The script tool has relative paths checked on, should I uncheck it? I have also seen other posts that say to build the connection to the SDE file in the script instead of using "Database Connections" but I'm not sure how to do that since the path on my local machine would be different than the path on the remote server, so it would run in one place and not the other. – MKF Mar 28 '18 at 11:45
  • I had to write some exotic services that required megabytes of ancillary information which needed to by dynamically configured, so I used conf files and web services to feed information into the app. This eliminated specific paths from the app entirely (and made it platform independent, since my Server was Linux). – Vince Mar 28 '18 at 11:56
1

I'm mostly certain this was at bug. You noted this was happening at 10.4.1 -- I recall around the 10.4.x - 10.5.x versions, development work was done on Geoprocessing Services in regards to how .SDE connections were made and handled during the publishing process.

I don't have a bug number to back this up, only my vague memory of these "issues" as I was directly involved with this area of the software at Esri. I'm mostly certain at 10.5.1 and higher, these "sde connection file issues" should be solved.

That said, this was work done both inside ArcMap (publishing software) and ArcGIS Server. Thus, in this particular case its critical the two versions of the software match.

  • Has not been resolved as of 10.6. Both Server and Desktop match now. I have republished (overwritten) one of my GP services and both SDE files remain. Unless it doesn't clear the folder entirely when re-writing the service, then it is still publishing two SDE files. – MKF Feb 11 at 17:58
  • I highly doubt it'd clear the directory contents on an overwrite. If you check time stamps you should see if a file has been overwritten or not. I suspect the 2nd SDE file will have the older time stamp. – KHibma Feb 11 at 18:32
  • Well, I just completely blew my service away and tried republishing it and now it won't publish because it claims my data sources are broken. "Script HabitatManagement contains broken project data source: C:\Users\mfoley10\AppData\Local\ESRI\Desktop10.6\Staging\arcgis on xxx_6080 (publisher)\0\v101\HabitatManagement_nbcidb_HabitatWriter1.sde" It's still looking for the data source with the '1' on the end. – MKF Feb 14 at 14:35
  • Alright, I went into Staging and deleted a HabitatManagement.sddraft file that maybe was screwing it up. I got it to publish succesfully. But, the extra SDE connection is still there (I had deleted the entire service and folder prior to republishing). They do have different dates though which I don't get as I blew the folder away... – MKF Feb 14 at 14:46

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.