How to to set tool parameters to be of "Constant" type while scripting the publishing of a gp service?

2525
4
05-24-2016 02:18 AM
WhereMatters
Occasional Contributor


When scripting the publishing of geoprocessing services using python, how can we set certain tool parameters to be of "Constant value" type or "User Defined" type?

Can we do this only in the service editor in Desktop while publishing?

How can we do this via scripting?

Tags (2)
0 Kudos
4 Replies
FC_Basson
MVP Regular Contributor

You should be able to do it in both environments.  In Python you can just use a normal variable or pass the value inline, while in Desktop (I assume model builder) you can create a variable with a set value to use as input for another process or tool in the model.

0 Kudos
WhereMatters
Occasional Contributor

Hi FC Basson,

I actually have a python script tool with about 25 input parameters. I run this tool and while publishing as gp service, I select about 20 parameters to be constants, i.e., stuff like path to data etc., which does not need to exposed as a parameter in the rest end point.  Only the parameters that need to be exposed at the REST endpoint are set as "User defined". I do this in desktop.

When scripting this publishing process, i run the tool through python, create the sddraft, then the sd(service definition), then stage and upload to server. In this process, i could not find a way to configure parameters as "Constant" or "Userdefined".

Is this making sense now?

0 Kudos
FC_Basson
MVP Regular Contributor

OK I see.  The user should not need to to worry about any "constant" parameters in your model, so only the "user defined" ones must be specified right?

0 Kudos
ModyBuchbinder
Esri Regular Contributor

If you do not need the user to give a value just do not make parameter of this value, just hardcoded it in your python script.

You can make it parameter and give default value, then the user will see it and can change it but the default parameter is used if the user do not change the value.

0 Kudos