AI-4-XAS / XASNet-XAI

End-to-end Graph Neural Network model to predict XAS spectra. The package enables automated feature engineering and data processing of large text data. XASNet-XAI also provides explainability of predicted spectra.
MIT License
2 stars 4 forks source link

Unable to use XASNet module in Jupyter Notebook #1

Open abd-adhyatma opened 3 months ago

abd-adhyatma commented 3 months ago

Hey! Thank you for supporting your publication with the code and in an easily accessible manner, to boot. I followed the installation instructions in the readme, and it seems everything was installed correctly. However, when I tried to use the modules in a python code, python was unable to call the XASNet module. When I checked the site packages folder, it seems like the XASNet package wasn't installed correctly as well.

Kindly find the code I used to call the package below:

Code:

from XASNet.data import QM9_XAS

# load or create QM9-XAS graph dataset
root = 'data/load-QM9-XAS-dataset' 
qm9_spec = QM9_XAS(
    root=root,
    raw_dir='./', # path to save/load the raw data necessary to build the graph dataset
    spectra=xas_spectra # XAS spectra of all structures in QM9-XAS
)

# save the dataset if it doesn't exists
if not osp.exists(root):
    torch.save(qm9_spec, root)

Output:

---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
Cell In[1], [line 1](vscode-notebook-cell:?execution_count=1&line=1)
----> [1](vscode-notebook-cell:?execution_count=1&line=1) from XASNet.data import QM9_XAS
      [3](vscode-notebook-cell:?execution_count=1&line=3) # load or create QM9-XAS graph dataset
      [4](vscode-notebook-cell:?execution_count=1&line=4) root = 'data/load-QM9-XAS-dataset' 

ModuleNotFoundError: No module named 'XASNet'

Kindly find the output for pip list -v and ls in the site-packages directory below:

Package                  Version    Location                                                        Installer
------------------------ ---------- --------------------------------------------------------------- ---------
...
urllib3                  2.2.2      /home/abadhy/anaconda3/envs/xasnet/lib/python3.12/site-packages pip
wcwidth                  0.2.13     /home/abadhy/anaconda3/envs/xasnet/lib/python3.12/site-packages conda
wheel                    0.43.0     /home/abadhy/anaconda3/envs/xasnet/lib/python3.12/site-packages
XASNet-XAI               1.0.0      /home/abadhy/anaconda3/envs/xasnet/lib/python3.12/site-packages pip
yarl                     1.9.4      /home/abadhy/anaconda3/envs/xasnet/lib/python3.12/site-packages pip
zipp                     3.19.2     /home/abadhy/anaconda3/envs/xasnet/lib/python3.12/site-packages conda
...
...
jinja2-3.1.4.dist-info              prompt_toolkit                               wheel
joblib                              prompt_toolkit-3.0.47.dist-info              wheel-0.43.0.dist-info
joblib-1.4.2.dist-info              psutil                                       XASNet_XAI-1.0.0.dist-info
jupyter_client                      psutil-5.9.0.dist-info                       yarl
jupyter_client-8.6.2.dist-info      psutil-6.0.0.dist-info                       yarl-1.9.4.dist-info
jupyter_core                        ptyprocess                                   zipp
jupyter_core-5.7.2.dist-info        ptyprocess-0.7.0.dist-info                   zipp-3.19.2.dist-info
jupyter.py                          pure_eval                                    zmq
kiwisolver                          pure_eval-0.2.2.dist-info
kiwisolver-1.4.5.dist-info          __pycache__

I would really love some assistance with this issue. Cheers!

sam-j-hall commented 3 months ago

Hi Abdurrahman,

Thank you for bringing this to my attention. I have had a look at the problem and it is nothing wrong on your end. The code was missing an __init__.py file and discrepancy in naming in the setup.py . I am not a collaborator on the repo so I cannot push any change to this currently so for now I will describe what needs to be done.

In the setup.py file, change the name on line 18 to name="XASNet",

and you then need to create an __init__.py file in the src/XASNet repository with the following text

from XASNet.trainer import *
from XASNet.utils import *
from XASNet.XASNet_GAT import *
from XASNet.XASNet_GraphNet import *
from .models import *

You should then repeat the installation and this should work.

Let me know if there are any problems with this.