I've had a problem with my geoprocessing service finding the data it needs for execution. I found out what's causing this is ArcGIS's assignment of a new variable "g_ESRI_variable_1" in the new copy of the code that lives on the server. However when I try to edit the code back to its original state it says "Permission Denied".
Here is the top few lines of my original script:
import os, regUtil, regQueries, urllib, sys
from arcpy import GetParameterAsText
outpath = GetParameterAsText(1)root_path = r'\\NewCaspian\BanksNew\Data\tiger\TigerData'
And here are the top few lines of the copy in the arcgisserver folder made upon creation of the geoprocessing package:
import os, arcpy
g_ESRI_variable_1 = os.path.join(arcpy.env.packageWorkspace,u'tigerdata')
# Esri end of added variables# Esri start of added imports
import sys, os, arcpy
# Esri end of added importsimport os, regUtil, regQueries, urllib, sys
from arcpy import GetParameterAsText
outpath = GetParameterAsText(1)root_path = g_ESRI_variable_1
It seems very weird that ArcGIS would actually go in and change a variable automatically. Why does this happen and how would I either prevent this from happening or edit the script back to the way I wrote it?
Did you republish the service after registering the data source per your other post, https://community.esri.com/thread/207330-geoprocessing-task-not-using-provided-file-paths?
It sets the path to the arcgisinput folder as it couldn't determine if it had at least read access to the original directory the data was in. It packages the data with the file that is uploaded to the server to create the service and unpacks the data in a location it definitely has access to, (the arcgisinput folder). Once you register the data source as a data store, overwrite the original service or publish a new one. You may still see a variable created for any input data, but it should reference the original path.
No I hadn't republished the service after registering the data, thanks! After doing so the path it referenced was the original path. However, it also add '\\0\\v101\\tigerdata" to the path so I was still getting the error but it at least was pointing to the file server. My workaround for now is just to manually set the g_ESRI_variable1 to my root path after ArcGIS set it.