Select to view content in your preferred language

Geoprocessing service failing in web app builder

912
2
02-27-2019 11:22 AM
GrantHaynes
Regular Contributor

I have Python toolbox that I have published a geoprocessing service. It works great in arcmap, and it works great after publishing when I access it from arcmap. However when I try to use it in web app builder it fails, the error reads:

  • Traceback (most recent call last): File "", line 113, in execute File "c:\program files\arcgis\server\arcpy\arcpy\management.py", line 17147, in GetCellValue raise e ExecuteError: ERROR 000622: Failed to execute (Get Cell Value). Parameters are not valid. ERROR 000628: Cannot set input into parameter location_point.

. I have no clue why this is failing earlier versions of this script published as gp services have worked perfectly in the past. If anyone here can figure this out I would be grateful.

# Top Comments

















# Start script
#-----------------------------------------------------------------------------
import arcpy
import os

# Tool initialization
#-----------------------------------------------------------------------------
class Toolbox(object):
    def __init__(self):
        """Define the toolbox (the name of the toolbox is the name of the
        .pyt file)."""
        self.label = "Value_Extraction_Tool"
        self.alias = "Value Extraction Tool"

        # List of tool classes associated with this toolbox
        self.tools = [Tool]

class Tool(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "Value Extraction Tool"
        self.description = ""
        self.canRunInBackground = False

    def getParameterInfo(self):
        DataSource = arcpy.Parameter(
		    displayName="DataSource",
		    name="DataSource",
		    datatype="DEWorkspace",
		    parameterType="Required",
		    direction="Input")

        InputPoint = arcpy.Parameter(
            displayName="InputPoint",
		    name="InputPoint",
		    datatype="DEFeatureClass",
		    parameterType="Required",
		    direction="Input")

        OutputFC = arcpy.Parameter(
            displayName="OutputFC",
		    name="OutputFC",
		    datatype="DEFeatureClass",
		    parameterType="Required",
		    direction="Output")

        params = [DataSource, InputPoint, OutputFC]
        return params

    def isLicensed(self):
        # Set whether tool is licensed to execute.
        return True

    def updateParameters(self, parameters):
        # Modify the values and properties of parameters before internal
        # validation is performed.  This method is called whenever a parameter
        # has been changed.
        return

    def updateMessages(self, parameters):
        #Modify the messages created by internal validation for each tool
        #parameter.  This method is called after internal validation."""
        return

    def execute(self, parameters, messages):

        # User input arguments
        DataSource = parameters[0].valueAsText
        InputPoint = parameters[1].valueAsText
        OutputFC = parameters[2].valueAsText 

        # Handle all input point procesing
        arcpy.CopyFeatures_management(InputPoint, OutputFC)
        arcpy.AddXY_management(InputPoint)

        # Add fields to hold temporal data
        arcpy.AddField_management(OutputFC, "LABEL", "TEXT")
        arcpy.AddField_management(OutputFC, "VALUE", "DOUBLE")

        # Loop through geometry attributes and get the x and y
        with arcpy.da.SearchCursor(InputPoint,"*") as cursor:
            PointIndex = 1
            for row in cursor:
                X = row[3]
                Y = row[4]
                arcpy.AddMessage(str(X) + " " + str(Y))

                # Get rasters and extract data at an X and Y        
                index = 0
                for (path, dirs, files) in os.walk(DataSource):
                    for ThisFile in files:
                        fName,fExt = os.path.splitext(ThisFile)
                        if fExt.upper() == ".IMG" or fExt.upper() == ".TIF":
                            RasterPath = path + "\\" + ThisFile      
                            data = (arcpy.GetCellValue_management(RasterPath, str(X) + " " + str(Y), ""))
                            aquisition_date = arcpy.GetRasterProperties_management(in_raster = RasterPath, property_type = "ACQUISITIONDATE")

                            if str(aquisition_date).upper() == "UNKNOWN":
                                insertcursor = arcpy.InsertCursor(OutputFC)
                                row = insertcursor.newRow()
                                row.setValue("POINTID", PointIndex)
                                row.setValue("LABEL", "{}, Point: {}".format(index, PointIndex))
                                row.setValue("VALUE", data)
                                insertcursor.insertRow(row)
                                del insertcursor
                                index += 1

                PointIndex += 1
        return‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
2 Replies
LynseyBlackburn
Esri Contributor

Are you able to run this service directly from REST using the input parameters provided from WAB? If you open up the web developer tools when running this task in WAB, you should see a submitjob or execute call. Within the headers there will be form data which you can input directly into the REST endpoint for the service to see if maybe this is a client side issue. 

-Lynsey

0 Kudos
LynseyBlackburn
Esri Contributor

Also, within your configuration of the script tool, what are your input data types set to? could you send a screenshot?

0 Kudos