-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Monitor failed job runs #165
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is super simple and it works. We could use it as-is, but I'd like to see two more features. Could you add these?
- Add the ability to pass optional arguments to an etl.
- implement the same functionality in the existing render_report.R and its copy in the study_template
etl/run_etl.R
Outdated
set_script_run_time() | ||
|
||
parser <- ArgumentParser() | ||
parser$add_argument("script_name", nargs=1, help="Script to be run") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you allow for optional parameters? it's quite rare but we do pass an argument to one of out ETLs in the rcc.ctsit repo
etl/run_etl.R
Outdated
} | ||
|
||
tryCatch({ | ||
rscript(script_name, stderr = "log.txt") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...and then use the arguments here?
Here's some example code I wrote to test a different way of specifying the optional arguments to the script called by library(argparse)
parser <- ArgumentParser()
parser$add_argument("file", nargs = 1, help = "RScript to be run")
parser$add_argument("optional_args", nargs='+', help = "optional arguments to the script to be run")
args <- parser$parse_args()
paste0("The first argument, file, has a value of '", args$file, "'")
paste0("The optional arguments that follow are '", paste(args$optional_args, collapse = " "), "'") Could you revise |
I don't understand this change?
Also, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made some suggestions.
We'll make changes to render_report.R
later after the rcc.grace PR is finished.
etl/run_etl.R
Outdated
parser$add_argument("--optional_args", nargs='*', help="Zero or more optional arguments of any type") | ||
|
||
if (!interactive()) { | ||
args <- parser$parse_args() | ||
} else { | ||
args <- parser$parse_args( | ||
c( | ||
"study_template/etl/test_failure_alert.R", | ||
"--optional_args", | ||
"test", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parser$add_argument("--optional_args", nargs='*', help="Zero or more optional arguments of any type") | |
if (!interactive()) { | |
args <- parser$parse_args() | |
} else { | |
args <- parser$parse_args( | |
c( | |
"study_template/etl/test_failure_alert.R", | |
"--optional_args", | |
"test", | |
parser$add_argument("optional_args", nargs='*', help="Zero or more optional arguments of any type") | |
if (!interactive()) { | |
args <- parser$parse_args() | |
} else { | |
args <- parser$parse_args( | |
c( | |
"study_template/etl/test_failure_alert.R", | |
"test", |
# Test email alert on script failure | ||
0 0 1 * * root /usr/bin/docker run --rm --env-file /rcc/study_template/.env rcc.site Rscript etl/run_etl.R etl/test_failure_alert.R --optional_args test "another test" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# Test email alert on script failure | |
0 0 1 * * root /usr/bin/docker run --rm --env-file /rcc/study_template/.env rcc.site Rscript etl/run_etl.R etl/test_failure_alert.R --optional_args test "another test" | |
# Test email alert on script failure | |
0 0 1 * * root /usr/bin/docker run --rm --env-file /rcc/study_template/.env rcc.site Rscript etl/run_etl.R etl/test_failure_alert.R test "another test" |
study_template/etl/run_etl.R
Outdated
parser$add_argument("--optional_args", nargs='*', help="Zero or more optional arguments of any type") | ||
|
||
if (!interactive()) { | ||
args <- parser$parse_args() | ||
} else { | ||
args <- parser$parse_args( | ||
c( | ||
"study_template/etl/test_failure_alert.R", | ||
"--optional_args", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parser$add_argument("--optional_args", nargs='*', help="Zero or more optional arguments of any type") | |
if (!interactive()) { | |
args <- parser$parse_args() | |
} else { | |
args <- parser$parse_args( | |
c( | |
"study_template/etl/test_failure_alert.R", | |
"--optional_args", | |
parser$add_argument("optional_args", nargs='*', help="Zero or more optional arguments of any type") | |
if (!interactive()) { | |
args <- parser$parse_args() | |
} else { | |
args <- parser$parse_args( | |
c( | |
"study_template/etl/test_failure_alert.R", |
Possible solution to issue #100?
Note, this only sends an email alert with the attached log on job failure. I figured since successful runs are logged in the db we wouldn't need to create a log file for that.