gentzkow / GentzkowLabTemplate

MIT License
0 stars 2 forks source link

Improve error handling #18

Open lucamlouzada opened 1 week ago

lucamlouzada commented 1 week ago

This issue is part of an effort to implement substantive improvements to the lab template, as discussed in #16.

In this issue, the goal is to work on error handling. The main points to be addressed per the plans for next steps are:

I am assigning myself to work on this.

lucamlouzada commented 1 week ago

I pushed some significant changes to each of the run_xx scripts, as well as to the make.sh scripts. The main changes and the reasoning behind them are as follows:

Run_xx scripts

Make.sh

lucamlouzada commented 19 hours ago

I just added two pushes to this branch to reflect a discussion with @gentzkow in which we noticed some errors when running the scripts from a zsh shell instead of bash. There seems to be some incompatibilities due to small differences in syntax such that some commands yield different outputs in zsh and bash. With the small changes I made, zsh should work.

In the run_xx scripts (6240a8d), the change was a minor alteration in syntax for the regex search in the output folder.

In the make.sh scripts (98dc2cb), I simplified the way error handling was happening in this shell script. I removed "set -e" from the beginning and instead defined a trap right at the start of the code (without redirecting output to the logfile, so we don't need to wait until the logfile has been created to activate this trap as was the case in my previous edit). I also brought back the subshells and manually reactivated the trap inside the subshell to ensure proper error handling.

However, there still are inconsistencies in the way that each deals with errors - for example, errors in the run_xx scripts in zsh get propagated to the parent script (make.sh), such that the inner error handling does not function the same way as in bash. I will keep investigating this issue.