Problem publishing PYT files to Server using script

Discussion created by bdaigle on Nov 22, 2013
Latest reply on Nov 22, 2013 by bdaigle
I have developed a script that we use to publish our PYT-based geoporocessing tools to our server environment so we don't need to go through the painful manual publishing process. The script basically:

  • imports the pyt toolbox

  • updates a few tags in the xml files so the analyze runs without error

  • runs each of the tools in the toolbox using the tools default values

  • passes the results of all tools to the arcpy.CreateGPSDDraft function

  • Analyzes the sdraft

  • Creates the sd file

  • deletes the service on the server if already exists

  • uploads the sd file to server

The script works great when all tools parameters are of string datatype. In this case, I simply give the paramater a default value using the parameter's value property(i.e. param.value="some default text").

I start running into problems however, when I try to include a parameter of type GPFeatureRecordSetLayer. In this case, I'm not sure what to set the default value to. If I were using the manual publish process, I would:

  • Set the parameter value equal a layer file's path.

  • Run the tool in ArcMap

  • publish the result

Although this method work, I need to do this for a number of tools, so I would really like to script the process. When I tried to publish the same tool using the script I developed, I'm not sure what use for the parameter's default value. I have tried two different methods so far:

  • If I set the value equal a .lyr file path(as I did in the manual process), the script I developed fails (i.e. crashes the editor) when it tries to create the sd file.

  • If I first use arcpy.MakeFeatureLayer_management on the .lyr file path, then pass the Feature Layer as the parameter's value, the script runs all the way through and the service gets published to server. However, when I try to run the published too, I get an error that the tool is not valid.

I'm not sure where to go from here. I am using Server 10.1 if that makes a difference.

I can provide sample code, but it will take a bit to clean it up and make it portable. Any thoughts are greatly appreciated.