I recently had to change a script to point to a different directory to find my SDE connections. When I try to republish the service so the paths are updated on the server, it says that my script contains a broken project data source and then lists the old path, even though the script no longer contains any references to the old path. How do I fix this? This is not the only GP service I've changed the path for; all the other ones I've changed have been able to overwrite the old services without error.
Current code with new path:
#Get MonitoringPoint, Patches, and PC layers from database.
fa_db_con = r'C:\Users\mfoley10\AppData\Roaming\ESRI\Desktop10.7\ArcCatalog\FocalAreas_HabitatWriter.sde'
hbw_db_con = r'C:\Users\mfoley10\AppData\Roaming\ESRI\Desktop10.7\ArcCatalog\HabitatMonitoring_HabitatWriter.sde'
mpFC = fa_db_con + '\FocalAreas.dbo.MonitoringPoint'
patchesFC = hbw_db_con + '\HabitatMonitoring.DBO.Patches'
pcFC = hbw_db_con + '\HabitatMonitoring.DBO.ProtectiveCover'
Errors I get when analyzing the service for overwriting:
00068 Script PrintHabitatMap contains broken project data source: C:\Users\mfoley10\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\HabitatMonitoring_nbcidb_HabitatWriter.sde
00068 Script PrintHabitatMap contains broken project data source: C:\Users\mfoley10\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\FocalAreas_nbcidb_HabitatWriter.sde
00178 Data: C:\Users\mfoley10\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\HabitatMonitoring_nbcidb_HabitatWriter.sde, used by Script PrintHabitatMap cannot be copied to the server
00178 Data: C:\Users\mfoley10\AppData\Roaming\ESRI\Desktop10.6\ArcCatalog\FocalAreas_nbcidb_HabitatWriter.sde, used by Script PrintHabitatMap cannot be copied to the server
The folder "...Desktop10.6\ArcCatalog\..." doesn't even exist on my computer. Regardless, I ran this code anyway to see if it would do anything (it didn't):
#(I typed out the full old path)
arcpy.env.workspace = 'C:\Users...\HabitatMonitoring_nbcidb_HabitatWriter.sde'
Next, I validated all my connections:
I have tried to see if changing the names of the connections listed in the Data Store to match that of the new paths in the script makes it publishable, but no luck (e.g. FocalAreas_nbcidb_HabitatWriter gets changed to the new name which is FocalAreas_HabitatWriter).
I have made sure no draft services exist in the "Staging" folder that are caching that path.
I have even deleted the PrintHabitatMap geoprocessing service altogether to see if I could just publish a fresh one and it still won't let me.
The PrintHabitatMap geoprocessing service takes some MXDs out of a registered folder and alters them according to user input. I have since checked the option in the MXDs for storing relative paths on and I have reset the data sources for all the data in the MXDs to be sure they are pointing to the right locations. I then copied those MXDs into the appropriate folder on the server machine (the registered folder is in a different location on each machine, hence the copying).
I cannot find ANYWHERE with that old path in it. I don't get where that old path is being stored or how the server keeps finding it.