<?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: See individual commands from script in history in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1146845#M63849</link>
    <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/2.8/arcpy/functions/getmessages.htm" target="_blank"&gt;GetMessages—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

fc = arcpy.GetParameterAsText(0)
arcpy.GetCount_management(fc)

# Print all of the geoprocessing messages returned by the
#  last tool (GetCount)
print(arcpy.GetMessages())
arcpy.AddMessage(arcpy.GetMessages())&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 23 Feb 2022 07:31:50 GMT</pubDate>
    <dc:creator>JohannesLindner</dc:creator>
    <dc:date>2022-02-23T07:31:50Z</dc:date>
    <item>
      <title>See individual commands from script in history</title>
      <link>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1146840#M63848</link>
      <description>&lt;P&gt;I am running a python script as a tool in Pro.&lt;/P&gt;&lt;P&gt;The tool runs many gp commands (with some other arcpy functions) and take some time.&lt;/P&gt;&lt;P&gt;In order to understand where time is spend it would be nice if I can see the&amp;nbsp;individual gp tools in the history (with the time it took them to run). This way I do not have to put endless time messages in my code.&lt;/P&gt;&lt;P&gt;I could not find a way to do it.&lt;/P&gt;&lt;P&gt;Is there a way or I should put it in the ideas site?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 06:29:52 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1146840#M63848</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2022-02-23T06:29:52Z</dc:date>
    </item>
    <item>
      <title>Re: See individual commands from script in history</title>
      <link>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1146845#M63849</link>
      <description>&lt;P&gt;&lt;A href="https://pro.arcgis.com/en/pro-app/2.8/arcpy/functions/getmessages.htm" target="_blank"&gt;GetMessages—ArcGIS Pro | Documentation&lt;/A&gt;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy

fc = arcpy.GetParameterAsText(0)
arcpy.GetCount_management(fc)

# Print all of the geoprocessing messages returned by the
#  last tool (GetCount)
print(arcpy.GetMessages())
arcpy.AddMessage(arcpy.GetMessages())&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 23 Feb 2022 07:31:50 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1146845#M63849</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-02-23T07:31:50Z</dc:date>
    </item>
    <item>
      <title>Re: See individual commands from script in history</title>
      <link>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1146947#M63850</link>
      <description>&lt;P&gt;One of us do not understand the other...&lt;/P&gt;&lt;P&gt;I have a script (just an example):&lt;/P&gt;&lt;P&gt;buffer(fc1,fcbuf1,15)&lt;/P&gt;&lt;P&gt;buffer(fc2,fcbuf2, 22)&lt;/P&gt;&lt;P&gt;buffer(fc3,fcbuf3,31)&lt;/P&gt;&lt;P&gt;It takes 10 minutes to run.&lt;/P&gt;&lt;P&gt;I would like to see in history 3 different entries, one for each buffer command so I know how the 10 minutes split between the different gp tools.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 14:29:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1146947#M63850</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2022-02-23T14:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: See individual commands from script in history</title>
      <link>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1146966#M63851</link>
      <description>&lt;P&gt;So you want to see the tools in the geoprocessing history? This is already the case (at least for me):&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;go to the geoprocessing history&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_0-1645627818811.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/34734iD0436310DB474950/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_0-1645627818811.png" alt="JohannesLindner_0-1645627818811.png" /&gt;&lt;/span&gt;&lt;/LI&gt;&lt;LI&gt;Hovering over the completed tools should give you a window with the tool's parameters, environment, messages and elapsed time:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="JohannesLindner_1-1645628043259.png" style="width: 400px;"&gt;&lt;img src="https://community.esri.com/t5/image/serverpage/image-id/34736i099F49864E32D765/image-size/medium?v=v2&amp;amp;px=400" role="button" title="JohannesLindner_1-1645628043259.png" alt="JohannesLindner_1-1645628043259.png" /&gt;&lt;/span&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;This works for both scripts and custom tools (python toolbox, haven't tested script tools).&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code snippet gets the log messages of the tool you ran last (which should include start time, end time, elapsed time, warnings, and errors) and prints them or adds them to your script tool's messages.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Feb 2022 14:57:12 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1146966#M63851</guid>
      <dc:creator>JohannesLindner</dc:creator>
      <dc:date>2022-02-23T14:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: See individual commands from script in history</title>
      <link>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1146969#M63852</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;If I understand right you need code like this:&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import time

start_time = time.time()
buffer(fc1,fcbuf1,15)
elapsed_time = time.time() - start_time
arcpy.AddMessage(time.strftime("First operation elapsed %H:%M:%S", time.gmtime(elapsed_time)))

start_time = time.time()
buffer(fc2,fcbuf2, 22)
elapsed_time = time.time() - start_time
arcpy.AddMessage(time.strftime("Second operation elapsed %H:%M:%S", time.gmtime(elapsed_time)))

start_time = time.time()
buffer(fc3,fcbuf3,31)
elapsed_time = time.time() - start_time
arcpy.AddMessage(time.strftime("Last operation elapsed %H:%M:%S", time.gmtime(elapsed_time)))&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 23 Feb 2022 15:01:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1146969#M63852</guid>
      <dc:creator>GKmieliauskas</dc:creator>
      <dc:date>2022-02-23T15:01:28Z</dc:date>
    </item>
    <item>
      <title>Re: See individual commands from script in history</title>
      <link>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1147376#M63864</link>
      <description>&lt;P&gt;I don't think you can log individual geoprocessing steps to the geoprocessing history. The closet thing would be logging the execution times to the arcpy message console or a log file.&amp;nbsp; You can get pretty creative with how you set this up to avoid repetitive code. For example, using dictionaries to select and execute a function that is wrapped in a timer function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import time as t
import datetime as dt

bufferDict = {
    'buffer1': lambda: buffer1(fc1,fcbuf1,15),
    'buffer2': lambda: buffer2(fc2,fcbuf2,22),
    'buffer3': lambda: buffer3(fc3,fcbuf3,31)
}

total_time = t.time()

for i in ['buffer1', 'buffer2', 'buffer3']:
    startTime = t.time()
    bufferDict.get(i)()
    arcpy.AddMessage(t.strftime(f'{i} completed in {dt.timedelta(seconds=t.time() - startTime)}'))

arcpy.AddMessage(t.strftime(f'Total time taken: {dt.timedelta(seconds=t.time() - total_time)}'))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;edited to add total time taken&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 02:07:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1147376#M63864</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-02-24T02:07:03Z</dc:date>
    </item>
    <item>
      <title>Re: See individual commands from script in history</title>
      <link>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1147410#M63866</link>
      <description>&lt;P&gt;Don't you think it can be helpful option?&lt;/P&gt;&lt;P&gt;In Pro SDK there is &lt;SPAN class=""&gt;GPExecuteToolFlags&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN class=""&gt;AddToHistory that add each gp tool to history.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;This will save many AddMessage in python (spatially when you have a lot of code that is not just gp tools) and can let you see in history what the real parameters to each tool was.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 05:43:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1147410#M63866</guid>
      <dc:creator>mody_buchbinder</dc:creator>
      <dc:date>2022-02-24T05:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: See individual commands from script in history</title>
      <link>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1147504#M63868</link>
      <description>&lt;P&gt;I think getting that granular would add too much clutter to the history. As &lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/294341"&gt;@JohannesLindner&lt;/a&gt; mentioned, you can currently hover over the task (or right click, view details) and access the messages generated within that task so information is not too far away.&lt;/P&gt;&lt;P&gt;Pro SDK and arcpy serve two different purposes and I think adding two lines of code where you want to capture time throughout a script is a lot more maintainable than extending Pro through the SDK to display individual task parameters ran within a script. The beauty of the SDK is customization and maybe you can create an extension to display what you're after, but aren't you are adding &lt;EM&gt;a lot&lt;/EM&gt; more code in other places to avoid adding redundant lines of code to a script?&lt;/P&gt;&lt;P&gt;You can always ask for it in the ideas board, but I think the answer will be to use AddMessage()&lt;/P&gt;</description>
      <pubDate>Thu, 24 Feb 2022 14:04:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/see-individual-commands-from-script-in-history/m-p/1147504#M63868</guid>
      <dc:creator>Anonymous User</dc:creator>
      <dc:date>2022-02-24T14:04:18Z</dc:date>
    </item>
  </channel>
</rss>

