Closed gabrielastro closed 5 months ago
MultiNest is Fortran code written by Farhan Feroz. PyMultiNest is only the python wrapper. Most of what you ask is MultiNest-related, and nothing that PyMultiNest can control.
1) you can currently only disable the output completely. UltraNest gives fine-grained control.
2) this is not a part of PyMultiNest. UltraNest supports this.
3) this is not a part of PyMultiNest. It is complicated with the MultiNest code. UltraNest, being "pure python", supports this much better.
4) you can query this from mpi4py with from mpi4py import MPI; print(MPI.COMM_WORLD.Get_rank(), MPI.COMM_WORLD.Get_size())
Sorry to not be more useful.
Thanks for your quick answer!
PyMultiNest
to catch the output of MultiNest
and to erase the last line(s) on screen and print again? I do not know how this is done but I would have thought there are good python
libraries for handling this.PyMultiNest
or even MultiNest
actually, and I forgot that the two are separate), but I guess you are saying that if those lines (… Get_size()
) give the expected answer from the top-level, user-written script, it is basically guaranteed to be fine also at the (Py
)MultiNest
level. Ok, good point!re 1&2:
PyMultiNest just passes things to MultiNest, which calls back a function for evaluation. So PyMultiNest is not in control. For progress viz you would need either a) another thread that monitors sys.stdout/sys.stderr, but catching output doesn't work very reliably, also fortran does some weird caching. b) write a small core program that uses pymultinest, and then call this from another python program with subprocess
and parse the stdout/stderr stream as you wish. This would also solve the Ctrl-C issue.
Ok, thanks! Thanks for the sketch—maybe someone will feel inspired to fill it out :).
First of all, thanks for the very useful package! I am using it through
species
and it works very well. Now a few things:Would it be possible to have more compact output: a few lines, then an active line getting updated? I am thinking of
UltraNest
(example from a call fromspecies
:with the last line getting updated. Currently, the console buffer is filled with blocks:
and it is hard to tell where one is, and whatever messages were printed before calling
MultiNest
are off the buffer.I do not know the details of
MultiNest
but would a "percentage complete" be possible/meaningful/not too complicated to implement? It would be helpful for long runs (to estimate when to get results).More importantly, is it possible to interrupt a run with
Ctrl+C
, for instance, buttouch
ing a "stop" file would be ok too? Currently, if I realise I made some mistake, the only solution seems to be to suspendpython
withCtrl+Z
and then to kill it withkill %%
. My interest is for runs throughspecies
and @tomasstolker suggested it should be done fromMultiNest
. Please see https://github.com/tomasstolker/species/issues/89#issuecomment-1941478083. Uh, I hope you agree with him :ping_pong: :wink:.Printing a simple one-line "Using N cores in parallel" or so at the beginning of
MultiNest
would be nice to confirm that one indeed is using 1×N cores and not N×1 core as can happen if MPI is not set up properly. I was not sure at first and used timing tests to figure it out but this feels a bit too complicated. Depending on the problem, timing tests might not reveal that parallelisation is on, as you essentially pointed out :smile:.