divelab / GOOD

GOOD: A Graph Out-of-Distribution Benchmark [NeurIPS 2022 Datasets and Benchmarks]
https://good.readthedocs.io/
GNU General Public License v3.0
181 stars 19 forks source link

Circular Import error #8

Closed amirshnll closed 1 year ago

amirshnll commented 1 year ago

Hello @divelab, n my opinion, this repository's code is amazing and very clean. It is very helpful to use others. My case involves a Circular Import error bug, which I fixed by changing two files in this repository:

  1. GOOD/data/__init__.py file i changed
from .good_datasets import *
from .good_loaders import *

to

from GOOD.data.good_datasets import good_arxiv, good_cbas, good_cmnist, good_cora, good_hiv, good_motif, good_pcba, good_sst2, good_twitch, good_webkb, good_zinc
from GOOD.data.good_loaders import BaseLoader
  1. GOOD/data/good_datasets/__init__.py file i changed
from . import *

to

import good_arxiv, good_cbas, good_cmnist, good_cora, good_hiv, good_motif, good_pcba, good_sst2, good_twitch, good_webkb, good_zinc

Please update the repository if you believe this is a global issue.

CM-BF commented 1 year ago

Hi amirshnll,

This import code serves for a unique feature: You can create any new dataset classes and register them without any modifications of the __init__.py file. Using this repo won't cause this issue since the code always passes the training test.

Can you tell me which GOOD version you are using and post your error log for me to check? I would like to help you with this issue. 😄

Best, Shurui

amirshnll commented 1 year ago

I used the repository sample code in documentation:

https://good.readthedocs.io/en/latest/tutorial.html#good-datasets

but not in a personal dataset.

CM-BF commented 1 year ago

I have just tried the code:

# Directly import
from GOOD.data.good_datasets.good_hiv import GOODHIV
hiv_datasets, hiv_meta_info = GOODHIV.load(dataset_root, domain='scaffold', shift='covariate', generate=False)
# Or use register
from GOOD import register as good_reg
hiv_datasets, hiv_meta_info = good_reg.datasets['GOODHIV'].load(dataset_root, domain='scaffold', shift='covariate', generate=False)
cmnist_datasets, cmnist_meta_info = good_reg.datasets['GOODCMNIST'].load(dataset_root, domain='color', shift='concept', generate=False)

and didn't meet the problem you mentioned.

Please let me know if the issue persists.