Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improving cmor fatal error handling #19

Closed
jypeter opened this issue Apr 8, 2015 · 5 comments
Closed

Improving cmor fatal error handling #19

jypeter opened this issue Apr 8, 2015 · 5 comments
Assignees
Milestone

Comments

@jypeter
Copy link

jypeter commented Apr 8, 2015

Still working with the Sample Program 1 example script, I have altered the variable definition line in order to generate a fatal error that I can use to expose several problems. So, I have used a non existing temperature unit

varid = cmor.variable('ts', 'Krap', axis_ids)

and I got the following error

CMOR - 91 >python -i sample_script_01.py

C Traceback:
In function: cmor_write_var_to_file


!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!                                                                                  !
! Error: in udunits analyzing units from user (Krap) for variable ts (table: Amon) !
!                                                                                  !
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

CMOR - 92 >

The things that should be improved:

  1. I was using python -i to run my script, but I got dumped in the shell rather than back in the python interpreter after the fatal error. It would be much more useful if we could have an exception and be able to go back to the python shell to debug. Maybe there is an exit in the C code in case of errors that prevents going back to python?
  2. The sample script that usually generates a ts_Amon_HadCM3_historical_r1i1p1_200001-200001.nc file (when there is no error) left a ts_Amon_HadCM3_historical_r1i1p1_28973.nc temporary file in the same directory instead. The first time I found one of these temporary files in the same directory as the correct file, I thought why is there a second file with a weird content in this directory?. It would be nice (and useful) to alter the name of the temp file to make it more explicit that it is a temp file! e.g. ts_Amon_HadCM3_historical_r1i1p1_28973_cmor_tmp.nc temporary file
@doutriaux1
Copy link
Collaborator

@jypeter do you mind splitting this issue in two separate ones?

@jypeter
Copy link
Author

jypeter commented Apr 8, 2015

No problem, go ahead

JYP @ SGS 2

@doutriaux1
Copy link
Collaborator

i meant you ;)

@doutriaux1 doutriaux1 added this to the 2.9.2 milestone May 26, 2015
@doutriaux1 doutriaux1 self-assigned this May 26, 2015
@durack1 durack1 modified the milestones: 2.9.3, 2.9.2 Jun 26, 2015
@dnadeau4
Copy link
Collaborator

I change the exit() called and send a SIGINT signal. With python, this mean that the program will not exit right away (kill -9), but when python "returns" it is possible to trap the signal. It was useful for my unittest to trap errors, but might have strange message since the code keeps running until the last functions call return. I might need to trap more "error" code.

@durack1
Copy link
Contributor

durack1 commented Jun 16, 2016

@jypeter @ehogan @dnadeau4 this issue is now duplicated by #27 if there are any specific things required please add these to the #27 issue - closing now

@durack1 durack1 closed this as completed Jun 16, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants