mik icon indicating copy to clipboard operation
mik copied to clipboard

Add post-completion hooks

Open mjordan opened this issue 9 years ago • 10 comments

It would be useful to be able to fire one or more scripts just before MIK stops executing. Some use cases are to send an email when the job completes, to run QA scripts on all the output, or to copy/Bag MIK's output.

One way of implementing this would be using register_shutdown_function(), having the hook scripts run as background processes.

mjordan avatar Feb 02 '16 17:02 mjordan

Related issue: https://github.com/MarcusBarnes/mik/issues/148.

mjordan avatar Feb 02 '16 17:02 mjordan

Here's a use case for this kind of functionality. Specifically, I'd like to see an option to clear the temp_directory after the run. Here's why:

I’ve got 11 different CSV files to process. The first runs through MIK smoothly. But for all subsequent runs, despite MIK correctly finding the desired CSV, MIK spits out XML and PDFs as if it were reading the first CSV.

This happens because of the temp_directory: If the “metadata” files aren’t cleared from the temp_directory first, MIK just reads those files instead of reading the new CSV.

An option to clear out the temp_directory would make multiple consecutive runs much simpler.

bondjimbond avatar Nov 23 '16 21:11 bondjimbond

We could provide a standard script to clear out the temp directory. All you'd need to do is enable/disable the script in the [WRITER] section of your .ini file.

mjordan avatar Nov 23 '16 21:11 mjordan

Further to @mjordan's comment, such as script would also make a nice example (while still being useful).

MarcusBarnes avatar Nov 23 '16 21:11 MarcusBarnes

@MarcusBarnes I'd like to pursue adding a register_shutdown_function() to mik which would loop through all registered scripts. What do you think? We could register them in [WRITER] shutdownhooks[] entries. Any objections? Might not get to it until the weekend.

mjordan avatar Nov 23 '16 21:11 mjordan

@mjordan Sounds like a good approach to explore. Thank you.

MarcusBarnes avatar Nov 23 '16 21:11 MarcusBarnes

I said the weekend, but I need to put https://github.com/MarcusBarnes/mik/issues/293 to bed first.

mjordan avatar Nov 23 '16 21:11 mjordan

#188 may offer another potential use case.

mjordan avatar Nov 25 '16 21:11 mjordan

First version of the wiki docs at https://github.com/MarcusBarnes/mik/wiki/Shutdown-hooks. Please take a look.

mjordan avatar Mar 23 '17 22:03 mjordan

@mjordan I added a comment about the wiki here https://github.com/MarcusBarnes/mik/issues/354

jpeak5 avatar Mar 24 '17 22:03 jpeak5