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

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

Closed
JanStreffing opened this issue Jun 26, 2024 · 3 comments
Closed
Assignees

Comments

@JanStreffing
Copy link
Contributor

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
Copy link
Contributor Author

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
Copy link
Collaborator

@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
Copy link
Contributor Author

ty, @patrickscholz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants