Select to view content in your preferred language

Supply a feature class for a GP service

1106
4
Jump to solution
02-10-2013 11:55 PM
AlexeyTereshenkov
Deactivated User
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).

[ATTACH=CONFIG]21666[/ATTACH]

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

[ATTACH=CONFIG]21667[/ATTACH]

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?


EDIT: 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.

Question: 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.
Tags (2)
0 Kudos
1 Solution

Accepted Solutions
nicogis
MVP Alum
The problem is that you set a object (features, file ect) in input it is copied on server. At server arrive a stream byte (object Transportable): if it in a path registered it haven't sense.

if you are in same network you can share gp (you don't need create service) but if you create a gp service you could do something that is close to your request passing a string parameter: create a variable string (named MyPathAndFile in picture) and use it in input for truncate.

see attached image[ATTACH=CONFIG]21740[/ATTACH]

View solution in original post

0 Kudos
4 Replies
nicogis
MVP Alum
For Truncate you can use only FC and table in geodatabase (example you cannot use shapefile).

you however see http://resources.arcgis.com/en/help/main/10.1/0154/0154000003mn000000.htm

If the input to your task is a geodatabase, the Input mode will be fixed to Constant value. If you publish with the input mode set to Constant value, the geodatabase and its contents will be copied to the server (unless it's found in the server's data store) and your task will use the copied geodatabase. Personal geodatabases (.mdb) are not supported on server platforms (64-bit Windows and Linux) and will be converted to file geodatabases when copied to the server. Enterprise geodatabases will also be converted to file geodatabases when copied to the server.

then you use truncate on fc or table in gdb and return client:

Create a layer package (.lpk) of the dataset using one of the tools in the Layers and Table Views toolset, then use the Package Layer tool to create the layer package. A layer package is a file, and files are transportable across the Internet. The client will have to unpack the package.

or

Use the ZIP utility to create a file of the result dataset or folder and transport the .zip file to the client. The client is responsible for unzipping the file. The clip and ship service example clips layers from a study area into a file geodatabase (and other formats), then creates a .zip file to be transported to the client. If you wish to use this technique, refer to these links below:
Zip.py takes an input folder and an output file name and creates a compressed .zip file.
Unzip.py takes an input .zip file and an output folder and writes the contents to the folder.
0 Kudos
AlexeyTereshenkov
Deactivated User
Thank you for the answer.

I am not sure you've got me right though. 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. Nothing is copied to the server ever (I have data store registered). 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 over and over again regardless of what I choose as my input table when running the GP task. My aim, however, is to be able to specify any feature class (that is accessible to the server of course).

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 - getting this "000187: Only supports Geodatabase tables and feature classes" error. However, when specifying the Constant value during the publishing process, 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.

What puzzles me is how to make the GP task work on a user provided feature class from a registered data store instead of using a constant feature class that I've run the model with to be able to publish a successful result.
0 Kudos
nicogis
MVP Alum
The problem is that you set a object (features, file ect) in input it is copied on server. At server arrive a stream byte (object Transportable): if it in a path registered it haven't sense.

if you are in same network you can share gp (you don't need create service) but if you create a gp service you could do something that is close to your request passing a string parameter: create a variable string (named MyPathAndFile in picture) and use it in input for truncate.

see attached image[ATTACH=CONFIG]21740[/ATTACH]
0 Kudos
AlexeyTereshenkov
Deactivated User
Thank you. This is very close to what I received in this post. I can't seem to get the Truncate Table working with inline variable substitution in ModelBuilder, so I switched completely to Python (much easier to get things done, I should say).

I use this workflow:

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.
0 Kudos