olebole / python-cpl

Python bindings for CPL recipes
http://pypi.python.org/pypi/python-cpl
GNU General Public License v2.0
10 stars 5 forks source link

muse_lsf runs fine but cpl crashes #24

Open jbrinchmann opened 5 years ago

jbrinchmann commented 5 years ago

I'm hit by a bit puzzling problem with CPL. The issue here is that the muse_lsf recipe usually runs nicely, but sometimes it returns an error message of -1 even though the log has no errors and the files are created nicely.

The problem here is less a bug, more that I do not know how to debug this error - any idea?

INFO Saving FITS cube as "LSF_PROFILE-24.fits" Traceback (most recent call last): File "/data/jarle/anaconda3/bin/musered", line 11, in load_entry_point('musered', 'console_scripts', 'musered')() File "/home/jarle/Source/musered/musered/main.py", line 395, in main cli(prog_name='musered') File "/data/jarle/anaconda3/lib/python3.7/site-packages/click/core.py", line 764, in call return self.main(args, kwargs) File "/data/jarle/anaconda3/lib/python3.7/site-packages/click/core.py", line 717, in main rv = self.invoke(ctx) File "/data/jarle/anaconda3/lib/python3.7/site-packages/click/core.py", line 1137, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/data/jarle/anaconda3/lib/python3.7/site-packages/click/core.py", line 956, in invoke return ctx.invoke(self.callback, ctx.params) File "/data/jarle/anaconda3/lib/python3.7/site-packages/click/core.py", line 555, in invoke return callback(args, kwargs) File "/data/jarle/anaconda3/lib/python3.7/site-packages/click/decorators.py", line 27, in new_func return f(get_current_context().obj, *args, kwargs) File "/home/jarle/Source/musered/musered/main.py", line 240, in process_calib mr.process_calib(step, dates=date, skip=not force, dry_run=dry_run) File "/home/jarle/Source/musered/musered/musered.py", line 774, in process_calib params_name=params_name, kwargs) File "/home/jarle/Source/musered/musered/musered.py", line 653, in _run_recipe_loop recipe.run(flist, name=date, params=params, *kwargs) File "/home/jarle/Source/musered/musered/recipes/recipe.py", line 185, in run results = self._run(flist, args, kwargs) File "/home/jarle/Source/musered/musered/recipes/recipe.py", line 372, in _run results = self._recipe(raw=self.raw, **kwargs) File "/home/jarle/Source/python-cpl/cpl/recipe.py", line 443, in call input_len, logger, output_format, delete, mtrace) File "/home/jarle/Source/python-cpl/cpl/recipe.py", line 457, in _exec input_len, logger, output_format) File "/home/jarle/Source/python-cpl/cpl/result.py", line 48, in init raise CplError(res[2][0], res[1], logger) cpl.result.CplError: Unspecified

/home/jarle/Source/python-cpl/cpl/result.py(48)init() -> raise CplError(res[2][0], res[1], logger) (Pdb) (Pdb) res ([('LSF_PROFILE', 'LSF_PROFILE.fits')], [], (-1, 1635.99, 157.79999999999998, -1)) (Pdb) res[2][0] -1 (Pdb) res[2] (-1, 1635.99, 157.79999999999998, -1) (Pdb) res[1] [] (Pdb)

olebole commented 5 years ago

This is somehow difficult, and there is not much python-cpl could do here: when a recipe (cpl_plugin_get_exec(recipe)()) returns an error, then the caller can't do much more than clean up -- there is no tracing information available in this case. You are then limited to what the recipe prints out as debug information (so, set the output level to debug), or try to attach a gdb debugger during the run and to catch it.

Since however muse_lsf is written by my as well, I would be interested in the details here. Can you provide some sample data and configuration so that I can reproduce this? The data maybe just the file names from MuseWISE (via e-mail).

The muse_lsf recipe has roughly has the following structure (recipe/muse_lsf.c):

  cpl_errorstate prestate = cpl_errorstate_get(); // <-----------------
  muse_pixtable *arcpixtable = muse_lsf_create_arcpixtable(...);
  muse_lsf_cube *lsfcube = muse_lsf_compute_slices(..., arcpixtable, ...);
  muse_lsf_qc(lsfcube);
  muse_processing_save_cube(..., lsfcube, ...); // this is where the INFO message comes from
  muse_pixtable_delete(arcpixtable);
  muse_lsf_cube_delete(lsfcube);
  return (cpl_errorstate_is_equal(prestate))?0:-1; // <----------------

Usually, when the error state would have been set somewhere, it should be accompanied with a proper error message. However this seems to be not happen (either in the CPL, or in the muse library). This should be corrected then. So, I don't see an other way than arming the recipe with a bit more debug output and to check where this happens.