gitter-lab / ml4bio

A graphical interface for sklearn classification to introduce machine learning to biologists
MIT License
11 stars 2 forks source link

Predict and Save as error handling #6

Closed agitter closed 5 years ago

agitter commented 5 years ago

I trained a model on the telomere example data and proceeded to Step 3: Test and Predict. I clicked the Predict and Save as button but then cancelled, which crashed the GUI.

Here is the stack trace:

Traceback (most recent call last):
  File "envs\ml4bio\lib\site-packages\ml4bio\ml4bio.py", line 1267, in predict
    self.curr_model.predict(data, path)
  File "envs\ml4bio\lib\site-packages\ml4bio\model.py", line 241, in predict
    output.to_csv(path, sep=',', index=False)           # save to file
  File "envs\ml4bio\lib\site-packages\pandas\core\frame.py", line 1745, in to_csv
    formatter.save()
  File "envs\ml4bio\lib\site-packages\pandas\io\formats\csvs.py", line 156, in save
    compression=self.compression)
  File "envs\ml4bio\lib\site-packages\pandas\io\common.py", line 400, in _get_handle
    f = open(path_or_buf, mode, encoding=encoding)
FileNotFoundError: [Errno 2] No such file or directory: ''
fmu2 commented 5 years ago

I found the bug and it is an easy fix. A condition for checking the file path was missing. I will push the change to the repo after the workshop.