Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with srr slot when sharing saved params objects #91

Closed
gustavdelius opened this issue Sep 14, 2019 · 2 comments · Fixed by #100
Closed

Problem with srr slot when sharing saved params objects #91

gustavdelius opened this issue Sep 14, 2019 · 2 comments · Fixed by #100
Assignees
Labels
bug core Issue relates to the mizer core discussion An idea that needs discussion before becoming a proposal

Comments

@gustavdelius
Copy link
Member

The fact that the params object has a slot that contains a function creates a problem when we save params objects to disk and then share them with each other. To see this, take a look at the stock recruitment function stored in the @srr slot of one of the params objects that Ken recently added to mizer:

Barents_params@srr

This produces:

<srcref: file "/Users/ken/Documents/Source/Mizer/R/MizerParams-class.R" chars 2391:20 to 2396:1>
<environment: namespace:mizer>
Warning messages:
1: In getSrcLines(srcfile, x[7L], x[8L]) :
  restarting interrupted promise evaluation
2: In getSrcLines(srcfile, x[7L], x[8L]) :
  internal error -3 in R_decompress1

Notice that it points to code on Ken's computer and hence R produces some cryptic warning messages.

Note also that the @srr slot contains a closure (http://adv-r.had.co.nz/Functional-programming.html#closures), i.e., it contains its environment, which in this case is the entire content of the mizer namespace. I don't know if that is a problem, because I have not really gotten my head around closures. But it sounds like it might be a problem when sharing params objects. It does for example lead to inflated file sizes when saving the params objects to disk.

The easiest way to avoid these complications is to not store the function in the @srr slot but instead a string with the name of the function. This would be similar to how we currently specify the gear selectivity functions and the predation kernel type.

Another option would be to take the option of using alternative stock-recruitment relationships out of the main mizer package and provide it via a mizer extension and in the process design it more carefully.

Both these options would break backwards compatibility, but I don't think many people have used alternative stock-recruitment relationships yet.

All comments welcome.

@gustavdelius gustavdelius added bug discussion An idea that needs discussion before becoming a proposal core Issue relates to the mizer core labels Sep 14, 2019
@Kenhasteandersen
Copy link
Contributor

Kenhasteandersen commented Sep 16, 2019 via email

@gustavdelius gustavdelius self-assigned this Sep 16, 2019
@gustavdelius
Copy link
Member Author

Thanks @Kenhasteandersen, I will go ahead and implement that solution now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug core Issue relates to the mizer core discussion An idea that needs discussion before becoming a proposal
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants