I really like the ideas behind doit - simple, flexible task definitions. The only bit that seems out of place is stuffing everything into a dictionary to define a task.
I've done a quick branch to allow defining tasks as classes. A class effectively defines a new namespace, and you can put things inside it with an obvious syntax. It also means you don't need magic mechanisms to pass in keyword arguments for e.g. targets - the method can just pull them off 'self'. Here's a couple of example tasks, roughly based on samples in the documentation:
(In the first example, because there is no 'actions' variable defined, the run() method is used as the action)
I haven't done any of the necessary polish - checks, tests, docs, etc. - just the bare minimum to get those examples working. If you're interested in the implementation, see:
https://bitbucket.org/takluyver/doit/commits/75795b93adfdf0a30d6db9c8173d2bfb0470fc53
Is there any interest in taking this further?
Thanks,
Thomas
--
Is there any interest in taking this further?
I had a new idea to allow easy customization on how tasks are defined.
It supports not only "classes" as you proposed but also "decorators" and "objects".
It is still up to the user to define its own way...
but much better than my previous advice to create a custom TaskLoader.
I wrote the details in a blog post: http://blog.schettino72.net/posts/doit-task-creation.html
I would suggest you create an independent module and push it to pypi.
I could add a link to it in main doit docs, and one day doit might
incorporate it...
I was also thinking about creating a task loader to read a file
similar to Makefiles...
> A minor snag I hit while developing this - if you have a class with apatches welcome :)
> create_doit_tasks(self) method, doit will see the class object as well as
> the instances, and try to call Class.create_doit_tasks(), which throws an
> error. Perhaps there's a way to check that the function takes no arguments
> (or one argument, for bound methods), before calling it? You don't really
> want to just catch the error, because that makes debugging harder if there's
> a problem.
> I also don't see any visible output from the simple example of a Python
> function printing, but that's the same for standard tasks. Is outputit is supressed by default. option "verbosity" default to "1", it
> suppressed by default?
should be "2" to display the output.
you can control the overall verbosity and also for individual tasks.
No it doesn't. check the "verbosity" option.
> The options in 'doit help run' suggest that it will
> be shown.