Skip to content

Commit 6566344

Browse files
authored
compatibility: rush 1.0.0 (#151)
* compatibility: rush 1.0.0 * ... * ...
1 parent 89a7740 commit 6566344

22 files changed

Lines changed: 471 additions & 486 deletions

.Rbuildignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,4 @@ man-roxygen
2525
^CRAN-RELEASE$
2626
^CRAN-SUBMISSION$
2727
^revdep$
28+
.claude

.github/workflows/dev-cmd-check.yml

Lines changed: 0 additions & 70 deletions
This file was deleted.

.github/workflows/no-suggest-cmd-check.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# r cmd check workflow without suggests of the mlr3 ecosystem v0.3.1
22
# https://github.com/mlr-org/actions
3-
# modified to use supercharge/redis-github-action@1.7.0
43
on:
54
workflow_dispatch:
65
inputs:
@@ -21,11 +20,22 @@ name: no-suggest-cmd-check
2120
jobs:
2221
no-suggest-cmd-check:
2322
runs-on: ${{ matrix.config.os }}
23+
services:
24+
redis:
25+
image: redis
26+
options: >-
27+
--health-cmd "redis-cli ping"
28+
--health-interval 10s
29+
--health-timeout 5s
30+
--health-retries 5
31+
ports:
32+
- 6379:6379
2433

2534
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
2635

2736
env:
2837
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
38+
RUSH_TEST_USE_REDIS: true
2939

3040
strategy:
3141
fail-fast: false
@@ -42,10 +52,6 @@ jobs:
4252
with:
4353
r-version: ${{ matrix.config.r }}
4454

45-
- uses: supercharge/redis-github-action@1.7.0
46-
with:
47-
redis-version: 7
48-
4955
- uses: r-lib/actions/setup-r-dependencies@v2
5056
with:
5157
extra-packages: |

.github/workflows/pkgdown.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,16 @@ name: pkgdown
1717
jobs:
1818
pkgdown:
1919
runs-on: ubuntu-latest
20+
services:
21+
redis:
22+
image: redis
23+
options: >-
24+
--health-cmd "redis-cli ping"
25+
--health-interval 10s
26+
--health-timeout 5s
27+
--health-retries 5
28+
ports:
29+
- 6379:6379
2030

2131
concurrency:
2232
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}

.github/workflows/r-cmd-check.yml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# r cmd check workflow of the mlr3 ecosystem v0.4.0
22
# https://github.com/mlr-org/actions
3-
# modified to use supercharge/redis-github-action@1.7.0
43
on:
54
workflow_dispatch:
65
inputs:
@@ -21,11 +20,22 @@ name: r-cmd-check
2120
jobs:
2221
r-cmd-check:
2322
runs-on: ${{ matrix.config.os }}
23+
services:
24+
redis:
25+
image: redis
26+
options: >-
27+
--health-cmd "redis-cli ping"
28+
--health-interval 10s
29+
--health-timeout 5s
30+
--health-retries 5
31+
ports:
32+
- 6379:6379
2433

2534
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
2635

2736
env:
2837
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
38+
RUSH_TEST_USE_REDIS: true
2939

3040
strategy:
3141
fail-fast: false
@@ -43,10 +53,6 @@ jobs:
4353
with:
4454
r-version: ${{ matrix.config.r }}
4555

46-
- uses: supercharge/redis-github-action@1.7.0
47-
with:
48-
redis-version: 7
49-
5056
- uses: r-lib/actions/setup-r-dependencies@v2
5157
with:
5258
extra-packages: any::rcmdcheck

.lintr

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
linters: linters_with_defaults(
2-
# lintr defaults: https://github.com/jimhester/lintr#available-linters
3-
# the following setup changes/removes certain linters
4-
assignment_linter = NULL, # do not force using <- for assignments
5-
object_name_linter = object_name_linter(c("snake_case", "CamelCase")), # only allow snake case and camel case object names
6-
cyclocomp_linter = NULL, # do not check function complexity
7-
commented_code_linter = NULL, # allow code in comments
8-
line_length_linter = NULL
9-
)
10-
2+
# lintr defaults: https://lintr.r-lib.org/reference/default_linters.html
3+
# the following setup changes/removes certain linters
4+
assignment_linter = NULL, # do not force using <- for assignments
5+
object_name_linter = object_name_linter(c("snake_case", "CamelCase")), # only allow snake case and camel case object names
6+
cyclocomp_linter = NULL, # do not check function complexity
7+
commented_code_linter = NULL, # allow code in comments
8+
line_length_linter = line_length_linter(180L),
9+
indentation_linter(indent = 2L, hanging_indent_style = "never")
10+
)
11+
exclusions: list("src/*.c", "src/*.h", "src/")

DESCRIPTION

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Depends:
2727
mlr3 (>= 1.0.1),
2828
R (>= 3.1.0)
2929
Imports:
30-
bbotk (>= 1.8.1),
30+
bbotk (>= 1.9.0),
3131
checkmate (>= 2.0.0),
3232
cli,
3333
data.table,
@@ -43,6 +43,8 @@ Suggests:
4343
mirai,
4444
mlr3learners,
4545
mlr3pipelines,
46+
processx,
47+
redux,
4648
rpart,
4749
rush (>= 0.4.1),
4850
testthat (>= 3.0.0)

inst/testthat/helper_misc.R

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -51,18 +51,3 @@ MeasureDummy = R6Class("MeasureDummy", inherit = MeasureRegr,
5151
)
5252
mlr3::mlr_measures$add("dummy", MeasureDummy)
5353

54-
flush_redis = function() {
55-
config = redux::redis_config()
56-
r = redux::hiredis(config)
57-
r$FLUSHDB()
58-
}
59-
60-
expect_rush_reset = function(rush, type = "kill") {
61-
rush$reset(type = type)
62-
# Sys.sleep(1)
63-
# keys = rush$connector$command(c("KEYS", "*"))
64-
# if (!test_list(keys, len = 0)) {
65-
# stopf("Found keys in redis after reset: %s", keys)
66-
# }
67-
mirai::daemons(0)
68-
}

tests/testthat/helper_rush.R

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# soon replaced by import from rush package
2+
skip_if_no_redis = function() {
3+
testthat::skip_on_cran()
4+
5+
if (identical(Sys.getenv("RUSH_TEST_USE_REDIS"), "true") && redux::redis_available()) {
6+
return(invisible())
7+
}
8+
9+
testthat::skip("Redis is not available")
10+
}
11+
12+
redis_configuration = function() {
13+
config = redux::redis_config()
14+
r = redux::hiredis(config)
15+
r$FLUSHDB()
16+
config
17+
}
18+
19+
start_rush = function(n_workers = 2, worker_type = "remote") {
20+
config = redis_configuration()
21+
22+
rush::rush_plan(n_workers = n_workers)
23+
24+
rush = if (packageVersion("rush") <= "0.4.1") {
25+
rush::rush_plan(n_workers = n_workers, worker_type = worker_type)
26+
rush::rsh(config = config)
27+
} else {
28+
rush::rush_plan(n_workers = n_workers, worker_type = worker_type)
29+
rush::rsh(config = config)
30+
}
31+
32+
if (worker_type == "remote") {
33+
mirai::daemons(n_workers)
34+
}
35+
36+
rush
37+
}
38+
39+
start_rush_worker = function(n_workers = 2) {
40+
config = redis_configuration()
41+
42+
network_id = paste(sample(LETTERS, 10), collapse = "")
43+
rush = if (packageVersion("rush") <= "0.4.1") {
44+
rush::RushWorker$new(network_id = network_id, config = config, remote = FALSE)
45+
} else {
46+
rush::RushWorker$new(network_id = network_id, config = config)
47+
}
48+
49+
rush
50+
}
51+
52+
# parses the string returned by rush$worker_script() and starts a processx process
53+
start_script_worker = function(script) {
54+
script = sub('^Rscript\\s+-e\\s+\\"(.*)\\"$', '\\1', script, perl = TRUE)
55+
56+
px = processx::process$new("Rscript",
57+
args = c("-e", script),
58+
supervise = TRUE,
59+
stderr = "|", stdout = "|")
60+
px
61+
}

0 commit comments

Comments
 (0)