1
- # ' @method applyJobFunction ExperimentRegistry
2
- # ' @export
3
- applyJobFunction.ExperimentRegistry = function (reg , job , cache ) {
4
- algo = cache(getAlgorithmFilePath(reg $ file.dir , job $ algo.id ),
5
- slot = " algo" , parts = " algorithm" )$ fun
1
+ # internal function to define a wrappers for job/reduce functions
2
+ # that can have optional arguments job, static and dynamic
3
+ .applyJobWrapper = function (reg , job , cache , algo ) {
6
4
algo.use = c(" job" , " static" , " dynamic" )
7
5
algo.use = setNames(algo.use %in% names(formals(algo )), algo.use )
8
-
6
+
9
7
# encapsulate the loading into functions for lazy loading
10
8
#
11
9
# IMPORTANT: Note that the order of the messages in the log files can be confusing.
@@ -15,17 +13,28 @@ applyJobFunction.ExperimentRegistry = function(reg, job, cache) {
15
13
parts = getProblemFilePaths(reg $ file.dir , job $ prob.id )
16
14
static = function () cache(parts [" static" ], slot = " static" , impute = NULL )
17
15
dynamic = function () calcDynamic(reg , job , static(), cache(parts [" dynamic" ], slot = " dynamic" , impute = NULL ))
18
-
16
+
19
17
# switch on algo formals and apply algorithm function
20
18
f = switch (sum(c(1L , 2L , 4L )[algo.use ]) + 1L ,
21
- function (... ) algo(... ),
22
- function (... ) algo(job = job , ... ),
23
- function (... ) algo(static = static(), ... ),
24
- function (... ) algo(job = job , static = static(), ... ),
25
- function (... ) algo(dynamic = dynamic(), ... ),
26
- function (... ) algo(job = job , dynamic = dynamic(), ... ),
27
- function (... ) algo(static = static(), dynamic = dynamic(), ... ),
28
- function (... ) algo(job = job , static = static(), dynamic = dynamic(), ... ))
19
+ function (... ) algo(... ),
20
+ function (... ) algo(job = job , ... ),
21
+ function (... ) algo(static = static(), ... ),
22
+ function (... ) algo(job = job , static = static(), ... ),
23
+ function (... ) algo(dynamic = dynamic(), ... ),
24
+ function (... ) algo(job = job , dynamic = dynamic(), ... ),
25
+ function (... ) algo(static = static(), dynamic = dynamic(), ... ),
26
+ function (... ) algo(job = job , static = static(), dynamic = dynamic(), ... ))
27
+ f
28
+ }
29
+
30
+ # ' @method applyJobFunction ExperimentRegistry
31
+ # ' @export
32
+ applyJobFunction.ExperimentRegistry = function (reg , job , cache ) {
33
+ algo = cache(getAlgorithmFilePath(reg $ file.dir , job $ algo.id ),
34
+ slot = " algo" , parts = " algorithm" )$ fun
35
+
36
+ # switch on algo formals and apply algorithm function
37
+ f = .applyJobWrapper(reg , job , cache , algo )
29
38
30
39
messagef(" Applying Algorithm %s ..." , job $ algo.id )
31
40
do.call(f , job $ algo.pars )
0 commit comments