Select to view content in your preferred language

publishing Python script to server as geoprocessing service??

9604
4
06-28-2013 09:15 AM
CyndyBresloff
Emerging Contributor
I am trying to directly publish a Python script as a geoprocessing service, and I cannot seem to get it to work.  From what I'm reading, I'm not even certain if I should be able to do this without wrapping a model from Model Builder around my script?  Can anyone tell me if there IS indeed a way to publish a straight up Python script as a geoprocessing service from an arc toolbox?  And if so, what exactly need I do to my output (feature set) to GET it to become output from the script to the server.   Examples welcome.  I can't seem to find much information about Python scripts as geoprocessing services. 

thanks!
Tags (2)
4 Replies
KevinHibma
Esri Regular Contributor
Cyndy,

The first step to publishing a script is making it into a script tool.
I'm not sure how far you've got with that, I'll just point you at the high level topic.

Once you've created a script tool, you should be able to run it fine from Desktop. If thats the case, its just a matter of publishing it like you'd publish any other tool.
This help topic talks about some of the pieces to be aware of with script tools as a gp service.

To answer your one question though, if you're doing some sort of "features" as output in the tool - creating your script tool with FeatureClass as the output type. When publishing, everything is handled for you in terms of making output featureclass work in Server. For your input, well it varies greatly, but FeatureSet is one of the most commonly used input parameters as it allows you to both "draw" input features as well as pass in existing layers and featureclasses.
0 Kudos
CyndyBresloff
Emerging Contributor
Hi Kevin -

Getting to the script tool point was easy.  I'm actually now stuck at the point where I don't know how to manage paths in my script for server vs as a Desktop tool.  Ie, in my tool on the desktop I give it the path to look for my data, and I'm not sure how to rewrite that bit for the script as a server tool.  I also am not sure how to direct the script for a scratch directory path for when it runs via server.  Can you advice, I'm not getting an answer for this through the help.

For example - if I a using an arcpy method that uses a path as one of the parameters, what do I use?  arcpy.env.Workspace won't work with the setting I use for Desktop, and not setting it results in an error.

Thanks!!
0 Kudos
KevinHibma
Esri Regular Contributor
Cyndy,

The 2nd link I provided above talks about data inputs and outputs.
Here's some quick points:

  • Input from a tool parameter will be part of the service, it gets there when publishing a result. The Service Editor handles this

  • We call data defined inside the tool, "project data". During publishing we scan the script, match it if possible to data registered in the data store or copy and update paths if there isn't a match

  • Outputs should almost always be written to scratch. Use the os.path.join(arcpy.env.scratchGDB, "output") style


If you happen to be coming to UC, I'm giving a demo theater that will touch on all these topics.
http://events.esri.com/uc/2013/infoweb/onlineagenda/?fa=ofg_details_form&ScheduleID=1830
0 Kudos
KevinGooss
Regular Contributor
almost seems like there should be 'types' of gp tools - those that run in desktop and those that are designed, from the ground up, to be run as ags gp services.
0 Kudos