<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic How to Publish GP Service: setting proper env.workspace  in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/how-to-publish-gp-service-setting-proper-env/m-p/336329#M26390</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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&amp;nbsp; explicitly declare a workspace locally that when published will not exist on the server?&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;##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)&lt;/P&gt;&lt;P&gt;import&amp;nbsp; sys, os&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;env.workspace=r"D:\arcgisserver\directories\arcgisoutput\MyTestingGroup\Working_GeoProc\working.gdb" #&lt;EM&gt;#this is the actual path on arcserver so I have duplicated this directory locally, which seems bonkers to have to do&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;out_path = env.workspace&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;FC_w_prj=fc = arcpy.GetParameterAsText(0)&lt;BR /&gt;a_list=["try1", "try2", "try3"]&lt;/P&gt;&lt;P&gt;geometry_type = "POINT"&lt;BR /&gt;has_m = "DISABLED"&lt;BR /&gt;has_z = "DISABLED"&lt;BR /&gt;spatial_reference = arcpy.Describe(FC_w_prj).spatialReference&lt;/P&gt;&lt;P&gt;for i in a_list:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;out_name=i&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.CreateFeatureclass_management(out_path, out_name, geometry_type, "", has_m, has_z, spatial_reference)&lt;/P&gt;&lt;P&gt;##The above tool publishes successfully but errors out when run on Portal (error000732.png attached)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I have a ticket open with ESRI on this...I have not reached resolution on this....yet&lt;/P&gt;&lt;P&gt;Does my env.workspace need to be a UNC or URL?&lt;/P&gt;&lt;P&gt;&lt;A class="cc_cursor link-titled" href="https://desktop.arcgis.com/en/arcmap/10.6/tools/supplement/pathnames-explained-absolute-relative-unc-and-url.htm#GUID-A1658F9A-FF24-454E-B0BA-55FAB5C3DF4E" title="https://desktop.arcgis.com/en/arcmap/10.6/tools/supplement/pathnames-explained-absolute-relative-unc-and-url.htm#GUID-A1658F9A-FF24-454E-B0BA-55FAB5C3DF4E"&gt;Paths explained: Absolute, relative, UNC, and URL—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;INPUT type="hidden" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 07 Jan 2020 23:48:20 GMT</pubDate>
    <dc:creator>ChristopherOneal</dc:creator>
    <dc:date>2020-01-07T23:48:20Z</dc:date>
    <item>
      <title>How to Publish GP Service: setting proper env.workspace</title>
      <link>https://community.esri.com/t5/python-questions/how-to-publish-gp-service-setting-proper-env/m-p/336329#M26390</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;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&amp;nbsp; explicitly declare a workspace locally that when published will not exist on the server?&amp;nbsp;&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;##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)&lt;/P&gt;&lt;P&gt;import&amp;nbsp; sys, os&lt;BR /&gt;import arcpy&lt;BR /&gt;from arcpy import env&lt;/P&gt;&lt;P&gt;env.workspace=r"D:\arcgisserver\directories\arcgisoutput\MyTestingGroup\Working_GeoProc\working.gdb" #&lt;EM&gt;#this is the actual path on arcserver so I have duplicated this directory locally, which seems bonkers to have to do&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;out_path = env.workspace&lt;BR /&gt;arcpy.env.overwriteOutput = True&lt;/P&gt;&lt;P&gt;FC_w_prj=fc = arcpy.GetParameterAsText(0)&lt;BR /&gt;a_list=["try1", "try2", "try3"]&lt;/P&gt;&lt;P&gt;geometry_type = "POINT"&lt;BR /&gt;has_m = "DISABLED"&lt;BR /&gt;has_z = "DISABLED"&lt;BR /&gt;spatial_reference = arcpy.Describe(FC_w_prj).spatialReference&lt;/P&gt;&lt;P&gt;for i in a_list:&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;out_name=i&lt;BR /&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp;arcpy.CreateFeatureclass_management(out_path, out_name, geometry_type, "", has_m, has_z, spatial_reference)&lt;/P&gt;&lt;P&gt;##The above tool publishes successfully but errors out when run on Portal (error000732.png attached)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I have a ticket open with ESRI on this...I have not reached resolution on this....yet&lt;/P&gt;&lt;P&gt;Does my env.workspace need to be a UNC or URL?&lt;/P&gt;&lt;P&gt;&lt;A class="cc_cursor link-titled" href="https://desktop.arcgis.com/en/arcmap/10.6/tools/supplement/pathnames-explained-absolute-relative-unc-and-url.htm#GUID-A1658F9A-FF24-454E-B0BA-55FAB5C3DF4E" title="https://desktop.arcgis.com/en/arcmap/10.6/tools/supplement/pathnames-explained-absolute-relative-unc-and-url.htm#GUID-A1658F9A-FF24-454E-B0BA-55FAB5C3DF4E"&gt;Paths explained: Absolute, relative, UNC, and URL—Help | ArcGIS Desktop&lt;/A&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;INPUT type="hidden" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 07 Jan 2020 23:48:20 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/how-to-publish-gp-service-setting-proper-env/m-p/336329#M26390</guid>
      <dc:creator>ChristopherOneal</dc:creator>
      <dc:date>2020-01-07T23:48:20Z</dc:date>
    </item>
  </channel>
</rss>

