MolecularAI / QSARtuna

QSARtuna: QSAR model building with the optuna framework
https://molecularai.github.io/QSARtuna/
Apache License 2.0
102 stars 16 forks source link

PermissionError: [Errno 13] Permission denied, for 3.0.0.1 and 3.0.0 version #7

Closed MachineGUN001 closed 6 months ago

MachineGUN001 commented 6 months ago

hi,

while I try to run the chemprop part, by following the example of the most basic ChemProp run, which will train the algorithm using the recommended (sensible) defaults for the MPNN architecture.

the error occured.

[I 2024-05-03 18:36:42,881] A new study created in memory with name: my_study
[I 2024-05-03 18:36:42,890] A new study created in memory with name: study_name_0
INFO:root:Enqueued ChemProp manual trial with sensible defaults: {'activation': 'ReLU', 'aggregation': 'mean', 'aggregation_norm': 100, 'batch_size': 50, 'depth': 3, 'dropout': 0.0, 'features_generator': 'none', 'ffn_hidden_size': 300, 'ffn_num_layers': 3, 'final_lr_ratio_exp': -1, 'hidden_size': 300, 'init_lr_ratio_exp': -1, 'max_lr_exp': -3, 'warmup_epochs_ratio': 0.1, 'algorithm_name': 'ChemPropRegressor'}
[W 2024-05-03 18:36:49,239] Trial 0 failed with parameters: {'algorithm_name': 'ChemPropRegressor', 'ChemPropRegressor_algorithm_hash': '668a7428ff5cdb271b01c0925e8fea45', 'activation': <ChemPropActivation.RELU: 'ReLU'>, 'aggregation': <ChemPropAggregation.MEAN: 'mean'>, 'aggregation_norm': 100.0, 'batch_size': 50.0, 'depth': 3.0, 'dropout': 0.0, 'ensemble_size': 1, 'epochs': 5, 'features_generator': <ChemPropFeatures_Generator.NONE: 'none'>, 'ffn_hidden_size': 300.0, 'ffn_num_layers': 3.0, 'final_lr_ratio_exp': -1, 'hidden_size': 300.0, 'init_lr_ratio_exp': -1, 'max_lr_exp': -3, 'warmup_epochs_ratio': 0.1, 'descriptor': '{"name": "SmilesFromFile", "parameters": {}}'} because of the following error: ValueError('\nAll the 2 fits failed.\nIt is very likely that your model is misconfigured.\nYou can try to debug the error by setting error_score=\'raise\'.\n\nBelow are more details about the failures:\n--------------------------------------------------------------------------------\n1 fits failed with the following error:\nTraceback (most recent call last):\n  File "c:\\Users\\lsy\\anaconda3\\envs\\plantain\\lib\\site-packages\\sklearn\\model_selection\\_validation.py", line 890, in _fit_and_score\n    estimator.fit(X_train, y_train, **fit_params)\n  File "d:\\Cheminfo_Workshop\\3_MachineLearning_V1\\QSARtuna-3.0.0.1\\optunaz\\algorithms\\chem_prop.py", line 255, in fit\n    pd.DataFrame(\n  File "c:\\Users\\lsy\\anaconda3\\envs\\plantain\\lib\\site-packages\\pandas\\util\\_decorators.py", line 211, in wrapper\n    return func(*args, **kwargs)\n  File "c:\\Users\\lsy\\anaconda3\\envs\\plantain\\lib\\site-packages\\pandas\\core\\generic.py", line 3720, in to_csv\n    return DataFrameRenderer(formatter).to_csv(\n  File "c:\\Users\\lsy\\anaconda3\\envs\\plantain\\lib\\site-packages\\pandas\\util\\_decorators.py", line 211, in wrapper\n    return func(*args, **kwargs)\n  File "c:\\Users\\lsy\\anaconda3\\envs\\plantain\\lib\\site-packages\\pandas\\io\\formats\\format.py", line 1189, in to_csv\n    csv_formatter.save()\n  File "c:\\Users\\lsy\\anaconda3\\envs\\plantain\\lib\\site-packages\\pandas\\io\\formats\\csvs.py", line 241, in save\n    with get_handle(\n  File "c:\\Users\\lsy\\anaconda3\\envs\\plantain\\lib\\site-packages\\pandas\\io\\common.py", line 856, in get_handle\n    handle = open(\nPermissionError: [Errno 13] Permission denied: \'C:\\\\Users\\\\lsy\\\\AppData\\\\Local\\\\Temp\\\\tmpnon7aoeh\'\n\n--------------------------------------------------------------------------------\n1 fits failed with the following error:\nTraceback (most recent call last):\n  File "c:\\Users\\lsy\\anaconda3\\envs\\plantain\\lib\\site-packages\\sklearn\\model_selection\\_validation.py", line 890, in _fit_and_score\n    estimator.fit(X_train, y_train, **fit_params)\n  File "d:\\Cheminfo_Workshop\\3_MachineLearning_V1\\QSARtuna-3.0.0.1\\optunaz\\algorithms\\chem_prop.py", line 255, in fit\n    pd.DataFrame(\n  File "c:\\Users\\lsy\\anaconda3\\envs\\plantain\\lib\\site-packages\\pandas\\util\\_decorators.py", line 211, in wrapper\n    return func(*args, **kwargs)\n  File "c:\\Users\\lsy\\anaconda3\\envs\\plantain\\lib\\site-packages\\pandas\\core\\generic.py", line 3720, in to_csv\n    return DataFrameRenderer(formatter).to_csv(\n  File "c:\\Users\\lsy\\anaconda3\\envs\\plantain\\lib\\site-packages\\pandas\\util\\_decorators.py", line 211, in wrapper\n    return func(*args, **kwargs)\n  File "c:\\Users\\lsy\\anaconda3\\envs\\plantain\\lib\\site-packages\\pandas\\io\\formats\\format.py", line 1189, in to_csv\n    csv_formatter.save()\n  File "c:\\Users\\lsy\\anaconda3\\envs\\plantain\\lib\\site-packages\\pandas\\io\\formats\\csvs.py", line 241, in save\n    with get_handle(\n  File "c:\\Users\\lsy\\anaconda3\\envs\\plantain\\lib\\site-packages\\pandas\\io\\common.py", line 856, in get_handle\n    handle = open(\nPermissionError: [Errno 13] Permission denied: \'C:\\\\Users\\\\lsy\\\\AppData\\\\Local\\\\Temp\\\\tmp25ubl3rt\'\n').
Traceback (most recent call last):
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\optuna\study\_optimize.py", line 200, in _run_trial
    value_or_values = func(trial)
  File "d:\Cheminfo_Workshop\3_MachineLearning_V1\QSARtuna-3.0.0.1\optunaz\objective.py", line 191, in __call__
    scores = sklearn.model_selection.cross_validate(
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\sklearn\utils\_param_validation.py", line 213, in wrapper
    return func(*args, **kwargs)
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\sklearn\model_selection\_validation.py", line 445, in cross_validate
    _warn_or_raise_about_fit_failures(results, error_score)
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\sklearn\model_selection\_validation.py", line 531, in _warn_or_raise_about_fit_failures
    raise ValueError(all_fits_failed_message)
ValueError: 
All the 2 fits failed.
It is very likely that your model is misconfigured.
You can try to debug the error by setting error_score='raise'.

Below are more details about the failures:
--------------------------------------------------------------------------------
1 fits failed with the following error:
Traceback (most recent call last):
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\sklearn\model_selection\_validation.py", line 890, in _fit_and_score
    estimator.fit(X_train, y_train, **fit_params)
  File "d:\Cheminfo_Workshop\3_MachineLearning_V1\QSARtuna-3.0.0.1\optunaz\algorithms\chem_prop.py", line 255, in fit
    pd.DataFrame(
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\pandas\util\_decorators.py", line 211, in wrapper
    return func(*args, **kwargs)
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\pandas\core\generic.py", line 3720, in to_csv
    return DataFrameRenderer(formatter).to_csv(
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\pandas\util\_decorators.py", line 211, in wrapper
    return func(*args, **kwargs)
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\pandas\io\formats\format.py", line 1189, in to_csv
    csv_formatter.save()
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\pandas\io\formats\csvs.py", line 241, in save
    with get_handle(
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\pandas\io\common.py", line 856, in get_handle
    handle = open(
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\lsy\\AppData\\Local\\Temp\\tmpnon7aoeh'

--------------------------------------------------------------------------------
1 fits failed with the following error:
Traceback (most recent call last):
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\sklearn\model_selection\_validation.py", line 890, in _fit_and_score
    estimator.fit(X_train, y_train, **fit_params)
  File "d:\Cheminfo_Workshop\3_MachineLearning_V1\QSARtuna-3.0.0.1\optunaz\algorithms\chem_prop.py", line 255, in fit
    pd.DataFrame(
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\pandas\util\_decorators.py", line 211, in wrapper
    return func(*args, **kwargs)
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\pandas\core\generic.py", line 3720, in to_csv
    return DataFrameRenderer(formatter).to_csv(
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\pandas\util\_decorators.py", line 211, in wrapper
    return func(*args, **kwargs)
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\pandas\io\formats\format.py", line 1189, in to_csv
    csv_formatter.save()
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\pandas\io\formats\csvs.py", line 241, in save
    with get_handle(
  File "c:\Users\lsy\anaconda3\envs\plantain\lib\site-packages\pandas\io\common.py", line 856, in get_handle
    handle = open(
PermissionError: [Errno 13] Permission denied: 'C:\\Users\\lsy\\AppData\\Local\\Temp\\tmp25ubl3rt'

[W 2024-05-03 18:36:49,243] Trial 0 failed with value None.

my OS is windows 10, with python 3.10.12

why can't I acess the temp folder? could you please provide some suggestions how to fix it up? many thanks,

lewismervin1 commented 6 months ago

Thanks for the interest in QSARtuna/Qptuna. I have not tested the package on Windows and this does seem related to specific OS behaviour.

From your logs, it looks like there are insufficient permissions to write to the Users\AppData\Local\Temp* location on your machine. This folder has been selected by the temp file Python package (not a specific QSARtuna function) as the location to write the chemprop model to.

Without the ability to test the code it might be difficult to resolve this for you. I can help with some suggestions from my side.

Can you ensure you are running Python with administration privileges?

Alternatively, I found the following SO page here: https://stackoverflow.com/questions/59522627/how-to-set-up-the-temp-dir-path-in-python.

The directory named by the TMPDIR environment variable. The directory named by the TEMP environment variable. The directory named by the TMP environment variable. A platform-specific location: On Windows, the directories C:\TEMP, C:\TMP, \TEMP, and \TMP, in that order. On all other platforms, the directories /tmp, /var/tmp, and /usr/tmp, in that order. As a last resort, the current working directory.

You could try changing some of those environment variables to an alternative directory (that you are sure you can write to- e.g. like the suggestion says the current working dir).

MachineGUN001 commented 6 months ago

thanks for your kind explanation and suggestions