montepython_public icon indicating copy to clipboard operation
montepython_public copied to clipboard

Error logger (possible new feature?)

Open carlosggarcia opened this issue 4 years ago • 3 comments

Hi, It'd be nice to have a record of the CosmoComputation errors: what set of parameters cause it, which kind of error it is, etc.

Based on https://github.com/miguelzuma/montepython_zuma, I've modified compute_lkl and io_mp.py to save the error messages, parameters and chains (with an error code for different kind of errors), when cosmo.compute() fails. Just a quick hack, nothing fancy.

0001-added-hi_class-error-logger.patch.txt

carlosggarcia avatar Jul 01 '20 14:07 carlosggarcia

Hi Carlos

Thank you! This sounds useful. Last I spoke to Miguel he mentioned he had some better error handling for MontePython and I guess this is it? Maybe to start you could add it as an flag that you can set for runs to print errors? That way people who have i/o concerns can skip it. E.g. you could add a flag --print-errors to parser_mp.py , do you already know how to do that?

Did you test your modifications for both Py2 and Py3?

The ideal for me would be if you would set this up as changes to the current branch 3.3 (v3.3.3) and then do a pull request, then I can add it right away to v3.4, which should be out in a week or so.

Best, Thejs

brinckmann avatar Jul 01 '20 16:07 brinckmann

Hi Thejs,

I have added the option --print-errors and seems to work for both python2 and python3. I haven't had much time to do an exhaustive test but, so far, it seems to work ok.

I cannot fork this repo because I've already forked another fork and need it for an ongoing project at this moment. Sorry for the inconvenience. I share the patch as before. You can apply it with git am 0001-added-hi_class-error-logger.patch.txt.

0001-added-hi_class-error-logger.patch.txt

Best, Carlos

carlosggarcia avatar Jul 02 '20 10:07 carlosggarcia

I just created the pull request, I've come out with a way of having the different versions of MP in the same repo. Thanks, Carlos

carlosggarcia avatar Jul 24 '20 14:07 carlosggarcia