Saturday 30 September 2017

arcgis 10.2 - Prevent parameter defaults in service definition file


I have a Python toolbox with a single tool designed for 10.2. The tool is intended to be a geoprocessing service on a server. So I run the tool, and after it succeeds, I right click the result and choose Share As --> Geoprocessing Service. In the wizard, I choose "Save a service definition file" and move through the wizard until it switches to the dialog where I can set service properties. I Analyze, and there are no errors or warnings.


At this point, I notice that my parameters are being given default values. In particular, they get the values that I used when I ran the tool to create the results file. ArcGIS's dialog will not let me modify the default parameters; the text boxes are read only.


I want to prevent this. Ideally, my parameters would have no default values, but empty string default values would also be acceptable. All my input parameters happen to be strings. How can I prevent ArcGIS from using the result's parameters as the defaults?




Answer



As @AlexTereshenkov noted, there doesn't seem to be a way to prevent this.


So, I have come up with the following work around: I have revised my services so that bad inputs will generate empty output. (For me, this was an empty shapefile or geodatabase.) This is far, far from ideal. An error message would be more useful to users, but my particular scripts can live with this workaround since end users will never call them directly. All calls to this service come from a web application (It's not even publicly accessible.), and the web app can ensure the input is correct.


By generating empty results for bad inputs, I can run the tool on a desktop with nonsense inputs and generate an empty data set. Using this run to generate the service definition file, my services now have nonsense defaults and generate empty output if those defaults are used. This lowers the risk of someone getting the wrong output because of a programming error.


As I said, this isn't ideal, but it does do roughly what I need without modifying anything after publishing. I wouldn't recommend this solution in all cases, but I think it's workable in cases where some external service can filter the inputs.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...