AnsweredAssumed Answered

How do you reload a module imported into a Python Toolbox?

Question asked by Hornbydd on Jan 23, 2014
Latest reply on Oct 23, 2014 by MartinHvidberg

Python Gurus,


I have downloaded the Spatial Analyst Supplemental Tools which is a Python Toolbox and there appears to be a bug in the Peak tool. I know a little bit of Python and thought I would have a crack at debugging it, primarily to teach myself how to use a Python toolbox. I am use to creating python script tools but not a Python toolbox.


Anyway every time I tweak the code in the Peak tool and try to run it, it's as if the tool has been cached and none of my tweaks run. I looked at help and found this page and in the tip section it talks about imported modules needing reloading. I think this is my problem none of my changes are being refreshed. But the import statement is "from peaktool import Peak". If I type reload(peaktool) it says "name 'peaktool' is not defined". So the help page gives advice but does not explicity show you how to do it!


So my question is how do you reload a module when the importing of it is in the format of "from peaktool import Peak" and where would one put the reload statement in the code? Below is the Python toolbox code.



import sys
import os
import arcpy
myScripts = os.path.join(os.path.dirname(__file__), "Scripts")
from dendrogrampdf import CreateDendrogram
from viewshedalongpath import ViewshedAlongPath
from maxelevation import MaximumUpstreamElevation
from drawsig import DrawSignatures
from filledcontours import FilledContours
from peaktool import Peak
from eraserastervalues import EraseRasterValues
from zonalstatisticsastable02 import ZonalStatisticsAsTable02
from tabulatearea02 import TabulateArea02
class Toolbox(object):    
    def __init__(self):        
        """Define the toolbox (the name of the toolbox is the name of the .pyt file)."""
        self.label = "Spatial Analyst Supplemental Tools"
        self.alias = "sas"        
        # List of tool classes associated with this toolbox        = [CreateDendrogram, DrawSignatures, ViewshedAlongPath,MaximumUpstreamElevation, FilledContours, Peak, EraseRasterValues,ZonalStatisticsAsTable02,TabulateArea02]



Peak is a Class in the peaktools module.