<?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: Run Model with Python, python deletes outputs? in Geoprocessing Questions</title>
    <link>https://community.esri.com/t5/geoprocessing-questions/run-model-with-python-python-deletes-outputs/m-p/1045080#M25409</link>
    <description>&lt;P&gt;I don't think models can be scheduled tasks unless run as python.&lt;BR /&gt;&lt;A href="https://support.esri.com/en/technical-article/000009370" target="_blank"&gt;https://support.esri.com/en/technical-article/000009370&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Apr 2021 15:07:54 GMT</pubDate>
    <dc:creator>JamesHood</dc:creator>
    <dc:date>2021-04-08T15:07:54Z</dc:date>
    <item>
      <title>Run Model with Python, python deletes outputs?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-model-with-python-python-deletes-outputs/m-p/1045039#M25404</link>
      <description>&lt;P&gt;I created a model using ArcMap 10.8&amp;nbsp; and save in toolbox.&amp;nbsp;&lt;BR /&gt;It starts by creating a new&amp;nbsp; FGDB with _TodaysDate variable in the name and saving to local drive.&amp;nbsp;&lt;BR /&gt;Then generates a number of feature classes and saves into GDB.&amp;nbsp;&lt;BR /&gt;Then using those intermediate outputs, appends data to SDE feature classes.&amp;nbsp;&lt;BR /&gt;That is it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The model does not have any delete functionality (except delete features on some SDE feature classes that are being appended to).&lt;/P&gt;&lt;P&gt;The model runs successfully in model builder edit mode, including the updates to SDE, and the creation of FGDB and all the intermediate Feature classes inside.&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I run the model from Python 2.7 it runs successfully and updates the SDE&amp;nbsp; but the feature classes inside the FGDB get deleted before python finishes executing.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The FGDB does not get deleted.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;The only thing the python does is&amp;nbsp; is execute the model and then email me to tell me about it.&amp;nbsp; &amp;nbsp;No deleting is programmed.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;What could be causing the feature classes to get deleted after the append which is the last step in the model?&amp;nbsp; &amp;nbsp;&lt;/P&gt;&lt;P&gt;Any Thoughts?&lt;BR /&gt;&lt;BR /&gt;Edit to add relevant code from python:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;#model update
m1 = "m1 not complete "
m2 = "m2 not complete "
try:

    tbx = arcpy.AddToolbox(r"E:/toolboxpath/toolbox.tbx")
    print tbx
    print "model update started"

    tbx.PRODNS()
    m1 = "m1 Complete"
    tbx.PRODSAO()
    m2 = "m2 Complete"
    print "model update complete"
    
    send_email('not_my_real_email@fakeemail.fake',
           'CENSUS DATA UPDATED',
           'CENSUS DATA UPDATED BOTH MODELS', 
           '')

except arcpy.ExecuteError:
    message = str(m1 + m2 + arcpy.GetMessages(2))
    print(arcpy.GetMessages(2))
    send_email('not_my_real_email@fakeemail.fake',
           'FAILED CENSUS UPDATE FAILED',
           message, 
           '')&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 14:23:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-model-with-python-python-deletes-outputs/m-p/1045039#M25404</guid>
      <dc:creator>JamesHood</dc:creator>
      <dc:date>2021-04-08T14:23:28Z</dc:date>
    </item>
    <item>
      <title>Re: Run Model with Python, python deletes outputs?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-model-with-python-python-deletes-outputs/m-p/1045049#M25406</link>
      <description>&lt;P&gt;Did you&amp;nbsp; do the model to python conversion?&amp;nbsp; Sometimes that will goof on you..&amp;nbsp; Perhaps you could post your code using the Insert/Edit Code Sample button after expanding the tool bar above.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 14:13:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-model-with-python-python-deletes-outputs/m-p/1045049#M25406</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-04-08T14:13:17Z</dc:date>
    </item>
    <item>
      <title>Re: Run Model with Python, python deletes outputs?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-model-with-python-python-deletes-outputs/m-p/1045051#M25407</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I did not convert model to python, just executing model from python as a means to run as a scheduled task.&amp;nbsp;&lt;BR /&gt;I added the relevant python code but I don't think that's the source of the problem because it doesn't do much.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;James&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 14:25:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-model-with-python-python-deletes-outputs/m-p/1045051#M25407</guid>
      <dc:creator>JamesHood</dc:creator>
      <dc:date>2021-04-08T14:25:13Z</dc:date>
    </item>
    <item>
      <title>Re: Run Model with Python, python deletes outputs?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-model-with-python-python-deletes-outputs/m-p/1045056#M25408</link>
      <description>&lt;P&gt;Can't you just run the model as a scheduled task without python calling it?&amp;nbsp; I don't do models, just python so I don't know why it would clobber your model output.&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 14:29:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-model-with-python-python-deletes-outputs/m-p/1045056#M25408</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-04-08T14:29:03Z</dc:date>
    </item>
    <item>
      <title>Re: Run Model with Python, python deletes outputs?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-model-with-python-python-deletes-outputs/m-p/1045080#M25409</link>
      <description>&lt;P&gt;I don't think models can be scheduled tasks unless run as python.&lt;BR /&gt;&lt;A href="https://support.esri.com/en/technical-article/000009370" target="_blank"&gt;https://support.esri.com/en/technical-article/000009370&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Thanks for your help.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 15:07:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-model-with-python-python-deletes-outputs/m-p/1045080#M25409</guid>
      <dc:creator>JamesHood</dc:creator>
      <dc:date>2021-04-08T15:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Run Model with Python, python deletes outputs?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-model-with-python-python-deletes-outputs/m-p/1045086#M25410</link>
      <description>&lt;P&gt;Just goes to show what I know about using models...&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 15:21:39 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-model-with-python-python-deletes-outputs/m-p/1045086#M25410</guid>
      <dc:creator>JoeBorgione</dc:creator>
      <dc:date>2021-04-08T15:21:39Z</dc:date>
    </item>
    <item>
      <title>Re: Run Model with Python, python deletes outputs?</title>
      <link>https://community.esri.com/t5/geoprocessing-questions/run-model-with-python-python-deletes-outputs/m-p/1045172#M25411</link>
      <description>&lt;P&gt;It turns out thanks to ESRI support, that the issue is in Model Builder, each output has a parameter that marks it as "Intermediate" or not.&amp;nbsp; When checked the model deletes the intermediate at conclusion of the model.&amp;nbsp;&lt;BR /&gt;This does not apply if running the model within Model Builder, but does apply if executing the model outside of Model Builder such as with python.&amp;nbsp; &amp;nbsp;Right click the output of the tool and uncheck "Intermediate" to turn this off.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://desktop.arcgis.com/en/arcmap/latest/analyze/modelbuilder/preserving-intermediate-data.htm" target="_blank"&gt;https://desktop.arcgis.com/en/arcmap/latest/analyze/modelbuilder/preserving-intermediate-data.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Apr 2021 17:54:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/geoprocessing-questions/run-model-with-python-python-deletes-outputs/m-p/1045172#M25411</guid>
      <dc:creator>JamesHood</dc:creator>
      <dc:date>2021-04-08T17:54:07Z</dc:date>
    </item>
  </channel>
</rss>

