I have a geoprocessing service that fails because the server adds two strings to the data variables

433
3
04-03-2023 01:57 PM
WilsonIonara
New Contributor III

I have a geoprocessing service that breaks because the server adds two strings to the data variables. The code snippet is: 

 

dir_path = r'e:\ArcGISData\ForestEcosystemValuesData'
arcpy.AddMessage(dir_path)
# root = r'E:\ArcGISData\ForestEcosystemValuesData\ForestValuesApp.gdb'
workspace = os.path.join(dir_path, 'ForestValuesApp.gdb')
arcpy.env.workspace = workspace
arcpy.env.overwriteOutput = True
CS = 30
CONV = 0.000247105381
ZONEFIELD = 'SAID'
AOITotalAreaAcres = 0
root = arcpy.env.workspace
urban = os.path.join(root, 'AOIUrbanVector')
rasterList = ['uBiodiversity', 'uClimate',  'uCultural', 'uEconomic',  'uHumanHealth', 'uWatershed',  'rBiodiversity', 'rClimate', 'rCultural', 'rWatershed']
tempPolygon = r'in_memory\temp1'
memo = "in_memory"

 

And when I open the script on the server folder I have this, it adds a string (a') to one of the variables and another string (db') to the other variable: 

g_ESRI_variable_1 = 'E:\\ArcGISData\\ForestEcosystemValuesData'a'
g_ESRI_variable_2 = 'E:\\ArcGISData\\ForestEcosystemValuesData/ForestValuesApp.gdb'db'
g_ESRI_variable_3 = 'in_memory\\temp1'
g_ESRI_variable_4 = 'SAID'
g_ESRI_variable_6 = 'in_memory/'
g_ESRI_variable_7 = 'in_memory\\urbanaoipoly3'
g_ESRI_variable_8 = 'UrbanID'

WilsonIonara_0-1680555075399.png

And this is the error returned on the app: 

File "E:\arcgisserver\directories\arcgissystem\arcgisinput\ForestEcosystemValues\EcoNewGP.GPServer\extracted\p20\forestecosystemvaluesdata\LATEST_CHANGEURBANNOPARAMS CLEAN NO PARAMS3.py", line 5
g_ESRI_variable_1 = 'E:\\ArcGISData\\ForestEcosystemValuesData'a'
^
SyntaxError: invalid syntax

WilsonIonara_1-1680555206187.png

My coworkers are able to publish the geoprocessing service with no errors. What is going with my publishing? Thanks

 

0 Kudos
3 Replies
ShaunWalbridge
Esri Regular Contributor

This sounds like a known logged bug, BUG-000147516, which unfortunately doesn't help you immediately. It may be easiest to fix the replaced strings on the server, or as a workaround, construct your path variables all as  os.path.join elements, and remove the one hiding inside of the comment.

Best wishes, Shaun

0 Kudos
WilsonIonara
New Contributor III

But how do you explain that it works on my coworkers computers, when they publish from theirs? It is the same code. How can I change the dir_path, in this case? 

dir_path = r'e:\ArcGISData\ForestEcosystemValuesData'
arcpy.AddMessage(dir_path)
workspace = os.path.join(dir_path, 'ForestValuesApp.gdb')
arcpy.env.workspace = workspace
arcpy.env.overwriteOutput = True
AOITotalAreaAcres = 0
root = arcpy.env.workspace
urban = os.path.join(root, 'AOIUrbanVector')
0 Kudos
ShaunWalbridge
Esri Regular Contributor

It may be that your coworkers are on different versions of the software, or there are specific circumstances where this bug is introduced that aren't universal, I haven't dug into it sufficiently to say. In terms of the path, could you try something like:

dir_path = os.path.join(r'E:\ArcGISData', 'ForestEcosystemValuesData')


If it persists as an issue despite 'hacks' like these, it may be worth seeing if using a different project location has any effect.

0 Kudos