mlr3 icon indicating copy to clipboard operation
mlr3 copied to clipboard

"The backend of Task xxx has been removed" error under StatET

Open comintel opened this issue 2 years ago • 4 comments

I have a variety of problems running mlr3 under StatET (https://projects.eclipse.org/projects/science.statet) on Windows 10.

Some of these problems include R crashes, but the easiest problem to reproduce is to just run the following example

library(mlr3) task_penguins = as_task_classif(species ~ ., data = palmerpenguins::penguins) learner = lrn("classif.rpart", cp = .01) split = partition(task_penguins, ratio = 0.67) learner$train(task_penguins, split$train_set) prediction = learner$predict(task_penguins, split$test_set) prediction$confusion

The output and traceback is shown below. The "Error:..." line appears 12 times every time you do anything from that point on!

This is exactly the same behavior under multiple recent R releases, multiple recent StatET releases, multiple MLR3 releases (this is the current code as of today) , and multiple Eclipse and Java releases. It does not occur using R alone without StatET.

What would be the best way to pursue this? I am happy to run any tracing you would suggest.

Thanks

================================

Output follows:

Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it.

traceback() 5: stop(simpleError(str_wrap(sprintf(msg, ...), width = wrap), call = NULL)) 4: stopf("The backend of Task '%s' has been removed. Set store_backends to TRUE during model fitting to conserve it.", task$id) at assertions.R#302 3: assert_has_backend(self) at Task.R#925 2: .__Task__weights(self = self, private = private, super = super, rhs = rhs) at Task.R#924 1: (function (rhs) .__Task__weights(self = self, private = private, super = super, rhs = rhs))() Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it.

comintel avatar Aug 22 '22 08:08 comintel

Here is a better fuller traceback()

R version 4.2.1 Patched (2022-07-29 r82648 ucrt) -- "Funny-Looking Kid" Copyright (C) 2022 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 (64-bit)

library(mlr3) options(error = traceback) task_penguins = as_task_classif(species ~ ., data = palmerpenguins::penguins) learner = lrn("classif.rpart", cp = .01) split = partition(task_penguins, ratio = 0.67) learner$train(task_penguins, split$train_set)

Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. No traceback available Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. 5: stop(simpleError(str_wrap(sprintf(msg, ...), width = wrap), call = NULL)) 4: stopf("The backend of Task '%s' has been removed. Set store_backends to TRUE during model fitting to conserve it.", task$id) at assertions.R#302 3: assert_has_backend(self) at Task.R#887 2: .__Task__groups(self = self, private = private, super = super, rhs = rhs) at Task.R#886 1: (function (rhs) .__Task__groups(self = self, private = private, super = super, rhs = rhs))() Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. 5: stop(simpleError(str_wrap(sprintf(msg, ...), width = wrap), call = NULL)) 4: stopf("The backend of Task '%s' has been removed. Set store_backends to TRUE during model fitting to conserve it.", task$id) at assertions.R#302 3: assert_has_backend(self) at Task.R#905 2: .__Task__order(self = self, private = private, super = super, rhs = rhs) at Task.R#904 1: (function (rhs) .__Task__order(self = self, private = private, super = super, rhs = rhs))() Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. 5: stop(simpleError(str_wrap(sprintf(msg, ...), width = wrap), call = NULL)) 4: stopf("The backend of Task '%s' has been removed. Set store_backends to TRUE during model fitting to conserve it.", task$id) at assertions.R#302 3: assert_has_backend(self) at Task.R#863 2: .__Task__strata(self = self, private = private, super = super, rhs = rhs) at Task.R#862 1: (function (rhs) .__Task__strata(self = self, private = private, super = super, rhs = rhs))() Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. 5: stop(simpleError(str_wrap(sprintf(msg, ...), width = wrap), call = NULL)) 4: stopf("The backend of Task '%s' has been removed. Set store_backends to TRUE during model fitting to conserve it.", task$id) at assertions.R#302 3: assert_has_backend(self) at Task.R#925 2: .__Task__weights(self = self, private = private, super = super, rhs = rhs) at Task.R#924 1: (function (rhs) .__Task__weights(self = self, private = private, super = super, rhs = rhs))() Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. 5: stop(simpleError(str_wrap(sprintf(msg, ...), width = wrap), call = NULL)) 4: stopf("The backend of Task '%s' has been removed. Set store_backends to TRUE during model fitting to conserve it.", task$id) at assertions.R#302 3: assert_has_backend(self) at Task.R#887 2: .__Task__groups(self = self, private = private, super = super, rhs = rhs) at Task.R#886 1: (function (rhs) .__Task__groups(self = self, private = private, super = super, rhs = rhs))() Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. 5: stop(simpleError(str_wrap(sprintf(msg, ...), width = wrap), call = NULL)) 4: stopf("The backend of Task '%s' has been removed. Set store_backends to TRUE during model fitting to conserve it.", task$id) at assertions.R#302 3: assert_has_backend(self) at Task.R#905 2: .__Task__order(self = self, private = private, super = super, rhs = rhs) at Task.R#904 1: (function (rhs) .__Task__order(self = self, private = private, super = super, rhs = rhs))() Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. 5: stop(simpleError(str_wrap(sprintf(msg, ...), width = wrap), call = NULL)) 4: stopf("The backend of Task '%s' has been removed. Set store_backends to TRUE during model fitting to conserve it.", task$id) at assertions.R#302 3: assert_has_backend(self) at Task.R#863 2: .__Task__strata(self = self, private = private, super = super, rhs = rhs) at Task.R#862 1: (function (rhs) .__Task__strata(self = self, private = private, super = super, rhs = rhs))() Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. 5: stop(simpleError(str_wrap(sprintf(msg, ...), width = wrap), call = NULL)) 4: stopf("The backend of Task '%s' has been removed. Set store_backends to TRUE during model fitting to conserve it.", task$id) at assertions.R#302 3: assert_has_backend(self) at Task.R#925 2: .__Task__weights(self = self, private = private, super = super, rhs = rhs) at Task.R#924 1: (function (rhs) .__Task__weights(self = self, private = private, super = super, rhs = rhs))() Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. 5: stop(simpleError(str_wrap(sprintf(msg, ...), width = wrap), call = NULL)) 4: stopf("The backend of Task '%s' has been removed. Set store_backends to TRUE during model fitting to conserve it.", task$id) at assertions.R#302 3: assert_has_backend(self) at Task.R#887 2: .__Task__groups(self = self, private = private, super = super, rhs = rhs) at Task.R#886 1: (function (rhs) .__Task__groups(self = self, private = private, super = super, rhs = rhs))() Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. 5: stop(simpleError(str_wrap(sprintf(msg, ...), width = wrap), call = NULL)) 4: stopf("The backend of Task '%s' has been removed. Set store_backends to TRUE during model fitting to conserve it.", task$id) at assertions.R#302 3: assert_has_backend(self) at Task.R#905 2: .__Task__order(self = self, private = private, super = super, rhs = rhs) at Task.R#904 1: (function (rhs) .__Task__order(self = self, private = private, super = super, rhs = rhs))() Error: The backend of Task 'palmerpenguins::penguins' has been removed. Set store_backends to TRUE during model fitting to conserve it. 5: stop(simpleError(str_wrap(sprintf(msg, ...), width = wrap), call = NULL)) 4: stopf("The backend of Task '%s' has been removed. Set store_backends to TRUE during model fitting to conserve it.", task$id) at assertions.R#302 3: assert_has_backend(self) at Task.R#863 2: .__Task__strata(self = self, private = private, super = super, rhs = rhs) at Task.R#862 1: (function (rhs) .__Task__strata(self = self, private = private, super = super, rhs = rhs))()

comintel avatar Aug 27 '22 16:08 comintel

Looking at the tracebacks, I guess the problem may be StatET scanning all objects after every top-level line of R is executed in order to maintain its state.

If this is the case, would that regarded as the fault of StatET or of mlr3?

Thanks.

comintel avatar Aug 28 '22 08:08 comintel

Hey, thanks for the bug report.

I guess the problem may be StatET scanning all objects after every top-level line of R is executed in order to maintain its state.

You are probably right. This could be a clash between R6 and StatET. learner$train() stores a copy of task_penguins without backend in learner$state$train_task. For example, if you call learner$state$train_task$groups() you get the same error message. The error message is correct because we cannot print the groups without the backend. Some time ago, we had a similar problem when using all.equal() on a task without a backend. all.equal() triggers all methods in an R6 object and some methods check for the backend. StatET probably also fails in a similar way.

I'm not sure what we can do about that. This might be a StatET bug related to R6 objects. Or StatET also uses all.equal() which means all.equal() must be fixed for R6 objects.

be-marc avatar Aug 28 '22 21:08 be-marc

Thanks so much for the reply! I really appreciate it.

I have opened an issue with StatET at https://gitlab.eclipse.org/eclipse/statet/statet/-/issues/32

and will see what he thinks ........

comintel avatar Aug 28 '22 21:08 comintel