Interpret warnings as warnings instead of errors in Python tools

1371
8
05-27-2022 08:31 AM
Status: Closed
Labels (1)
PhilippNagel1
New Contributor III

When executing a Python script as a custom tool in ArcGIS Pro through a Python toolbox or other means, Python will sometimes emit warning-level messages via warnings.warn or logging.warn. These should be interpreted by ArcGIS Pro as warning-level messages. Instead, Pro sees these as error messages because Python outputs these to sys.stderr. This will cause them to be shown on the wrong list in the tool results, and it will also indicate the tool has failed, even though it completed sucessfully. I've included screenshots showing the behavior in the results, as well as a simple PYT with a tool that will demonstrate this issue. The tool does nothing but print a warning, but Pro still claims that it failed to run.

8 Comments
Luke_Pinner

Good idea. Esri should implement this idea as well as  Make arcpy.AddWarning wrapped in script warnings! - Esri Community

 

 

HildermesJoséMedeirosFilho

To do my test I always turn off warning if it's not doing something meaningful in my tests.
Do like so in your scripts and you will see no fail, after the end.

import warnings
warnings.filterwarnings("ignore")

To turn on again.

warnings.filterwarnings("default")

 

PhilippNagel1

Sure, if you don't want to see warnings that is a possibility. But I would like to be able to use them to warn the user of something that maybe didn't work as expected, even though the tool still completed. In the current scenario, it is not possible to emit warnings (which are displayed in a specific way after the tool completes). The tool will always look like it failed, even though if completed with warnings but no errors.

PhilippNagel1

By the way, this issue is logged as BUG-000149576 with ESRI. This idea was only posted because ESRI requires an idea to be there in order to log a defect now.

HannesZiegler
Status changed to: Under Consideration

We are looking at addressing this bug for the next release. Please keep in mind though, that this doesn't guarantee that it'll be resolved in time for the next release, as there are many other things that require our attention.

KoryKramer
Status changed to: Closed

Sorry for the miscommunication on this @PhilippNagel1 Thank you for mentioning that this had already been submitted as a bug through Technical Support. I read through your comments on that case, and you are absolutely correct - it is certainly not a prerequisite to submit an idea before support can log a bug. In fact, the ArcGIS Ideas Submission Guidelines and Statuses are explicit in stating that ArcGIS Ideas is not for bugs:

KoryKramer_0-1657224057094.png

This issue is being tracked through the bug tracking system and can be found here: https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDE0OTU3Ng== If other Esri Community members encounter this, it is not necessary to call Support. Rather, use the Subscribe button at the link above - this will set you up for notifications as well as increment the count of affected users in the system which helps teams prioritize issues. 

KoryKramer_1-1657224155957.png

Given the above, this idea will be closed. Thank you again, and we apologize for the confusion in communicating around this issue.

PhilippNagel1

@KoryKramer thanks for that reference. I thought this was odd, too, but I was instructed by the ESRI support rep to submit the bug here first. He stated that this was a new workflow and now the only way to submit bugs to ESRI, they had to be in the ideas forum first. Sounds like there is some mis-communication going on between some ESRI departments.

KoryKramer

Just wanted to bump the thread to point out that https://support.esri.com/en/bugs/nimbus/QlVHLTAwMDE0OTU3Ng== is now showing as Fixed in ArcGIS Pro 3.1 (scheduled to be available ~Feb 2023).