Esri / solutions-geoprocessing-toolbox

Models, scripts, and tools for use in ArcGIS Desktop and Server to support defense and intelligence workflows.
Apache License 2.0
133 stars 67 forks source link

Create GRG from Point tool error handling - catch and handle case where no point dropped. #646

Closed BobBooth closed 6 years ago

BobBooth commented 6 years ago

Using the Create GRG from Point tool included in the Clearing Operations template, I saw an issue with Pro 2.1 where the tool seemed to be failing due to a bug. Turns out that it was user error, I had somehow not dropped a point for the start point. Input Start Location is a required field, image

but the tool will run without an actual point having been dropped. The error message is: Messages Start Time: Thursday, January 11, 2018 11:38:25 AM Running script CreateGRGFromPoint... App environment: ARCGIS_PRO PYTHON ERRORS: Traceback info: File "C:\Users\XYZ\Documents\ArcGIS\Projects\Pro_2_1_CLROPS_Test\scripts\GRGUtilities.py", line 697, in GRGFromPoint rightCorner = float(pointExtents[0]) + ((float(cellWidth) * float(numberCellsVert)) /2.0)

Error Info: could not convert string to float: 'None' ArcPy ERRORS: Start Time: Thursday, January 11, 2018 11:36:17 AM Succeeded at Thursday, January 11, 2018 11:36:17 AM (Elapsed Time: 0.01 seconds) Completed script Create GRG from Point... Failed to execute (CreateGRGFromPoint). Failed at Thursday, January 11, 2018 11:38:27 AM (Elapsed Time: 1.60 seconds)

I think the solution to this could be better error handling in the Py script to detect whether or not a single point actually exists in the input feature class, and to fail gracefully with a message indicating that a point feature input is required when this happens.

Steps to Reproduce (for bugs)

  1. Run the Create GRG from Point tool, entering all parameters, drop an input point.
  2. Tool runs correctly, creates grid.
  3. Run the tool again, enter all parameters but don't drop an input point.
  4. Get error.

Your Environment

Pro 2.1 10257/ latest released Clearing Operations template Windows 8.1 Enterprise

adgiles commented 6 years ago

Addressed in PR #655

Added a check to see if input feature class contains any features.

Shouldn't affect any of the automated tests, remove labels

BobBooth commented 6 years ago

@adgiles - I just grabbed the ClearingOperationsTools.pyt from the solutions-geoprocessing-toolbox repo and tested this: still seeing: Start Time: Thursday, February 1, 2018 11:33:07 AM Running script CreateGRGFromPoint... App environment: ARCGIS_PRO ImagePYTHON ERRORS:Traceback info: File "C:\Users\XYZ\Documents\ArcGIS\Projects\TestClrops\scripts\GRGUtilities.py", line 697, in GRGFromPoint rightCorner = float(pointExtents[0]) + ((float(cellWidth) * float(numberCellsVert)) /2.0)Error Info:could not convert string to float: 'None' ImageArcPy ERRORS:Start Time: Thursday, February 1, 2018 11:32:53 AMSucceeded at Thursday, February 1, 2018 11:32:53 AM (Elapsed Time: 0.01 seconds) Completed script Create GRG from Point... ImageFailed to execute (CreateGRGFromPoint). Failed at Thursday, February 1, 2018 11:33:07 AM (Elapsed Time: 0.34 seconds)

adgiles commented 6 years ago

@bbooth Are you sure you have got the lastest, as the line:

rightCorner = float(pointExtents[0]) + ((float(cellWidth) * float(numberCellsVert)) /2.0)

is now on 718 not 697

BobBooth commented 6 years ago

@adgiles - yes

adgiles commented 6 years ago

@bbooth when you say you grabbed ClearingOperationsTools.pyt did you also grab the rest of the files?

BobBooth commented 6 years ago

@adgiles - yes image image

adgiles commented 6 years ago

@BobBooth Pro must be caching something as the tool should look like this:

capture

And this would be the error

capture

BobBooth commented 6 years ago

Huh, that is odd. @adgiles I added the toolbox to a blank project. Maybe the presence of the pycache file? image

BobBooth commented 6 years ago

@adgiles - I think that was it. I deleted the pycache folder, re-added the tool to a new Pro project, and I see the new UI: image Guess the pycache folders should not live in the solutions gp repo...

BobBooth commented 6 years ago

Using the new tool, I confirm that this is fixed.