@@ -28,3 +28,44 @@ test_that("E2E: Model spec removal works", {
28
28
expect_false(exists(update_method_name , inherits = FALSE ))
29
29
expect_no_error(parsnip ::: check_model_doesnt_exist(model_name ))
30
30
})
31
+
32
+ test_that(" E2E: Model spec removal is not too aggressive" , {
33
+ skip_if_no_keras()
34
+
35
+ model_name <- " my_mlp"
36
+ model_name_2 <- " my_mlp_2"
37
+
38
+ input_block <- function (model , input_shape ) {
39
+ keras3 :: keras_model_sequential(input_shape = input_shape )
40
+ }
41
+ output_block <- function (model ) {
42
+ model | > keras3 :: layer_dense(units = 1 )
43
+ }
44
+
45
+ create_keras_sequential_spec(
46
+ model_name = model_name ,
47
+ layer_blocks = list (input = input_block , output = output_block ),
48
+ mode = " regression"
49
+ )
50
+
51
+ create_keras_sequential_spec(
52
+ model_name = model_name_2 ,
53
+ layer_blocks = list (input = input_block , output = output_block ),
54
+ mode = " regression"
55
+ )
56
+
57
+ expect_true(exists(model_name , inherits = FALSE ))
58
+ expect_true(exists(model_name_2 , inherits = FALSE ))
59
+ expect_error(parsnip ::: check_model_doesnt_exist(model_name ))
60
+ expect_error(parsnip ::: check_model_doesnt_exist(model_name_2 ))
61
+
62
+ remove_keras_spec(model_name )
63
+
64
+ expect_false(exists(model_name , inherits = FALSE ))
65
+ expect_true(exists(model_name_2 , inherits = FALSE ))
66
+ expect_no_error(parsnip ::: check_model_doesnt_exist(model_name ))
67
+ expect_error(parsnip ::: check_model_doesnt_exist(model_name_2 ))
68
+
69
+ # cleanup
70
+ remove_keras_spec(model_name_2 )
71
+ })
0 commit comments