Executing script once before job starts

Hi,

I’ve written a custom plugin. It’s a simple plugin (i.e. self.PluginType = PluginType.Simple) and it operates on frames (self.SingleFramesOnly = False )

The plugin writes frames on disk, but I would like to first erase the contents of the folder in which the plugin is writing the images.

So I need to find a way to execute a method once when the job starts, in other words, I don’t want this method to be excecuted by each worker picking up a chunk of frames to process

I’ve been trying with PreRenderTasks in the custom plugin, and I’ve also tried with a JobPreload.py. In both cases, this will be executed by each worker.

Is there a way to do this ? In the last resort, I could implement something in my custom event plugin that spawns the custom plugin job (but I would prefer to do this at the plugin level)

Thanks

The only way I can think to have a method fire once per job would be in a prejob script. Everything else is going to be run by a Worker when it picks up the task.

You could use the StartJob callback and add a check to be sure you’re not overwriting the current job’s output. You could put the render output into a folder named with the job ID or something similar.

Thanks @Justin_B I’ll try the prejob script way. I was not aware of that feature

Regards

2 Likes