AnsweredAssumed Answered

Dissolve tool error: "Invalid field type" only in GP Service

Question asked by MollyKFoley on Apr 4, 2018
Latest reply on Apr 6, 2018 by MollyKFoley

I'm running a python script as a GP service, this script works great when run in the IDE or when run from a toolbox in ArcMap, but I cannot run the tool once it's published in a geoprocessing service. The error I receive is when it hits a line that uses the dissolve tool. It says "Error 000308: Invalid field type". All the fields being used to dissolve are integers, strings, float, and GUID data types. It runs successfully when it's not a geoprocessing service, so I know the fields are of a valid data type. I think it has something to do with my use of in_memory workspaces, but from what I have read, using in_memory workspace is the best practice when creating a lot of intermediate data in a GP service. I don't think the program is running out of memory when dissolving either because it's only dissolving a max of 200 features (and more often than not, it's really dissolving 50 or less). 

 

In the non-GP service code:

try:
  #Intersect buffer with selected patches to evaluate appropriate access to protective cover
  intersect_result = arcpy.Intersect_analysis([[aa2PCPolys, 1], [pc_buffer, 2]], 'in_memory/pc_intersect')
except:
intsctError = traceback.format_exc()
arcpy.AddError(intsctError)
sys.exit(1)

#Define fields by which to aggregate features in the intersect_result FC
dissolveFields = ['StateID', 'Point', 'PatchNum', 'IsDeveloped', 'CropTypeID', 'CropResidue', 'CnpyOver12', 'CnpyDecid',
                              'CnpyConif', 'ShrubCover', 'ShbHiStemsDens', 'GrassCover', 'ForbCover', 'FrbAsProtect', 'ForbSpecies',
                              'BareGround', 'HerbHeight', 'IsQuailHab', 'ObsvDate', 'FirstName', 'LastName', 'Overstory', 'Understory',
                              'OfficialQH', 'StatePoint', 'MonitoringPointID', 'Orig_OID', 'Imputation', 'WhereImpute', 'QHonImputedVals',
                              'ObsvType']

#Aggregate features (ERRORS OUT ON THIS LINE)
try:
  dislvIntersect = arcpy.Dissolve_management(intersect_result, 'in_memory/pc_dislvIntersect', dissolveFields)

 

Once it has been published as  GP service it replaces the in_memory stuff with ESRI variables:

try:
  #Intersect buffer with selected patches to evaluate appropriate access to protective cover
  intersect_result = arcpy.Intersect_analysis([[aa2PCPolys, 1], [pc_buffer, 2]], g_ESRI_variable_28)
except:
  intsctError = traceback.format_exc()
  arcpy.AddError(intsctError)
  sys.exit(1)

#Define fields by which to aggregate features in the intersect_result FC
dissolveFields = ['StateID', 'Point', 'PatchNum', 'IsDeveloped', 'CropTypeID', 'CropResidue', 'CnpyOver12', 'CnpyDecid',
                              'CnpyConif', 'ShrubCover', 'ShbHiStemsDens', 'GrassCover', 'ForbCover', 'FrbAsProtect', 'ForbSpecies',
                              'BareGround', 'HerbHeight', 'IsQuailHab', 'ObsvDate', 'FirstName', 'LastName', 'Overstory', 'Understory',
                              'OfficialQH', 'StatePoint', 'MonitoringPointID', 'Orig_OID', 'Imputation', 'WhereImpute', 'QHonImputedVals',
                              'ObsvType']
#Aggregate features (ERRORS OUT ON THIS LINE)
try:
   dislvIntersect = arcpy.Dissolve_management(intersect_result, g_ESRI_variable_29, dissolveFields)

 

This part of the python script is recursive, in that it will do this process many times on different selected features. I noticed from the error messages it went through it one full time, and then errored out on the second pass (see the first two messages in the picture, that message prints every time it starts a new pass). Does it have to do with overwriting issues maybe? I have arcpy.env.overwriteOutput = True set, but I don't know how that effects in_memory datasets.

Outcomes