AgriculturalModelExchangeInitiative / PyCrop2ML

CropML Python library
Other
17 stars 17 forks source link

using special character creates error ? #122

Closed mariegosme closed 2 years ago

mariegosme commented 2 years ago

I received the following error trying to open a model unit that I created with jupyterlab. Maybe because I used special characters (French accented characters) in the model description. It was saved without raising an error, but could not be opened again. There should be checks on the user's inputs so that it does not create errors later.


Exception Traceback (most recent call last) /opt/conda/lib/python3.7/site-packages/pycrop2ml_ui/menus/edition/editunit.py in _parse(self) 165 self._out2.clear_output() 166 with self._out: --> 167 raise Exception('Critical error while parsing the file.') 168 169 self._buildEdit()

Exception: Critical error while parsing the file. ./packages/multiplication/crop2ml/unit.modelunit.xml is NOT in CropML Format ! no element found: line 1, column 0

AttributeError Traceback (most recent call last) /opt/conda/lib/python3.7/site-packages/pycrop2ml_ui/menus/edition/editmenu.py in _eventEdit(self, b) 66 unit = editunit.editUnit({'Path': os.path.join(self._modelPath.value, 'crop2ml'), 'Model type': typemodel[0], 'Model name': typemodel[1]}, self.local) ---> 67 unit.displayMenu() 68 except:

/opt/conda/lib/python3.7/site-packages/pycrop2ml_ui/menus/edition/editunit.py in displayMenu(self) 1040 -> 1041 self._parse() 1042

/opt/conda/lib/python3.7/site-packages/pycrop2ml_ui/menus/edition/editunit.py in _parse(self) 168 --> 169 self._buildEdit() 170

/opt/conda/lib/python3.7/site-packages/pycrop2ml_ui/menus/edition/editunit.py in _buildEdit(self) 62 ---> 63 self._datas['Old name'] = self._xmlfile.name 64 self._modelname.value = self._xmlfile.name

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

During handling of the above exception, another exception occurred:

Exception Traceback (most recent call last) /opt/conda/lib/python3.7/site-packages/pycrop2ml_ui/menus/edition/editmenu.py in _eventEdit(self, b) 67 unit.displayMenu() 68 except: ---> 69 raise Exception('Could not load unit model edition menu.') 70 71 else:

Exception: Could not load unit model edition menu. ​ 0

mariegosme commented 2 years ago

problem solved: it was actually not related to the special characters, but because some information (e.g. min and max) where missing on one of the lines. Suggestion: make error message more explicit, and prevent saving a variable if it is missing required information