3

I am attempting to use an ArcGIS Desktop 10.5.1 client to publish a Geoprocessing Toolbox to an instance of ArcGIS Server 10.3.1. According to the FAQ, the version difference should not cause this problem.

Using the same example, I have the same results as https://community.esri.com/thread/177453: After clicking Publish from the Service Editor in ArcMap, the "Successfully Published Service" appears. However, when I visit the REST endpoint for the published service, the Tasks list is empty. Although I do not have ArcMap installed on the ArcGIS Server instance, the posted workaround of creating, staging, and uploading the service definition draft from the server "works" for the MWE below but is not feasible for our deployment pipeline.

Minimal Example: A single-tool Python toolbox to return the sum of two integers, along with its associated XML files is transferred to a host running ArcGIS Server 10.3. Also in the same directory are a server.ags connection file and an arcpy script to draft and publish the service.

InputToolbox.pyt:

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 = "InputToolbox"
        self.alias = "InputToolbox"

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


class AddTool(object):
    def __init__(self):
        """Define the tool (tool name is the name of the class)."""
        self.label = "AddTool"
        self.description = "Adds two integers"
        self.canRunInBackground = False

    def getParameterInfo(self):
        """Define parameter definitions"""
        params = [
            arcpy.Parameter(
                displayName="Addend 1",
                name="addend1",
                datatype="GPLong",
                parameterType="Required",
                direction="Input"
            ),
            arcpy.Parameter(
                displayName="Addend 2",
                name="addend2",
                datatype="GPLong",
                parameterType="Required",
                direction="Input"
            ),
            arcpy.Parameter(
                displayName="Sum",
                name="sum",
                datatype="GPLong",
                parameterType="Optional",  # a recommended workaround
                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."""
        parameters[2].value = parameters[0].value + parameters[1].value
        return

publish.py:

# Imports a .pyt Python Toolbox and publishes its Geoprocessing Service
import arcpy
import os

tool_name = u'AddTool'
pyt_filepath = u'./InputToolbox.pyt'
ags_workspace = u'./server.ags'
tool_kwargs = {
    u'addend1' : 2,
    u'addend2' : 4,
}

pyt_filepath = os.path.abspath(pyt_filepath)
tbx_module = arcpy.ImportToolbox(pyt_filepath)
tool_result = getattr(tbx_module, tool_name)(**tool_kwargs)
sddraft_filepath = os.path.abspath(u'./' + tool_name + '.sddraft')
arcpy.CreateGPSDDraft(
    tool_result,
    sddraft_filepath,
    tool_name,
    server_type='ARCGIS_SERVER',
    connection_file_path=None,
    copy_data_to_server=False,
    folder_name=None,
    summary='perfunctory',
    tags='perfunctory',
    showMessages='Info',
    executionType='Asynchronous',
)

sd_filepath = sddraft_filepath[:-5]
arcpy.StageService_server(sddraft_filepath, sd_filepath)
arcpy.UploadServiceDefinition_server(sd_filepath, ags_workspace)

InputToolbox.pyt.xml

<?xml version="1.0" encoding="UTF-8"?>
<metadata xml:lang="en"><Esri><CreaDate>20180123</CreaDate><CreaTime>16565400</CreaTime><ArcGISFormat>1.0</ArcGISFormat><SyncOnce>TRUE</SyncOnce><ModDate>20180123</ModDate><ModTime>192522</ModTime></Esri><toolbox name="InputToolbox" alias="InputToolbox"><arcToolboxHelpPath>c:\program files (x86)\arcgis\desktop10.5\Help\gp</arcToolboxHelpPath><toolsets/></toolbox><dataIdInfo><idCitation><resTitle>InputToolbox</resTitle></idCitation></dataIdInfo><distInfo><distributor><distorFormat><formatName>ArcToolbox Toolbox</formatName></distorFormat></distributor></distInfo></metadata>

InputToolbox.AddTool.pyt.xml:

<?xml version="1.0"?>
<metadata xml:lang="en"><Esri><CreaDate>20180123</CreaDate><CreaTime>17123400</CreaTime><ArcGISFormat>1.0</ArcGISFormat><SyncOnce>TRUE</SyncOnce><ModDate>20180123</ModDate><ModTime>174505</ModTime><scaleRange><minScale>150000000</minScale><maxScale>5000</maxScale></scaleRange><ArcGISProfile>ItemDescription</ArcGISProfile></Esri><tool name="AddTool" displayname="AddTool" toolboxalias="InputToolbox" xmlns=""><arcToolboxHelpPath>c:\program files (x86)\arcgis\desktop10.5\Help\gp</arcToolboxHelpPath><parameters><param name="addend1" displayname="Addend 1" type="Required" direction="Input" datatype="Long" expression="addend1"><dialogReference>&lt;DIV STYLE="text-align:Left;"&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;The first of two integers to be added together&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</dialogReference></param><param name="addend2" displayname="Addend 2" type="Required" direction="Input" datatype="Long" expression="addend2"><dialogReference>&lt;DIV STYLE="text-align:Left;"&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;The second of two integers to be added together&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</dialogReference></param></parameters><summary>&lt;DIV STYLE="text-align:Left;"&gt;&lt;DIV&gt;&lt;P&gt;&lt;SPAN&gt;adds numbers&lt;/SPAN&gt;&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</summary></tool><dataIdInfo><idCitation><resTitle>AddTool</resTitle></idCitation><searchKeys><keyword>test adding</keyword></searchKeys></dataIdInfo><distInfo><distributor><distorFormat><formatName>ArcToolbox Tool</formatName></distorFormat></distributor></distInfo><mdHrLv><ScopeCd value="005"></ScopeCd></mdHrLv></metadata>

If it is relevant, I notice that the arcgisserver\directories\arcgisoutput\MyService_GPServer\MyTask folder contains files toolinfos.dat and toolinfos.xml but not the MyTool.htm and MyTool.xml files present for functional published services.

0

1 Answer 1

3

As commented by @KHibma:

Double check the last note in that FAQ part you reference: If you're publishing a geoprocessing service, the ArcGIS Desktop and ArcGIS Server versions must match.

In full that part of the help page on Compatibility of ArcGIS Server 10.5.1 with earlier versions says:

Can I use ArcGIS Desktop 10.5.1 to publish a service to an earlier version of ArcGIS Server?

Generally, you can publish services to a 10.1 or 10.2 version of ArcGIS Server using a 10.5.1 version of ArcGIS Desktop. However, you will not be able to take advantage of any new 10.5.1 functionality until your server is upgraded to 10.5.1.

If you're publishing a geoprocessing service, the ArcGIS Desktop and ArcGIS Server versions must match.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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