lightonai / lightonml

Python library for running large-scale computations on LightOn's OPUs
https://docs.lighton.ai
Other
35 stars 11 forks source link

lighton.json missing? #2

Closed jacquesdurden closed 3 years ago

jacquesdurden commented 3 years ago

Dear all,

When I launch the example "Kernel methods and Random features approximation" in https://docs.lighton.ai/examples/kernels_and_random_features.html#Kernel-Ridge-Classification-and-Approximating-Kernels I got an error message that seems to point to a missing "lighton.json".

Here is the error:

In [3]: from lightonml.datasets import MNIST 
   ...: from sklearn.model_selection import train_test_split 
   ...:  
   ...: (X_train, y_train), (X_test, y_test) = MNIST() 
   ...:                                                                                                                          
---------------------------------------------------------------------------
FileNotFoundError                         Traceback (most recent call last)
<ipython-input-3-ace58cf22abb> in <module>
      2 from sklearn.model_selection import train_test_split
      3 
----> 4 (X_train, y_train), (X_test, y_test) = MNIST()

//anaconda/lib/python3.6/site-packages/lightonml/datasets.py in MNIST()
     33     ]
     34 
---> 35     data_home = get_ml_data_dir_path()
     36 
     37     if not (data_home/'MNIST').is_dir():

//anaconda/lib/python3.6/site-packages/lightonml/utils.py in get_ml_data_dir_path()
     27         config_data = json.loads(user_lighton_cfg.read_text())
     28     else:
---> 29         raise FileNotFoundError("Can't find a lighton.json folder.")
     30     return Path(config_data['ml_data_path'])
     31 

FileNotFoundError: Can't find a lighton.json folder.

Thank you for your help.

CharlesB2 commented 3 years ago

Hi,

Sorry for the inconvenience, we'll provide a better way to handle this.

For now, you can fix the error by adding a .lighton.json file in your home directory, containing the following line:

{ "ml_data_path": "/path/to/mldata" }

Where /path/to/mldata is a writable directory. MNIST dataset will be downloaded the first time you call the MNIST() function, the same holds for the other datasets in this module.

CharlesB2 commented 3 years ago

With version 1.4, we added a better error message, and more ways to specify the data directory:

See https://docs.lighton.ai/lightonml.datasets.html for complete documentation