GP Service default values

4718
1
05-25-2014 11:00 PM
by Anonymous User
Not applicable
Original User: oearley

Firstly, apologies for the length of this post but it clearly steps through the issue.

I have been struggling with the new idea of publishing GP services only after having run them in ArcMap �?? others have already raised some of my concerns in this thread: http://forums.arcgis.com/threads/61461-publishing-a-geoprocessing-toolbox

Anyway, running a script in ArcMap first raises an interesting behavior concerning default values.

This is a test python script to demonstrate the issue:

p0 = arcpy.GetParameterAsText(0)
p1 = arcpy.GetParameterAsText(1)
p2 = arcpy.GetParameterAsText(2)
# Test/replace input values
if p1 == "#" or not p1:
    p1 = 'NULL'
if p2 == "#" or not p2:
    p2 = 'NULL'
output = '{0}-{1}-{2}'.format(p0,p1,p2)
arcpy.SetParameterAsText(3, output)


No default values are set in the script parameters:

[ATTACH=CONFIG]34074[/ATTACH]

Run in ArcMap

I then run the script in ArcMap with the following values:

p0 = A
p1 = B
p2 =

The result is what I expected, output = 'A-B-NULL'

[ATTACH=CONFIG]34075[/ATTACH]

Publish to Server

I right-click on the result and publish to server �?? this takes over 10 minutes to complete (9+ minutes to stage and 48 seconds to publish). This is a 10 line script with 3 input parameters and 1 output, no processing at all beyond a couple of conditional statements and a single string concatenation. It takes less than a second to run the script in ArcMap.

[ATTACH=CONFIG]34076[/ATTACH]

Bonus question: The machine this is running on is a fairly old work PC but what is ArcGIS doing that could possibly take this long?

Test a Submit Job

I navigate to the GP service tool, for example:

http://myserver/arcgis/rest/services/testScript/GPServer/Test%20Script/submitJob


The web user interface displays the values used when running the script in ArcMap as the default values (not the values set in the Test Script Properties).

If I clear the optional p1 parameter and run the tool I would expect to get the result: A-NULL-NULL

However, when the tool is run the submit job user interface shows the parameter values as:

Input Parameter: p0 (Test Script)
{
"paramName": "p0",
"dataType": "GPString",
"value": "A"
}

Input Parameter: p1 (Test Script)
{
"paramName": "p1",
"dataType": "GPString"
}

Note the absence of a value for p1.

Input Parameter: p2 (Test Script)
{
"paramName": "p2",
"dataType": "GPString"
}

Result Parameter: Output (Test Script)
{
"paramName": "Output",
"dataType": "GPString",
"value": "A-B-NULL"
}

Why is the original value �??B�?? used when I explicitly cleared it? - a null value should have been passed into the script.

To me, a default value has a very different meaning to a null value. If this parameter is optional a null value is totally acceptable and should not be replaced with the default (displayed) value.

I will look at modifying my other scripts to use null values when running them in ArcMap before publishing but this looks like either a bug or a bad design decision.

Cheers,

Owen
1 Reply
subba_krishnakatta1
New Contributor

I am also having the same problem. I do not know how to clear default values while publishing GP.

As I know there is no option to remove default values in service editor dialogue.

Regards,

K S Krishna.

0 Kudos