I would like to be able to put each tool in a Python toolbox in its own file. This way I don't end up with a huge and hard to manage .pyt file if the toolbox contains a lot of tools. Right now I can write other modules and use them in the tool's execute method, which definitely helps, but putting the entire tool in its own file would be a lot better.
I was thinking that maybe a Python toolbox could be a folder that contained all of the required files, kind of like a file geodatabase.
Thank you for submitting your idea to break out individual tools in a .pyt into separate files. We appreciate your suggestion and the time you took to provide detailed feedback. The recommended way to separate individual tool logic from your Python Toolbox code is to place the tool logic in separate modules and import these in your .pyt (as described by in Dave and Luke's previous responses).
I do think that the implementation I've shown in pytframe2 is a good iteration on the code shown here. Utilizing module reloading and a more agnostic import system that relies not on import statements, but on a configuration dictionary.
Only adding a comment here to raise some awareness on similar solutions and hopefully gather similar ideas into one solution.
Yes, thanks, some users viewing this idea may find it helpful
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.