Error in get(moduleCall, envir = sim@.envir[[cur[["moduleName"]]]]) : invalid 'envir' argument

10 views
Skip to first unread message

Eliot McIntire

unread,
Feb 6, 2018, 4:27:25 PM2/6/18
to SpaDES Users
Question from @SteveCumming

This strange error came while trying to run a SpaDES object returned by an apparently OK call to simInit. Any thoughts?

This code works on my machine, but not my students, suggesting a config problem.


>> Simulation dependencies:

use `depends(sim)` to view dependencies for each module

 

>> Simulation times:

     current start end timeunit

[1,] 0       0     30  "year" 

 

>> Modules:

     Name     Timeunit

[1,] "ageMap" "year" 

 

>> Objects Loaded:

  objectName loadTime loaded file fun package arguments intervals

1     mapDim        0   TRUE <NA>  NA      NA        NA        NA

 

>> Objects stored:

ageMap : Formal class 'RasterLayer' [package "raster"] with 12 slots

ageMapAge : function (sim) 

ageMapInit : function (sim) 

doEvent.ageMap : function (sim, eventTime, eventType, debug = FALSE) 

mapDim :  num 40

 

>> Parameters:

      Module        Parameter Value

.checkpoint             file     

 .checkpoint         interval    NA

      ageMap .plotInitialTime     0

      ageMap    .plotInterval     1

      ageMap .saveInitialTime    NA

      ageMap    .saveInterval    NA

      ageMap   returnInterval     1

      ageMap        startTime     0

 

>> Completed Events:

Null data.table (0 rows and 0 cols)

NULL

 

>> Current Event:

Null data.table (0 rows and 0 cols)

NULL

 

>> Scheduled Events:

   eventTime moduleName eventType eventPriority

1:         0 checkpoint      init             5

2:         0       save      init             5

3:         0   progress      init             5

4:         0       load      init             5

5:         0     ageMap      init             5

 

> tmp=spades(mySim)

Error in get(moduleCall, envir = sim@.envir[[cur[["moduleName"]]]]) :

  invalid 'envir' argument

>

Eliot McIntire

unread,
Feb 6, 2018, 4:30:35 PM2/6/18
to SpaDES Users
This happens when the user creates an object in the simList that is the same name as the module. And it may not be occurring in the module itself. 

example:
Say there is a module called FireModule

mySim <- simInit(...., modules = list("FireModule"))

This will put all the functions from that module inside sim$FireModule

Then if some module does this:
sim$FireModule <- TRUE

then you will get the above error. 

The development version of SpaDES.core will shortly have a meaningful error indicating this is the problem. The user will have to fix this themselves by *never* making an object with the same name as a module.

Eliot McIntire

unread,
Feb 6, 2018, 6:33:45 PM2/6/18
to spades...@googlegroups.com
This has now been superceded, by locking the sim$<moduleName> binding. In other words, it won't work if a module tries to assign something that that name.

Reply all
Reply to author
Forward
0 new messages