Issue with Geoprocessing service

4201
12
06-29-2015 03:19 PM
jayshukla
New Contributor III

Hi There,

I have a GP model that does some analysis and adds few columns in the feature class. I ran this model successfully on my local machine and after that I published this model as a service. The model was published successfuly as well. When i use this GP service and use the featureclasses that are located on my machine, service comes back with an error. I am not sure if GP service can make change to a feature class that is local on my pc. Appreciate any feedback. Thanks Jay

0 Kudos
12 Replies
JonathanQuinn
Esri Notable Contributor

Jay,

The ArcGIS Server account needs at least read access to any data you're trying to use within ArcGIS Server, so you're most likely right in that it can't see the data on your local PC.  Can you set the messages to Info for the geoprocessing service under Parameters and reply back with an image of the error you get?

Thanks,

Jon

jayshukla
New Contributor III

Hi Jon, Thanks for the feedback. These are all the errors that I get, seems a lot. The same model ran fine while runing from desktop, Appreciate your input.

Thanks Jay   

GPServiceError.bmp

0 Kudos
XanderBakker
Esri Esteemed Contributor

Can you post the code of your script (see: Posting Code blocks in the new GeoNet  )? That would help to see what might be going wrong...

0 Kudos
jayshukla
New Contributor III
# Import arcpy module
import arcpy
# Load required toolboxes
arcpy.ImportToolbox("Model Functions")
# Script arguments
Your_AMU_Name = arcpy.GetParameterAsText(0)
if Your_AMU_Name == '#' or not Your_AMU_Name:
    Your_AMU_Name = "BNDRYNAME = 'AB'" # provide a default value if unspecified
Your_Projected_LSD_Grid = arcpy.GetParameterAsText(1)
if Your_Projected_LSD_Grid == '#' or not Your_Projected_LSD_Grid:
    Your_Projected_LSD_Grid = "Abr_Grid_GP_U_CH" # provide a default value if unspecified
Your_NPR = arcpy.GetParameterAsText(2)
if Your_NPR == '#' or not Your_NPR:
    Your_NPR = "GP_U_CH_H" # provide a default value if unspecified
Exported_AMU_Layer__not_SDE_ = arcpy.GetParameterAsText(3)
if Exported_AMU_Layer__not_SDE_ == '#' or not Exported_AMU_Layer__not_SDE_:
    Exported_AMU_Layer__not_SDE_ = "AMU_1" # provide a default value if unspecified
Tool_test_2_Layer = arcpy.GetParameterAsText(4)
if Tool_test_2_Layer == '#' or not Tool_test_2_Layer:
    Tool_test_2_Layer = "Abr_Grid_GP_U_CH_Layer" # provide a default value if unspecified
# Local variables:
AMU_1__4_ = Your_AMU_Name
Abr_Grid_GP_U_CH__2_ = AMU_1__4_
Abr_Grid_GP_U_CH__3_ = Abr_Grid_GP_U_CH__2_
Output_Layer = Abr_Grid_GP_U_CH__3_
Selected_Countour = AMU_1__4_
GP_U_CH_Statistics1 = Selected_Countour
Value__2_ = GP_U_CH_Statistics1
Value = Value__2_
# Process: Select Layer By Attribute
arcpy.SelectLayerByAttribute_management(Exported_AMU_Layer__not_SDE_, "NEW_SELECTION", Your_AMU_Name)
# Process: Select Layer By Location (2)
arcpy.SelectLayerByLocation_management(Your_Projected_LSD_Grid, "INTERSECT", AMU_1__4_, "", "NEW_SELECTION")
# Process: Select Layer By Location
arcpy.SelectLayerByLocation_management(Abr_Grid_GP_U_CH__2_, "INTERSECT", Your_NPR, "", "SUBSET_SELECTION")
# Process: Make Feature Layer
arcpy.MakeFeatureLayer_management(Abr_Grid_GP_U_CH__3_, Output_Layer, "", "", "FID FID VISIBLE NONE;Shape Shape VISIBLE NONE;DLS_TAG DLS_TAG VISIBLE NONE;H1 H1 VISIBLE NONE")
# Process: Select Layer By Location (3)
arcpy.SelectLayerByLocation_management(Your_NPR, "INTERSECT", AMU_1__4_, "", "NEW_SELECTION")
# Process: Summary Statistics
arcpy.Statistics_analysis(Selected_Countour, GP_U_CH_Statistics1, "Elevation MAX", "")
# Process: Get Field Value
arcpy.GetFieldValue_mb(GP_U_CH_Statistics1, "MAX_Elevation", "Long", "0")
# Process: For
arcpy.IterateCount_mb("0", Value__2_, "1")
# Process: Add Field
arcpy.AddField_management(Output_Layer, "H%Value%", "SHORT", "", "", "", "", "NULLABLE", "NON_REQUIRED", "")
0 Kudos
XanderBakker
Esri Esteemed Contributor

wow... I really dislike the python code that ModelBuilder exports...

It is going to take a little more time to clean this code in order to understand it and see what might be going wrong. Be aware that a model running locally is no guarantee that it will work as geoprocessing service.

I will get back to you...

0 Kudos
XanderBakker
Esri Esteemed Contributor

mmmm... just looking at this section:

Your_AMU_Name = arcpy.GetParameterAsText(0)

# ...code omitted...

# Local variables: 
AMU_1__4_ = Your_AMU_Name 
Abr_Grid_GP_U_CH__2_ = AMU_1__4_ 
Abr_Grid_GP_U_CH__3_ = Abr_Grid_GP_U_CH__2_ 
Output_Layer = Abr_Grid_GP_U_CH__3_ 
Selected_Countour = AMU_1__4_ 
GP_U_CH_Statistics1 = Selected_Countour 
Value__2_ = GP_U_CH_Statistics1 
Value = Value__2_

So, the script reads out the first parameter as text and sets this to the variable "Your_AMNU_Name". No problem there... but then in the section of the local variables a whole list of variables are set and they all will have the same value as "Your_AMNU_Name". In some of the tools executed afterwards input and output turn out to be the same... I think this might be the reason why the script doesn't work.

Could you explain in a little more detail what you are trying to obtain and what the 5 parameters consist of (maybe even include some sample or dummy data)? The smoke curtain that ModelBuilder has put up while exporting the code is giving me a hard time understanding the process.

0 Kudos
XanderBakker
Esri Esteemed Contributor

OK, I still have a hard time trying to understand what you are doing (which would be a lot clearer if you could provided some sample data). I have the feeling that there are some redundant selections being made and at the end a list of fields are added to the featureclass, but not filled with anything.

You will see the result directly when you execute the script in a desktop environment. In server I guess that inputs will be send to the server as featuresets and you would have to set an output parameter to hold the result of the geoprocessing service.

0 Kudos
RebeccaStrauch__GISP
MVP Emeritus

Xander, I would have to agree with you on the MB to Python ugliness.  For what it's worth, I found this blog earlier today (old post) Considerations when exporting a model to a Python script | ArcGIS Blog

XanderBakker
Esri Esteemed Contributor

Yep, that blog is still valid. It seems that many examples from the blog can be applied to this script. Thanks for sharing!

0 Kudos