<?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: Python Toolbox: Only validate when you press run? in Python Questions</title>
    <link>https://community.esri.com/t5/python-questions/python-toolbox-only-validate-when-you-press-run/m-p/1541901#M72924</link>
    <description>&lt;P&gt;You can just rename your validation function so it's not called in the validation loop and run it at the top of your execute function, something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import time

class Tool:
    
    ... # other methods
    
    def validateParameters(self, parameters):
        # Expensive validation goes here
        time.sleep(5)
        
        # Randomly fail validation
        if time.time() % 2 == 0:
            arcpy.AddError("Validation failed")
            return False
        
        arcpy.AddMessage("Validation complete")
        return True
    
    def execute(self, parameters, messages):
        # Expensive execution goes here (after run)
        if not self.validateParameters(parameters):
            arcpy.AddError("Validation failed")
            return
        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Sep 2024 13:41:17 GMT</pubDate>
    <dc:creator>HaydenWelch</dc:creator>
    <dc:date>2024-09-24T13:41:17Z</dc:date>
    <item>
      <title>Python Toolbox: Only validate when you press run?</title>
      <link>https://community.esri.com/t5/python-questions/python-toolbox-only-validate-when-you-press-run/m-p/1539655#M72888</link>
      <description>&lt;P&gt;I'm running into an issue where the standard validation is just taking waaaay too long (Describing the input) and I really just need it to validate when I press Run, not beforehand.&lt;/P&gt;&lt;P&gt;That is, if there's an error, only tell me when I press Run.&lt;/P&gt;&lt;P&gt;Has anyone figured out a way to do this?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 17 Sep 2024 18:58:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-toolbox-only-validate-when-you-press-run/m-p/1539655#M72888</guid>
      <dc:creator>AlfredBaldenweck</dc:creator>
      <dc:date>2024-09-17T18:58:31Z</dc:date>
    </item>
    <item>
      <title>Re: Python Toolbox: Only validate when you press run?</title>
      <link>https://community.esri.com/t5/python-questions/python-toolbox-only-validate-when-you-press-run/m-p/1541901#M72924</link>
      <description>&lt;P&gt;You can just rename your validation function so it's not called in the validation loop and run it at the top of your execute function, something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;import arcpy
import time

class Tool:
    
    ... # other methods
    
    def validateParameters(self, parameters):
        # Expensive validation goes here
        time.sleep(5)
        
        # Randomly fail validation
        if time.time() % 2 == 0:
            arcpy.AddError("Validation failed")
            return False
        
        arcpy.AddMessage("Validation complete")
        return True
    
    def execute(self, parameters, messages):
        # Expensive execution goes here (after run)
        if not self.validateParameters(parameters):
            arcpy.AddError("Validation failed")
            return
        return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Sep 2024 13:41:17 GMT</pubDate>
      <guid>https://community.esri.com/t5/python-questions/python-toolbox-only-validate-when-you-press-run/m-p/1541901#M72924</guid>
      <dc:creator>HaydenWelch</dc:creator>
      <dc:date>2024-09-24T13:41:17Z</dc:date>
    </item>
  </channel>
</rss>

