2

I have been trying to publish a python 'Hello, World!' sample geoprocessing service. I have ArcMap 10.7.1 and ArcGIS Enterprise Server 10.71. In Arc Map I started with a new Python Toolbox, and added an input parameter (string) and output parameter (string). The script will echo the input parameter as the result to show things are set up correctly and working. It works in ArcMap. I can also run the .pyt script on the ArcGIS Server locally.

Here is the complete python tool box:

import arcpy

class Toolbox(object):
    def __init__(self):
        """Define the toolbox (the name of the toolbox is the name of the
        .pyt file)."""
        self.label = "BasicTest"
        self.alias = "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 = "Tool"
        self.description = "Desc"
        self.canRunInBackground = True

    def getParameterInfo(self):
        """Define parameter definitions"""
        params = []
        params.append(arcpy.Parameter(displayName='Input',
                                      name='Input',
                                      datatype='String',
                                      parameterType="Required",
                                      direction="Input"))
        params.append(arcpy.Parameter(displayName='Output',
                                      name='Output',
                                      datatype='String',
                                      parameterType='Derived',
                                      direction='Output'))
        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):
        """The source code of the tool."""

        arcpy.AddMessage("Input was: " + parameters[0].valueAsText)
        arcpy.AddMessage("******************************************")
        arcpy.SetParameterAsText(1, "Output is: " + parameters[0].value)
        return

It runs fine in ArcMap:

Results panel

Then I right click the result, and Share As... Geoprocessing Service. I added stuff for parameter description, and tool description and summary. I set the information level to Info. Checked for no warnings or errors, and clicked publish. It says Published Successfully. I can browse to it, and click Submit Job to test it, and it always fails as not a valid tool: Submit Job screen

Job Messages:

esriJobMessageTypeInformative: Submitted.
esriJobMessageTypeInformative: Executing...
esriJobMessageTypeError: ERROR 000816: The tool is not valid.
esriJobMessageTypeError: Failed.

I read a tip somewhere about checking the folder on the server for the packaged python toolbox and try running that from the server. So I tried that too and it runs just fine:

PS C:\python27> .\ArcGISx6410.7\python.exe
Python 2.7.16 (v2.7.16:413a49145e, Mar  4 2019, 01:37:19) [MSC v.1500 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> import arcgisscripting
>>> import arcpy
>>> import os
>>> os.chdir(r'C:\arcgis\arcgisserver\directories\arcgissystem\arcgisinput\MyFolder\BasicTool.GPServer\extracted\v101\basictest')
>>> arcpy.ImportToolbox(r".\BasicTest.pyt", "Tool")
<module 'Tool' (built-in)>
>>> arcpy.Tool.Tool("Hi There")
Input was: Hi There
******************************************
<Result 'Output is: Hi There'>
>>>

So I've never done this successfully, what am I missing? What is invalid about the tool?

3
  • Can you try running the tool on the server, but from ArcMap?
    – nr_aus
    Jul 21 '20 at 7:01
  • @nr_ogc Thanks, I can't currently because ArcMap is not installed on the ArcGIS Sever. I'd need to be careful it doesn't overwrite the default python environment of ArcGIS Server (64 bit server vs. 32 bit arcmap), I think. I was reading something about that and it makes we wary to try it without a good reason and research.
    – freshop
    Jul 22 '20 at 16:25
  • Sounds like a TEST or DEV server equivalent environment would be useful for you in this instance. You mentioned 32bit vs 64bit - I know bit version incompatibility exists in other software, such as database and db client software needs to be matching bit versions.... not sure about AGIS Server and ArcMap though (and I kinda doubt it in this instance)…… Try manually publishing the tookit through ArcServer Manager (as opposed to publishing from ArcMap)…. This will eliminate/identify the ArcMap 'Share as …." part of your workflow as being the problem.
    – nr_aus
    Jul 23 '20 at 1:38
0

I wanted to share that the service runs successfully after performing a repair install of the ArcGIS Server. This fixed some ArcPy dependencies that were broken by running PIP to install a python package on the server. The ERROR 000816: The tool is not valid. message from ArcGIS Server really meant that the ESRI ArcPy environment was messed up.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.