7

A model I built with ModelBuilder works as expected in Desktop yet generates numerous error messages when published as a geoprocessing (GP) service in ArcGIS Server 10.1 SP1. I've decided to start simple then and am trying to get just a single tool to work.

Here is my model. It has one parameter, a table or a feature class to truncate. When running in ArcGIS Desktop 10.1 SP1, user can specify what object should be truncated. When publishing as a model after getting a successful result, I use default settings for all settings (and Info for Message Level).

Truncate Table model

When running the GP service task in the same ArcGIS Desktop, I get this window in order to supply an object for truncating.

enter image description here

After pointing to a dataset (stored in a 10.1 file geodatabase on a local disk drive), the GP task gets running. The task does not truncate table and produces an error: 000187 : Only supports Geodatabase tables and feature classes.

My guess is that it has something to do with the Input mode of the task (User defined value) which makes it impossible to supply to my task a feature class from a file geodatabase in the file system. It seems as model uses the empty FeatureSet object instead of a feature class I supply when running the GP service task.

Is there a way to make the Truncate Table GP tool to use another feature class (not the same used when running the model first in Desktop before publishing) when published as a GP service?

The model for truncating a table works fine when there are no parameters exposed and when running the GP task of a published service, it runs over the same feature class I've used when running the model first to generate a result.

So, the GP service does work with feature classes yet only with the same one used when running the model before publishing.

Is it possible to supply a feature class to a GP task that differs from the feature class used to run the model and generate the result?

NB: the feature class is not copied to the arcgisserver folder, it is being processed properly right in the geodatabase on the disk, so this part works properly.

4
  • Are you setting the workspace in the environment settings? How would the tool know which table to truncate if you give just the name? It needs the complete path. Feb 11, 2013 at 11:08
  • 1
    Also can you tell us what workflow you would be using? I don't think that a server tool would be able to truncate a table which is present only on the client system. Feb 11, 2013 at 11:10
  • I don't set any workspace. I don't give just a name of table, though. As outlined above, after pointing to a dataset (stored in a 10.1 geodatabase on a local disk drive), the GP task gets running. The task does not truncate table and produces an error. So I do supply the full path to a feature class on a disk. Feb 11, 2013 at 11:56
  • The workflow is that I want to allow a user to supply own feature class to truncate. The GP service task works fine truncating the same feature class (the one I used when running the tool) stored on a machine without copying anything to the server folder. Feb 11, 2013 at 12:00

2 Answers 2

4

The problem was that the GP service is not able to use Feature Classes directly as input parameters. The solution to this is to use a parsing technique which would take a string from a user (name of the feature class) and then append this string variable to the full path of the feature class (I specify the geodatabase name forehand in the code).

It seemed as this is much easier to implement in Python rather than in ModelBuilder, so I've implemented this logic by using arcpy module in ArcGIS 10.1:

import arcpy
from arcpy import env
#Setting the env workspace to be an SDE geodatabase
#
env.workspace = r'C:\sde_at_DB101.sde'

#Getting the existing polygon feature class as input parameter
#
GetExistingPolyFC = arcpy.GetParameterAsText(0)
GetPolyFC = GetExistingPolyFC

# Truncate a feature class if it exists
#
if arcpy.Exists(GetPolyFC):
   arcpy.AddMessage("Polygon feature class exists, start working...")
   arcpy.TruncateTable_management(r'C:\sde_at_DB_101.sde\%s' %GetPolyFC)
   arcpy.AddMessage("Truncating table is complete")

else:
   arcpy.AddMessage("Polygon feature class does not exist")

I've used this logic for other bits of my bigger model and it works just fine as a GP service now. I've decided to rewrite the whole model as a Python script from scratch and it was much easier to implement and it performs much faster too when running the GP task.

3
+25

Looking at your comment, I can see that your work-flow won't work. ArcGIS server geoprocessing services can't update or edit user-provided input data.

They can take an input and process it, but not edit it.

The truncate tool might be useful in other situation, For example you do some processing and then you want to pass only some of that back to the user. In This case you could use a truncate tool in your model, and it would work fine, since that data was already on the server.

Another possible workflow could be if your geoprocessing tool already has access to some data in your SDE, and you just provide the name of the table to truncate. In that case, the service will run successively, since you are just passing the name as input, and ArcGIS server itself is going to the SDE and truncating the data.

But in general,an ArcGIS Server Geoprocessing service can not edit user-provided data.

5
  • Devdatta, I am not sure if you've got me right. A model with the Truncate Table tool I publish as a GP service is able to edit a feature class regardless where it is stored - in a file geodatabase or an ArcSDE geodatabase. However, it seems as the GP service can truncate only the feature class I've used when running the model first for generating a successul result (in order to publish it). So the GP service does truncate the same feature class. My aim, however, is to be able to specify any feature class (that is accessible to the server of course). Feb 11, 2013 at 14:05
  • So, when publishing a model as a GP service and specifying "User defined value" as the Input Mode I am not able to run the GP task. However, when specifying the Constant value, no parameter for the GP task is created and the GP task runs successully yet of course with the same feature class I've run it in Desktop first. I want to find a way to leave the input feature class as an input parameter for the GP task and be able to run it successfully. Feb 11, 2013 at 14:09
  • @AlexTereshenkov: If you are trucating tables on the server, I come back to my original comment. How would the tool know which table to truncate if you give just the name? It needs the complete path. You can specify the complete path by having the input parameter as a featureset, and you could either set the workspace in the model, or ask the user to provide it. Feb 11, 2013 at 14:53
  • 1
    The GP task knows which table to truncate because I provide path to the feature class in the input parameter text box (Input Table parameter on the second figure in my answer). Again, the task does truncating a feature class stored in a geodatabase that was used for running the model first, but I can't find a way to be able to specify another feature class when using the GP task. I am fairly sure this should be possible. Feb 11, 2013 at 15:41
  • 1
    Devdatta, your statement "Looking at your comment, I can see that your work-flow won't work. ArcGIS server geoprocessing services can't update or edit user-provided input data. They can take an input and process it, but not edit it." seems to be incorrect since GP service is actually capable of editing an existing geodatabase object (consider Calculate Field tool for instance, or as in my case, Truncate Table which I finally got to work) Feb 13, 2013 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.