Repository: snap-stanford/ogb
Issue: Import issue in ogb
Root cause: Validation Gap

The ogb package can not be imported on console now and will generate errors for the below imports:

import torch
import ogb
from ogb.graphproppred import GraphPropPredDataset
from ogb.graphproppred import PygGraphPropPredDataset

In addition log generation is not implemented in __init__ files. I also noticed that the lines in __init__ that blocks proper import have not yet been used anywhere else in the program so I have a PR to address these issues.

https://github.com/Zahra-Bakhtiari/GraphPropPred_bug_fix/pull/1/files

I also did some google search and noticed that this is a big struggle for the new ogb users, several open issues exist on it :)



Hi! Thanks for the PR! Could you elaborate on what is the import error? I think people just need to install some prerequisites (`torch`, `rdkit`, `torch-geometric`, `dgl`) before using `ogb`. I try to print fewer errors because some package is not necessary for some users (`dgl` is not necessary for PyG users, `rdkit` is not necessary for non-molecule graph datasets)

Without logs users are getting just below error:
![image](https://user-images.githubusercontent.com/22945240/145498207-2c763e30-2342-4c0d-b71f-ee11f90ef495.png)


with the changes in this PR import is successful for both:
![image](https://user-images.githubusercontent.com/22945240/145498677-45849cfa-39b9-41ef-ae3d-68c2fc2c8be8.png)


these 2 lines are causing import issues:

from torch_geometric.data import InMemoryDataset    noqa pylint: disable
 from ogb.io.read_graph_pyg import read_graph_pyg

it looks like  InMemoryDataset is not actively being used anywhere in the file so it can get converted to object. 

In addition the below line in __init__ also causes import issue:

  TODO: The below line causes import issue for "from ogb.graphproppred import PygGraphPropPredDataset"
         and is not being used anywhere else
         self.data, self.slices = torch.load(self.processed_paths[0])

Did you install torch-geometric? In order to use PyGGraphPropDataset, you need to have pyg.

yes, this is the screenshot of my virtualenv:

![image](https://user-images.githubusercontent.com/22945240/145499946-d80faea3-6879-493a-b073-2df9e954313d.png)


can you successfully do the following?
```
from torch_geometric.data import InMemoryDataset
```
It's likely that your torch_geometric is not installed properly.

![image](https://user-images.githubusercontent.com/22945240/145500921-1086cbde-3968-4e48-af74-82008b449e9d.png)


the installation looks fine but the import provides this error:
![image](https://user-images.githubusercontent.com/22945240/145501108-63866841-0ace-49f8-9493-c6709facfcf2.png)



I see. You need to install torch_sparse correctly. See https://pytorch-geometric.readthedocs.io/en/latest/notes/installation.html

Hi I am able to run `from torch_geometric.data import InMemoryDataset` successfully. But whenever I try to import anything from ogb, the program stuck for infinite time. Import code is: `from ogb.graphproppred import Evaluator`

I followed the following command to install torch in conda environment:


```
CUDA=cu113
TORCH=1.11.0
pip install torch-scatter -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-sparse -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-cluster -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-spline-conv -f https://pytorch-geometric.com/whl/torch-${TORCH}+${CUDA}.html
pip install torch-geometric
```

Please see my reply in https://github.com/snap-stanford/ogb/issues/322#issuecomment-1104761589.

> 

Did you find any solution for this issue? I'm facing the same issue while importing from ogb.graphproppred.
It's taking infinite time to import

> > 
> 
> Did you find any solution for this issue? I'm facing the same issue while importing from ogb.graphproppred. It's taking infinite time to import

I fix this problem by calling `import sklearn` at first, since` ogb.graphproppred.evaluate.py `calls` from sklearn.metrics import ... `In my case, it is an issue with `sklearn`.

Import sklearn before also solve my problem. Thanks! @Qitong-Wang !