|
| 1 | +test_that("SFN create", { |
| 2 | + skip_if_no_metaflow() |
| 3 | + |
| 4 | + cmd <- "Rscript test-run-cmd.R step-functions create" |
| 5 | + system(cmd) |
| 6 | + |
| 7 | + # Rscript /Library/../metaflow/run.R --flowRDS=flow.RDS step-functions create |
| 8 | + run_cmd <- strsplit(trimws(readRDS("run_cmd.RDS")), split=" ")[[1]] |
| 9 | + actual <- paste(run_cmd[3:length(run_cmd)], collapse=" ") |
| 10 | + |
| 11 | + expected <- "--flowRDS=flow.RDS --no-pylint step-functions create" |
| 12 | + |
| 13 | + expect_equal(actual, expected) |
| 14 | + on.exit(file.remove("run_cmd.RDS")) |
| 15 | +}) |
| 16 | + |
| 17 | +test_that("SFN create --help", { |
| 18 | + skip_if_no_metaflow() |
| 19 | + |
| 20 | + cmd <- "Rscript test-run-cmd.R step-functions create --help" |
| 21 | + system(cmd) |
| 22 | + |
| 23 | + run_cmd <- strsplit(trimws(readRDS("run_cmd.RDS")), split=" ")[[1]] |
| 24 | + actual <- paste(run_cmd[3:length(run_cmd)], collapse=" ") |
| 25 | + |
| 26 | + expected <- "--flowRDS=flow.RDS --no-pylint step-functions create --help" |
| 27 | + |
| 28 | + expect_equal(actual, expected) |
| 29 | + on.exit(file.remove("run_cmd.RDS")) |
| 30 | +}) |
| 31 | + |
| 32 | +test_that("SFN create --package-suffixes", { |
| 33 | + skip_if_no_metaflow() |
| 34 | + |
| 35 | + cmd <- "Rscript test-run-cmd.R --package-suffixes=.csv,.RDS,.R step-functions create" |
| 36 | + system(cmd) |
| 37 | + |
| 38 | + run_cmd <- strsplit(trimws(readRDS("run_cmd.RDS")), split=" ")[[1]] |
| 39 | + actual <- paste(run_cmd[3:length(run_cmd)], collapse=" ") |
| 40 | + |
| 41 | + expected <- "--flowRDS=flow.RDS --no-pylint --package-suffixes=.csv,.RDS,.R step-functions create" |
| 42 | + |
| 43 | + expect_equal(actual, expected) |
| 44 | + on.exit(file.remove("run_cmd.RDS")) |
| 45 | +}) |
| 46 | + |
| 47 | +test_that("SFN create --generate-new-token", { |
| 48 | + skip_if_no_metaflow() |
| 49 | + |
| 50 | + cmd <- "Rscript test-run-cmd.R step-functions create --generate-new-token" |
| 51 | + system(cmd) |
| 52 | + |
| 53 | + run_cmd <- strsplit(trimws(readRDS("run_cmd.RDS")), split=" ")[[1]] |
| 54 | + actual <- paste(run_cmd[3:length(run_cmd)], collapse=" ") |
| 55 | + |
| 56 | + expected <- "--flowRDS=flow.RDS --no-pylint step-functions create --generate-new-token" |
| 57 | + |
| 58 | + expect_equal(actual, expected) |
| 59 | + on.exit(file.remove("run_cmd.RDS")) |
| 60 | +}) |
| 61 | + |
| 62 | +test_that("SFN create --generate-new-token --max-workers 100 --lr 0.01", { |
| 63 | + skip_if_no_metaflow() |
| 64 | + |
| 65 | + cmd <- "Rscript test-run-cmd.R step-functions create --generate-new-token --max-workers 100 --lr 0.01" |
| 66 | + system(cmd) |
| 67 | + |
| 68 | + run_cmd <- strsplit(trimws(readRDS("run_cmd.RDS")), split=" ")[[1]] |
| 69 | + actual <- paste(run_cmd[3:length(run_cmd)], collapse=" ") |
| 70 | + |
| 71 | + expected <- "--flowRDS=flow.RDS --no-pylint step-functions create --generate-new-token --max-workers 100 --lr 0.01" |
| 72 | + expect_equal(actual, expected) |
| 73 | + on.exit(file.remove("run_cmd.RDS")) |
| 74 | +}) |
| 75 | + |
| 76 | + |
| 77 | +test_that("SFN trigger", { |
| 78 | + skip_if_no_metaflow() |
| 79 | + |
| 80 | + cmd <- "Rscript test-run-cmd.R step-functions trigger" |
| 81 | + system(cmd) |
| 82 | + |
| 83 | + run_cmd <- strsplit(trimws(readRDS("run_cmd.RDS")), split=" ")[[1]] |
| 84 | + actual <- paste(run_cmd[3:length(run_cmd)], collapse=" ") |
| 85 | + |
| 86 | + expected <- "--flowRDS=flow.RDS --no-pylint step-functions trigger" |
| 87 | + |
| 88 | + expect_equal(actual, expected) |
| 89 | + on.exit(file.remove("run_cmd.RDS")) |
| 90 | +}) |
| 91 | + |
| 92 | + |
| 93 | +test_that("SFN list-runs --running", { |
| 94 | + skip_if_no_metaflow() |
| 95 | + |
| 96 | + cmd <- "Rscript test-run-cmd.R step-functions list-runs --running" |
| 97 | + system(cmd) |
| 98 | + |
| 99 | + run_cmd <- strsplit(trimws(readRDS("run_cmd.RDS")), split=" ")[[1]] |
| 100 | + actual <- paste(run_cmd[3:length(run_cmd)], collapse=" ") |
| 101 | + |
| 102 | + expected <- "--flowRDS=flow.RDS --no-pylint step-functions list-runs --running" |
| 103 | + |
| 104 | + expect_equal(actual, expected) |
| 105 | + on.exit(file.remove("run_cmd.RDS")) |
| 106 | +}) |
0 commit comments