mrc-ide / queuer

:walking::walking::walking: Prototype general queue
https://mrc-ide.github.io/queuer
Other
4 stars 1 forks source link

notify on job completion #25

Open richfitz opened 5 years ago

richfitz commented 5 years ago

Either server side or client side ideally (client side is after wait, server side on job completion).

Implement with callbacks for extensibility

Ideas include

jameshay218 commented 5 years ago

I have found slackr to be relatively easy to setup and to have great, flexible functionality. You just need to create a slack app (with the correct permissions) which gives you an API token. I then just have something like this in my cluster function arguments:

message_slack_pars=list(api_token=XXXXXXXXX,
                                          channel="#result_notification",
                                          username="tmp",
                                          message_freq=1000)

And this in the function body:

if(message_slack){
        message_slack_pars$username <- username
        slackr::slackrSetup(api_token=message_slack_pars$api_token,
                            channel=message_slack_pars$channel,
                            username=message_slack_pars$username)
        Sys.sleep(runif(1))
        slackr::text_slackr(paste0("Starting job ", runName,"_",chainNo))
    }

Upon completion:

if(message_slack){
        text_slackr(completion_message,
                    channel="@james",
                    username=message_slack_pars$username)
        if(!is.null(res$p_slack)){
            ggslackr(res$p_slack,channel="@james")
        }
    }