This is a thread to address a couple of different conversation points regarding event handling. To pre-summarize, the two items I’d like to discuss are 1) extension of the DeadlinePlugin class to include event handling callbacks and functionality, and 2) consolidation of APIs and execution models between the EventListener and DeadlinePlugin classes
DeadlinePlugin event extensions
I really like the idea of adding event slots to the plugin classes directly. This would make it possible to give certain job types special (additional) event handling, without having to bloat up the global event system (listeners being loaded unnecessarily, etc.). Additionally, it would make more sense from a job class-centric perspective, and I think it would help make the plugin API more appealing and functional to those interested in doing heavy development.
The plugin class is already loaded, so there would be no need to rebuild a suitable environment (though this could be done if someone wanted to), and in the case of things like jobDone or taskDone events, contextual information could easily be passed between the execution environment and the event handler methods. Also, I would say that these event handler methods should be suppresed separately from the EventListener handling at the job level. In other words, allow all of the generic EventListener plugins to be suppressed for the job without affecting its plugin’s event handling methods.
Now, there’s obviously a case to be made for keeping the current EventListener paradigm, so I’m not suggesting it should be removed. However, I think event handler methods at the plugin level would make things a lot easier when writing custom plugins.
Our Deadline usage pattern is an example of a situation in which the current EventListener model becomes a little clumsy. We run all of our jobs through one custom plugin currently, and our internal render stack and jobs (which are abstracted away from whatever queue they’re executed on) have their own slots for things like jobStart, jobTask jobDone, jobDelete, etc (tasks are just another callback type). Mapping these to Deadline’s events has proven to be a little bit painful because the job tasks and the other event types all need to run in the same environment (that is, an environment containing the same information, not the same instance of the environment). Thus, there is code that is largely duplicated between the two, except where differences are required because of the interface divergence (more on that below).
Shared API and execution consolidation
Right now, the execution models for plugins, event listeners, and scripts are very different. Leaving scripts aside, as they can fill many different roles, it seems like there has to be some room for consolidation between the EventListener and Plugin classes.
Some notes based on our current usage:
- Our job process needs a temporary directory. On the plugin class, this is easy. On the EventListener class, I have to manage my own temporary directories using Python.
- Changes to our job event process obviously require much more work to propagate. Many times it seems like things need to be reloaded to pick up the latest changes to EventListener classes.
- Because jobs can specify a custom plugin directory to use, I’m able to use different versions of our job plugin across different code release branches. It’s not the prettiest solution, but in lieu of a complete slave environment refresh between jobs (fingers still crossed on that one…), it works. However, there is no way to adapt this same approach to the EventListener (believe me, I’ve tried…)
As far as the API goes, if the first request were to be implemented, it seems like it would make a lot of sense to do it by adding an EventHandler class that both the EventListener and DeadlinePlugin classes inherited to provide a common event handling interface.
Anyway, I know this is a lot, but I’d appreciate any thoughts on any of this.