<?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 Re: Error publishing gp model with python script as a service in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/error-publishing-gp-model-with-python-script-as-a/m-p/592994#M46479</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you tried using %ScratchWorkspace%\Output.dbf for your output file?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You'd probably need to set that in the model as the default output and get it as text in the script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Jul 2012 06:40:50 GMT</pubDate>
    <dc:creator>BenHolmes</dc:creator>
    <dc:date>2012-07-05T06:40:50Z</dc:date>
    <item>
      <title>Error publishing gp model with python script as a service</title>
      <link>https://community.esri.com/t5/python-questions/error-publishing-gp-model-with-python-script-as-a/m-p/592993#M46478</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Hi,&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm attempting to publish a toolbox to ArcGIS Server. The toolbox contains a model and a custom python script. The model calls the script. It runs fine in the desktop but when I publish as a service I'm given a code 500 Error Executing Task. Error executing tool. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My model takes a featureset as a parameter which can have different fields each time. My end goal is to run an intersect against this featureset and add up the values of a field for all intersecting features. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My model works as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Make a feature layer from the featureset -&amp;gt; select features that intersect with another layer -&amp;gt; save the selection to my scratchworkspace &amp;gt; run summary statistics using my python script&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I need the script because I don't know what the field is going to be called. The field name is also a parameter to the model. My script does the following:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Input_features = arcpy.GetParameterAsText(0)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Input_metric = arcpy.GetParameterAsText(1)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Output_table = "GetFieldValue.dbf"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.Statistics_analysis(Input_features, Output_table, [[Input_metric, "SUM"]])&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; arcpy.SetParameterAsText(1, Output_table)&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;As i say this works fun in ArcGIS desktop. My script has 3 parameters:&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Input_features - FeatureSet&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Input_metric - String&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Output_table - Table or String - fails either way!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I'm dubious about this last output as appreciate I declare Output_table as a string above. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Anyhow, I publish the whole lot storing relative path names for both model and script. I set it to run synchronously and to run python script in progress. &lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;My js code calls the service as follows:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; var metric = "METRIC_1"&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt; // setup params and execute&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; var params = {&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; "Buffers" : bufferFeatureSet,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; "Metrics" : metricsFeatureSet,&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;&amp;nbsp; "Input_metric": metric&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; };&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt; gpIntersects.execute(params, handleGpIntersectSuccess, handleQueryError);&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;I land at handleQueryError every time!&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;Has anyone got any suggestions or advice as I'm struggling....&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jul 2012 19:05:08 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-publishing-gp-model-with-python-script-as-a/m-p/592993#M46478</guid>
      <dc:creator>deleted-user-VeZur_n9o0OZ</dc:creator>
      <dc:date>2012-07-04T19:05:08Z</dc:date>
    </item>
    <item>
      <title>Re: Error publishing gp model with python script as a service</title>
      <link>https://community.esri.com/t5/python-questions/error-publishing-gp-model-with-python-script-as-a/m-p/592994#M46479</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;Have you tried using %ScratchWorkspace%\Output.dbf for your output file?&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;You'd probably need to set that in the model as the default output and get it as text in the script.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jul 2012 06:40:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/error-publishing-gp-model-with-python-script-as-a/m-p/592994#M46479</guid>
      <dc:creator>BenHolmes</dc:creator>
      <dc:date>2012-07-05T06:40:50Z</dc:date>
    </item>
  </channel>
</rss>

