-
Notifications
You must be signed in to change notification settings - Fork 0
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
Mrc 5114 Add a submit function to the queue object #5
Conversation
R/runner.R
Outdated
@@ -0,0 +1,59 @@ | |||
runner_run <- function(orderly_root, reportname, parameters, branch, ref, ...) { | |||
# Helper functions |
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.
These are here because there is a bug in rrq_task_create_call
and it doesn't seem to capture them. Made a ticket about this: https://mrc-ide.myjetbrains.com/youtrack/issue/mrc-5153/Investigate-rrqtaskcreatecall-bug
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.
Does this work if you call rrq::rrq_task_create_call
with the package qualifier? i.e. as orderly.runner:::runner_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.
i tried it, didnt seem to even pick up orderly:::runner_run
like the task completed successfully but it didnt do anything
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.
ohhh nevermind, i didnt install it, it did work!
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.
it actually works without it too, i just didnt do an install all and so it didnt pick it up from the orderly.runner
package 😭 i was avoiding that cos I was relying on specific branches of the orderly2 and rrq repos and didnt know if install all would overwrite them with the head of the github repo, but yh that was the issue!
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 looks great, couple of questions/comments. I wonder if your helper functions will be available if you call your rrq submit with the package qualified name.
Is the plan to expose this in the API the next PR?
tests/testthat/test-queue.R
Outdated
q <- new_queue_quietly(root) | ||
worker_manager <- start_queue_workers_quietly(1, q$controller) | ||
make_worker_dirs(root, worker_manager$id) |
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 wrap this in a helper to get a queue with specified number of workers.
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.
done
for (i in seq_len(n_tries)) { | ||
is_completed <- rrq::rrq_task_status( | ||
task_id, controller = controller | ||
) == "COMPLETE" | ||
if (is_completed == TRUE) { | ||
break | ||
} | ||
Sys.sleep(1) | ||
} |
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.
You can use rrq_task_wait
for this
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.
ooo thats neat thanks
R/runner.R
Outdated
@@ -0,0 +1,59 @@ | |||
runner_run <- function(orderly_root, reportname, parameters, branch, ref, ...) { | |||
# Helper functions |
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.
Does this work if you call rrq::rrq_task_create_call
with the package qualifier? i.e. as orderly.runner:::runner_run
?
# Cleanup | ||
git_clean(worker_path) |
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.
In what case do we need to cleanup?
Just tried locally and I was able to use point_head_to_ref
to switch between commits without cleaning up anything in between.
Is this for if orderly fails to run and writes to the draft
dir? I think that will be gitignored?
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.
at the end of a successful run, orderly deletes the file from the draft folder and leaves an empty folder in the directory, the most important bit of this git clean function is the removing of those empty dirs, just to keep a clean worktree after every run, otherwise that draft folder would just keep accumulating lots of empty folders after many runs
the stash and drop is just a safety in case someone has somehow produced something that is untracked by git, we can guarantee that it is removed and doesnt accumulate, people could also change their gitignore files which could also lead to these problems i think
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 wonder if it might also be worth (or worth doing in addition) the clean before running the report?
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5 +/- ##
===========================================
- Coverage 100.00% 99.44% -0.56%
===========================================
Files 7 8 +1
Lines 142 179 +37
===========================================
+ Hits 142 178 +36
- Misses 0 1 +1 ☔ View full report in Codecov by Sentry. |
yh i wanted to get this object sorted, once the status and submit are in, adding the endpoints should hopefully be a fairly easy PR |
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 didn't get a chance to run this up, sorry. But the implementation looks great, much simpler than orderly1 I think. I'm sure when we use it in practice we'll iterate a few times getting the git stuff right, but this feels at least on the right not track, possibly it'll be all we need
orderly2::orderly_artefact("Some data", "data.rds") | ||
d <- data.frame(a = 1:10, x = runif(10), y = 1:10 + runif(10)) | ||
write.table("test", file = file.path("..", "..", "inside_draft.txt")) | ||
write.table("test", file = file.path("..", "..", "..", "outside_draft.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.
naughty!
# Cleanup | ||
git_clean(worker_path) |
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 wonder if it might also be worth (or worth doing in addition) the clean before running the report?
Pushed a commit here which will
|
Finally got a PR up for this! This adds the submit function to the queue and returns the
task_id
from rrq. The strategy for the worker dirs was that we were going to git clone the orderly root and fetch before we run a report. We can then checkout and hard reset on to the desired commit.This PR also required mrc-ide/rrq#110 and mrc-ide/orderly2#130 for the env vars required to make this work