FESOM / tripyview

Triangular plotting for FESOM2
MIT License
4 stars 3 forks source link

tripyrun AttributeError: 'NoneType' object has no attribute 'nbytes' #114

Closed JanStreffing closed 2 months ago

JanStreffing commented 3 months ago

After solving #112 and #113 I am faced with this error:

tripyrun tripyrun_main_all.yml
/work/ab0246/a270092/software/miniconda3/envs/pyfesom2/lib/python3.9/site-packages/scipy/__init__.py:155: UserWarning: A NumPy version >=1.18.5 and <1.25.0 is required for this version of SciPy (detected version 1.26.4
  warnings.warn(f"A NumPy version >={np_minversion} and <{np_maxversion}"
/work/ab0246/a270092/software/tripyview
 --> start time: 2024-06-26 13:45:22

 --> compute hmesh:
     --> compute: None
Executing: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 7/7 [00:14<00:00,  2.19s/cell]Exception ignored in: <function WeakSet.__init__.<locals>._remove at 0x7fcd1713b9d0>
Traceback (most recent call last):
  File "/work/ab0246/a270092/software/miniconda3/envs/pyfesom2/lib/python3.9/_weakrefset.py", line 39, in _remove
    def _remove(item, selfref=ref(self)):
KeyboardInterrupt:
Executing: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 7/7 [00:17<00:00,  2.43s/cell]
     --> compute: nresol
Executing: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 7/7 [00:22<00:00,  3.23s/cell]

 --> compute hslice:
     --> compute: temp
          --> depth: 100
Executing:  67%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▎                                                                             | 6/9 [00:10<00:05,  1.72s/cell]
Executing:  78%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████▏                                                   | 7/9 [00:17<00:04,  2.49s/cell]
Traceback (most recent call last):
  File "/work/ab0246/a270092/software/miniconda3/envs/pyfesom2/bin/tripyrun", line 33, in <module>
    sys.exit(load_entry_point('tripyview', 'console_scripts', 'tripyrun')())
  File "/work/ab0246/a270092/software/tripyview/tripyview/sub_tripyrun.py", line 275, in tripyrun
    webpage = analyses_driver_list[analysis_name](yaml_settings, analysis_name, webpage=dict(), image_count=0, vname=None)
  File "/work/ab0246/a270092/software/tripyview/tripyview/sub_tripyrundriver.py", line 259, in drive_hslice
    webpage, image_count = loop_over_param(webpage, image_count, params_vname, target='mon',
  File "/work/ab0246/a270092/software/tripyview/tripyview/sub_tripyrundriver.py", line 210, in loop_over_param
    webpage, image_count = exec_papermill(webpage, image_count, params_vname, exec_template=exec_template)
  File "/work/ab0246/a270092/software/tripyview/tripyview/sub_tripyrundriver.py", line 116, in exec_papermill
    pm.execute_notebook(f"{templates_nb_path}/template_{exec_template}.ipynb",
  File "/work/ab0246/a270092/software/miniconda3/envs/pyfesom2/lib/python3.9/site-packages/papermill/execute.py", line 134, in execute_notebook
    raise_for_execution_errors(nb, output_path)
  File "/work/ab0246/a270092/software/miniconda3/envs/pyfesom2/lib/python3.9/site-packages/papermill/execute.py", line 241, in raise_for_execution_errors
    raise error
papermill.exceptions.PapermillExecutionError:
---------------------------------------------------------------------------
Exception encountered at "In [6]":
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[6], line 82
     78         data = tpv.load_data_fesom2(mesh, datapath, vname=vname, year=yeari, mon=moni, day=dayi, record=recordi,
     79                                     depth=depth, descript=descript, do_info=False)
     81 print(' --> elasped time to load data: {:3.2f} min.'.format( (clock.time()-ts)/60  ))
---> 82 print(' --> data uses {:3.2f} Gb:'.format(data.nbytes/(1024**3)))
     83 print('')
     85 #__________________________________________________________________________________________________
     86 # check if data where loaded

AttributeError: 'NoneType' object has no attribute 'nbytes'

for this one the solution is not immediately obvious to me. I tried again with a clean environment for tripyview and with the recommended python version 3.9, but got the same error.

JanStreffing commented 3 months ago

I found that this error can result from an incorrectly set simulation path / trying to load data that is not there.

Needs better error handeling.

patrickscholz commented 3 months ago

@JanStreffing yes the datapath might be wrong, ... the hslice notebook had a wrong order of the checks for None (In most of the other notebooks it was correct)! Now i first check for None with a valueerror message, than i use the nbytes variable

#__________________________________________________________________________________________________    
    # check if data where loaded
    if data is None: raise ValueError(f'data == None, data could not be readed, your path:{datapath} might be wrong!!!')
    print(' --> elasped time to load data: {:3.2f} min.'.format( (clock.time()-ts)/60  ))        
    print(' --> data uses {:3.2f} Gb:'.format(data.nbytes/(1024**3)))
    print('')

Now when there is a wrong path it prints the ValueError error message! Main branch has been actualized (I will look at the otherproblems as well)

JanStreffing commented 2 months ago

ty, @patrickscholz