How to Publish GP Service: setting proper env.workspace

01-07-2020 03:48 PM
New Contributor II

We have recently stood up our Enterprise GIS. I am migrating from running my scripts in desktop/Pro environment to trying to figure out a workflow for publishing Python scripts as Geoprocessing services and then return output as hosted feature service. The idea is for a user to grab a published tool from Portal , execute it and see it as a hosted feature service (which is my next task). As I understand it scripts must be run successfully in Pro and then published from there...I can do this successfully.. Tool wont run without error once published though (error attached). What is the proper way to set the env.workspace?...seems like circular logic in that you must  explicitly declare a workspace locally that when published will not exist on the server? 


##make three blank feature classes using one input(input really only used here in order to designate a prj for the three resulting feature classes)

import  sys, os
import arcpy
from arcpy import env

env.workspace=r"D:\arcgisserver\directories\arcgisoutput\MyTestingGroup\Working_GeoProc\working.gdb" ##this is the actual path on arcserver so I have duplicated this directory locally, which seems bonkers to have to do

out_path = env.workspace
arcpy.env.overwriteOutput = True

FC_w_prj=fc = arcpy.GetParameterAsText(0)
a_list=["try1", "try2", "try3"]

geometry_type = "POINT"
has_m = "DISABLED"
has_z = "DISABLED"
spatial_reference = arcpy.Describe(FC_w_prj).spatialReference

for i in a_list:
   arcpy.CreateFeatureclass_management(out_path, out_name, geometry_type, "", has_m, has_z, spatial_reference)

##The above tool publishes successfully but errors out when run on Portal (error000732.png attached)

 I have a ticket open with ESRI on this...I have not reached resolution on this....yet

Does my env.workspace need to be a UNC or URL?

Paths explained: Absolute, relative, UNC, and URL—Help | ArcGIS Desktop  

0 Kudos
0 Replies