Select to view content in your preferred language

MakeFeatureLayer not recognizing input file path when run on ArcServer

812
2
01-04-2018 10:25 AM
DevonCanady
Emerging Contributor

Although I ran this script successfully from ArcCatalog, for some reason the file path I'm providing to arcpy.MakeFeatureLayer() changes whenever I run it as a geoprocessing service on ArcGIS Server.

Here are the snippets that lead to this error:

##buildRegQuery.py

[...]

path = os.path.join(root_path, r'Zips\esriZipsLayer_NAD83.shp')

geometry = regUtil.parse_geometry(coords)

regUtil.pull_attributes(3, path, geometry, '0.25 miles')

[...]

##regUtil.py

def pull_attributes(idx, path, geometry, distance):
    search_cursor = select_by_location(path, geometry, distance)

    [...]

def select_by_location(tiger_data_path, geometry, distance):
    arcpy.MakeFeatureLayer_management(tiger_data_path, 'tigerLayer') ##throws error
    arcpy.SelectLayerByLocation_management('tigerLayer', 'INTERSECT', geometry, distance)
    return arcpy.da.SearchCursor('tigerLayer', '*')

Once this code is copied to the local drive of the server (via creating geoprocessing service), it seems to be looking on the server for the data not on the machine I specified in the path. Regarding my original post, I have already set the permissions on the file server hosting the data for the publisher server to access the data by following these instructions. But I'm still getting the same error and I don't feel like that explains why MakeFeatureLayer is getting a file path on the local drive when I'm explicitly providing it as input in my script.

Here is the stack trace:

  • esriJobMessageTypeError: Traceback (most recent call last): File "C:\arcgisserver\directories\arcgissystem\arcgisinput\RegQueryBuilder\RegQueryBuilder.GPServer\extracted\v101\my_toolboxes\buildRegQuery.py", line 45, in distance='0.25 miles') File "C:\arcgisserver\directories\arcgissystem\arcgisinput\RegQueryBuilder\RegQueryBuilder.GPServer\extracted\v101\my_toolboxes\regUtil.py", line 34, in pull_attributes search_cursor = select_by_location(path, geometry, distance) File "C:\arcgisserver\directories\arcgissystem\arcgisinput\RegQueryBuilder\RegQueryBuilder.GPServer\extracted\v101\my_toolboxes\regUtil.py", line 23, in select_by_location arcpy.MakeFeatureLayer_management(tiger_data_path, g_ESRI_variable_1) File "c:\program files\arcgis\server\arcpy\arcpy\management.py", line 5748, in MakeFeatureLayer raise e ExecuteError: Failed to execute. Parameters are not valid. ERROR 000732: Input Features: Dataset C:\arcgisserver\directories\arcgissystem\arcgisinput\RegQueryBuilder\RegQueryBuilder.GPServer\extracted\v101\tigerdata\Zips\esriZipsLayer_NAD83.shp does not exist or is not supported Failed to execute (MakeFeatureLayer).
0 Kudos
2 Replies
JoshuaBixby
MVP Esteemed Contributor

Where is root_path being set and how is it being set?

0 Kudos
DevonCanady
Emerging Contributor

It's a UNC to a folder on another server
root_path = r'\\NewCaspian\BanksNew\Data\tiger\TigerData'

0 Kudos