kima-org / kima

A data analysis framework for exoplanet detection
http://www.kima.science
MIT License
4 stars 1 forks source link

Non-deterministic crashing of pip-installable kima with same inputs #22

Closed Kamuish closed 1 month ago

Kamuish commented 2 months ago

Hi,

It seems that the pip-installable version has non-deterministic crashing when running the same code multiple times in a row (without changing the input data). I have added below the code and the traceback. Do you have any idea of what might be going wrong?

Ps: I can't test this with the (latest) github version as I am facing problems with the installation (see #21)

Code:

def run_kima(new_path, input_files, n_steps, fix, NPmax, run_with_GP = False):
  with chdir(new_path):

    # pass list to RVData with filepaths
    data = RVData(filenames=input_files, 
                  units="ms",
                  skip=0, 
                  indicators=["fwhm", "s-fwhm", "cont", "s-cont", "bis", "s-bis"]
                  )
    if run_with_GP:
      model = GPmodel(fix=fix, 
                      npmax=NPmax,
                        data=data,
                        )
    else:
      model = RVmodel(fix=fix, npmax=NPmax, data=data
                      )

    model.conditional.eprior = Kumaraswamy(0.867, 3.03)

    # GP correlation timescale
    model.eta1_prior = LogUniform(0.1, 10)
    model.eta2_prior = LogUniform(50, 600)

    # GP period
    model.eta3_prior = LogUniform(50, 200)

    kima.run(model, 
             steps=n_steps,
              num_threads=5,
              new_level_interval=7000,
              save_interval=500
              )

run_kima(results_path.as_posix(),
    n_steps=30_000,
    input_files=[data_path.as_posix()],
    fix=False,
    NPmax=2,
    run_with_GP=False
    )

Traceback:

(.venv) ➜  KOBE /home/amiguel/RV_analysis/KOBE/.venv/bin/python /home/amiguel/RV_analysis/KOBE/kima_runs/apply_kima.py
[1]    24914 segmentation fault (core dumped)  /home/amiguel/RV_analysis/KOBE/.venv/bin/python 
(.venv) ➜  KOBE /home/amiguel/RV_analysis/KOBE/.venv/bin/python /home/amiguel/RV_analysis/KOBE/kima_runs/apply_kima.py
Traceback (most recent call last):
  File "/home/amiguel/RV_analysis/KOBE/kima_runs/apply_kima.py", line 68, in <module>
    run_kima(results_path.as_posix(),
  File "/home/amiguel/RV_analysis/KOBE/kima_runs/apply_kima.py", line 27, in run_kima
    data = RVData(filenames=input_files, 
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: vector::_M_range_insert
(.venv) ➜  KOBE /home/amiguel/RV_analysis/KOBE/.venv/bin/python /home/amiguel/RV_analysis/KOBE/kima_runs/apply_kima.py
Traceback (most recent call last):
  File "/home/amiguel/RV_analysis/KOBE/kima_runs/apply_kima.py", line 68, in <module>
    run_kima(results_path.as_posix(),
  File "/home/amiguel/RV_analysis/KOBE/kima_runs/apply_kima.py", line 27, in run_kima
    data = RVData(filenames=input_files, 
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
MemoryError: std::bad_alloc
(.venv) ➜  KOBE /home/amiguel/RV_analysis/KOBE/.venv/bin/python /home/amiguel/RV_analysis/KOBE/kima_runs/apply_kima.py
Traceback (most recent call last):
  File "/home/amiguel/RV_analysis/KOBE/kima_runs/apply_kima.py", line 68, in <module>
    run_kima(results_path.as_posix(),
  File "/home/amiguel/RV_analysis/KOBE/kima_runs/apply_kima.py", line 27, in run_kima
    data = RVData(filenames=input_files, 
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
ValueError: vector::_M_range_insert
Kamuish commented 2 months ago

Managed to find the issue: One of the indicators was not present in the file (i.e., it had one column less than expected). Is it possible to add a warning/check for such cases?

j-faria commented 1 month ago

This should explicitly raise a RuntimeError now.

In any case, I was already getting a ValueError: vector too long before when the file was missing a column, although that might be compiler-dependent.