Bring back full arcpy.GetMessages() messages in ArcGIS Pro!

529
4
05-28-2019 10:10 AM
Status: Open
Labels (1)
Regular Contributor III

In Desktop, the arcpy.GetMessages() function generally returned full and useful geoprocessing tool information. However, in Pro (currently at 2.3.3) GetMessages() now generally only returns start/end/elapsed time (!?!?!). ESRI: Please bring back the full geoprocessing message! Many of us record extensive log files for the purposes of debugging and performance monitoring and testing. The messages retuned in Pro now don't even have the tool name any more! As a GIS Programmer/Analyst with 20+ years experience in geoprocessing automation, I find this pretty disappointing.

In Desktop (v10.7 and before)

>>> arcpy.Select_analysis(blah, blah)

>>> arcpy.GetMessages()

Executing: Select E:\lidar_derivatives\processing_data\rs_hydro_processing\fishnet.shp

E:\lidar_derivatives\processing_data\rs_hydro_processing\tile_479\tile_479.gdb\tile_479 "TILE_ID = 479"

Start Time: Sat May 18 09:38:56 2019

Succeeded at Sat May 18 09:38:58 2019 (Elapsed Time: 1.47 seconds)

 

But now in Pro:

>>> arcpy.Select_analysis(blah, blah)

>>> arcpy.GetMessages()

Start Time: Friday, May 24, 2019 2:35:35 PM

Succeeded at Friday, May 24, 2019 2:35:37 PM (Elapsed Time: 1.47 seconds)

4 Comments

I came here just to write this. Thanks. Having useful logging messages that come directly from the tool is critical. 

by Anonymous User

I completely agree. I have several scripts where geoprocessing tool messages returned are critical as a means to see progress and troubleshoot issues, in addition to standard exception tracking. In cases where this is very important, I find myself writing extra code to provide the user the name of the tool and sometimes the parameters. All of this detailed information used to automatically be returned with the geoprocessing messages. 

There is also the result object but using it adds too much scaffolding for my taste. It adds a cognitive load to understanding what a piece of code is actually about. I want to focus on the gp tool, not handling the messages from it.

So instead of:

import arcpy
results
= []

results.append(arcpy.SomeTool_toolbox(some_input))
results.append(arcpy.AnotherTool_toolbox(some_input))
results.append(arcpy.DifferentTool_toolbox(some_input))

for
result in results:
    print(result.getMessage(result.messageCount-1))

How about something like:

import arcpy
result = results.start_logging()

arcpy.SomeTool_toolbox(some_input)
arcpy.AnotherTool_toolbox(some_input)
arcpy.DifferentTool_toolbox(some_input)

print(result.getMessages())

Example found by way of user2856 in arcpy - Using for loop to print last messages from multiple processes? - Geographic Information Syst... 

Has this been fixed or is there a workaround?  I'm trying to move away from ArcMap to Pro, but there are all these little things that are holding me back.