Skip to content

Commit

Permalink
Merge pull request #284 from vimc/mrc-2337
Browse files Browse the repository at this point in the history
  • Loading branch information
richfitz authored May 7, 2021
2 parents 89bff97 + 8508bea commit 82f64f9
Show file tree
Hide file tree
Showing 16 changed files with 77 additions and 731 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: orderly
Title: Lightweight Reproducible Reporting
Version: 1.2.38
Version: 1.2.39
Description: Order, create and store reports from R. By defining a
lightweight interface around the inputs and outputs of an
analysis, a lot of the repetitive work for reproducible research
Expand Down
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -50,5 +50,4 @@ export(orderly_use_gitignore)
export(orderly_use_package)
export(orderly_use_resource)
export(orderly_use_source)
export(orderly_workflow)
importFrom(R6,R6Class)
4 changes: 4 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# orderly 1.2.39

* Remove `orderly_workflow` in favour of supporting workflows through orderly.server (mrc-2275)

# orderly 1.2.38

* Much clearer error message where dependency resolution fails due to a query dependency (vimc-4499)
Expand Down
11 changes: 4 additions & 7 deletions R/db2.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
## namespace/module feature so that implementation details can be
## hidden away a bit further.

orderly_schema_version <- "1.2.34"
orderly_schema_version <- "1.2.39"
orderly_schema_table <- "orderly_schema"
orderly_table_list <- "orderly_schema_tables"

Expand Down Expand Up @@ -429,16 +429,13 @@ report_data_import <- function(con, name, id, config) {

if (!is.null(dat_rds$meta$workflow)) {
sql_batch <- "SELECT id FROM workflow WHERE id = $1"
if (nrow(DBI::dbGetQuery(con, sql_batch, dat_rds$meta$workflow$id)) == 0L) {
workflow <- data_frame(
id = dat_rds$meta$workflow$id,
name = dat_rds$meta$workflow$name
)
if (nrow(DBI::dbGetQuery(con, sql_batch, dat_rds$meta$workflow)) == 0L) {
workflow <- data_frame(id = dat_rds$meta$workflow)
DBI::dbWriteTable(con, "workflow", workflow, append = TRUE)
}
report_version_workflow <- data_frame(
report_version = id,
workflow_id = dat_rds$meta$workflow$id
workflow_id = dat_rds$meta$workflow
)
DBI::dbWriteTable(con, "report_version_workflow", report_version_workflow,
append = TRUE)
Expand Down
76 changes: 14 additions & 62 deletions R/main.R
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,6 @@ cli_args_process <- function(args) {
dat$options$parameters <- cli_args_process_batch_parameters(
dat$options$parameter, dat$options$file)
dat$options$name <- dat$options[["<name>"]] # docopt bug?
} else if (dat$command == "workflow") {
dat$options$parameters <- cli_args_process_run_parameters(
dat$options$parameter)
dat$options$name <- dat$options[["<name>"]] # docopt bug?
}

dat
Expand All @@ -55,8 +51,7 @@ Commands:
cleanup Remove drafts and dangling data
rebuild Rebuild the database
migrate Migrate the archive
batch Run a batch of reports
workflow Run a workflow"
batch Run a batch of reports"

cli_args_preprocess <- function(args) {
## This will work ok for filtering away unwanted arguments *if* the
Expand Down Expand Up @@ -144,14 +139,15 @@ usage_run <- "Usage:
orderly run [options] <name> [<parameter>...]
Options:
--instance=NAME Database instance to use (if instances are configured)
--no-commit Do not commit the report
--print-log Print the log (rather than storing it)
--id-file=FILE File to write the id into
--ref=REF Git reference (branch or sha) to use
--fetch Fetch git before updating reference
--pull Pull git before running report
--message=TEXT A message explaining why the report was run
--instance=NAME Database instance to use (if instances are configured)
--no-commit Do not commit the report
--print-log Print the log (rather than storing it)
--id-file=FILE File to write the id into
--ref=REF Git reference (branch or sha) to use
--fetch Fetch git before updating reference
--pull Pull git before running report
--message=TEXT A message explaining why the report was run
--workflow-id=TEXT The ID of the workflow this report is run as part of
Parameters, if given, must be passed through in key=value pairs"

Expand All @@ -176,6 +172,7 @@ main_do_run <- function(x) {
fetch <- x$options$fetch
pull <- x$options$pull
message <- x$options$message
workflow_id <- x$options$workflow_id

if (print_log) {
sink(stderr(), type = "output")
Expand All @@ -188,7 +185,8 @@ main_do_run <- function(x) {
id <- orderly_run_internal(name, parameters, root = config,
id_file = id_file, instance = instance,
ref = ref, fetch = fetch, message = message,
commit = commit, capture_log = !print_log)
commit = commit, capture_log = !print_log,
workflow_id = workflow_id)
message("id:", id)
}

Expand Down Expand Up @@ -387,49 +385,6 @@ main_do_batch <- function(x) {
message("ids:", paste(ids, collapse = ", "))
}

## 9. workflow
usage_workflow <- "Usage:
orderly workflow [options] <name> [<parameter>...]
Options:
--print-log Print the log (rather than storing it)
--ref=REF Git reference (branch or sha) to use
--pull Pull git before running report
--instance=NAME Database instance to use (if instances are configured)
--message=TEXT A message explaining why the workflow was run
Parameters, if given, must be passed through in key=value pairs"

main_do_workflow <- function(x) {
## TODO: Get some classed errors though here and then write out
## information about whether or not things worked and why they
## didn't. Possible issues (in order)
##
## * orderly report not found
## * error while preparing (e.g., package not found)
## * error while running report
## * error checking artefacts
config <- orderly_config(x$options$root, TRUE)
name <- x$options$name
instance <- x$options$instance
print_log <- x$options$print_log
ref <- x$options$ref
pull <- x$options$pull
message <- x$options$message

if (print_log) {
sink(stderr(), type = "output")
on.exit(sink(NULL, type = "output"))
} else {
config$add_run_option("capture_log", TRUE)
}

git_pull_ref(pull, ref, config, message = "Can't use --pull with --ref.")

output <- orderly_workflow_internal(name, root = config, instance = instance,
message = message, ref = ref)
message("ids:", paste(output, collapse = ", "))
}

write_script <- function(path, versioned = FALSE) {
if (!isTRUE(is_directory(path))) {
Expand Down Expand Up @@ -476,10 +431,7 @@ cli_commands <- function() {
target = main_do_migrate),
batch = list(name = "batch run reports",
usage = usage_batch,
target = main_do_batch),
workflow = list(name = "run workflow",
usage = usage_workflow,
target = main_do_workflow))
target = main_do_batch))
}


Expand Down
8 changes: 4 additions & 4 deletions R/orderly_version.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ orderly_version <- R6::R6Class(

id = NULL,
batch_id = NULL,
workflow_info = NULL,
workflow_id = NULL,
workdir = NULL,

envvar = NULL,
Expand Down Expand Up @@ -354,7 +354,7 @@ orderly_version <- R6::R6Class(
tags = private$tags,
git = private$preflight_info$git,
batch_id = private$batch_id,
workflow = private$workflow_info,
workflow = private$workflow_id,
data = private$postflight_info$data_info,
view = private$postflight_info$view_info)
},
Expand Down Expand Up @@ -423,7 +423,7 @@ orderly_version <- R6::R6Class(
use_draft = FALSE, remote = NULL,
## These might move around a bit
id_file = NULL, batch_id = NULL,
workflow_info = NULL, ref = NULL, fetch = FALSE,
workflow_id = NULL, ref = NULL, fetch = FALSE,
capture_log = FALSE) {
logfile <- tempfile()
capture_log <- capture_log %||%
Expand All @@ -441,7 +441,7 @@ orderly_version <- R6::R6Class(
path_orderly_log(private$workdir)))
}
private$batch_id <- batch_id
private$workflow_info <- workflow_info
private$workflow_id <- workflow_id
private$fetch()
self$run_execute(echo)
self$run_cleanup()
Expand Down
4 changes: 0 additions & 4 deletions R/paths.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,6 @@ path_orderly_envir_yml <- function(path) {
file.path(path, "orderly_envir.yml")
}

path_orderly_workflow_dir <- function(path, workflow_name) {
file.path(path, "workflows", paste0(workflow_name, ".yml"))
}

path_orderly_log <- function(path) {
file.path(path, "orderly.log")
}
Expand Down
4 changes: 2 additions & 2 deletions R/recipe_run.R
Original file line number Diff line number Diff line change
Expand Up @@ -128,13 +128,13 @@ orderly_run_internal <- function(name = NULL, parameters = NULL, envir = NULL,
remote = NULL, tags = NULL,
# specific to run_internal
id_file = NULL, batch_id = NULL,
workflow_info = NULL, fetch = FALSE,
workflow_id = NULL, fetch = FALSE,
ref = NULL, capture_log = NULL,
commit = FALSE) {
version <- orderly_version$new(name, root, locate)
id <- version$run_internal(parameters, instance, envir, message, tags, echo,
use_draft, remote, id_file, batch_id,
workflow_info, ref, fetch, capture_log)
workflow_id, ref, fetch, capture_log)
if (commit) {
version$commit(capture_log)
}
Expand Down
122 changes: 0 additions & 122 deletions R/workflow.R

This file was deleted.

1 change: 0 additions & 1 deletion inst/database/schema.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ report_version_batch:
workflow:
columns:
- id: {type: TEXT}
- name: {type: TEXT}

report_version_workflow:
columns:
Expand Down
Loading

0 comments on commit 82f64f9

Please sign in to comment.