JMSLab / Template

Template for research repository using scons.
9 stars 1 forks source link

Matlab builder issues #19

Closed mcaceresb closed 3 years ago

mcaceresb commented 3 years ago

@jmshapir Now that #12 is merged we have a working repo. While I wait for @veli-m-andirin's feedback on #10, I wanted to highlight some problems with the matlab builder.

I had already coded a fix for all these issues (it's a 15-line snippet) but I didn't want to delay #12. It's a matter of whether you think it's a good idea (the only drawback is it adds complexity to the matlab call; the pro is that it would solve the issues above). If you think it makes sense, I can ask @veli-m-andirin to review the snippet.

jmshapir commented 3 years ago

Thanks @mcaceresb!

These issues may possibly be a legacy of the fact that I wrote the first version of the matlab builder myself. :-)

It may also be related to the bug flagged in gslab_python/#166

From your description it sounds like a good idea to fix this. I suggest that @veli-m-andirin reviews the snippet and plays around with the functionality, and after @veli-m-andirin reviews I can incorporate it into my broader review of the Template.

Thanks for checking.

veli-m-andirin commented 3 years ago

Thanks @mcaceresb! Happy to review the snippet and check the functionality.

mcaceresb commented 3 years ago

Continued in #21.

mcaceresb commented 3 years ago

@jmshapir I had a look here and that is exactly the second issue I highlighted, so it would be fixed by #21.

mcaceresb commented 3 years ago

For this issue, we fixed the problems with the Matlab builder outlined here. The second seemed the most pressing, and is the same issue that had been pointed out gslab_python/#166.

  1. Handling the log was more nuanced than expected. On *nix, the old method did save a log file because Matlab was run from the console, so everything was printed to stdout, but not so on Windows. We now save to the log using Matlab's diary function and we redirect stdout to a dummy log that is deleted after the program runs (if we don't redirect stdout then the log would be printed twice on *nix).

  2. The Matlab program is run inside a try, catch block that exits with status 1 on error and 0 on no error. Hence errors do not cause Matlab to hang.

  3. Before the program runs, the program's directory gets added to Matlab's path via the addpath function.

During the PR we made some additional changes not specific to Matlab: