HelloJocelynLu / t5chem

Transformer-based model for chemical reactions
MIT License
58 stars 14 forks source link

import error #1

Closed zhaisilong closed 2 years ago

zhaisilong commented 2 years ago

First

position: t5chem/__init__.py

from .data_utils import TaskPrefixDataset, data_collator without import LineByLineTextDataset which needed in __all__

Second

failed to run python script directly:

python __main__.py --data_dir data/MW/ --output_dir model/ --pretrain models/pretrain/simple/ --task_type regression --num_epoch 1 ./t5chem/run_trainer.py --data_dir data/MW/ --output_dir model/ --pretrain models/pretrain/simple/ --task_type regression --num_epoch 1
Traceback (most recent call last):
  File "__main__.py", line 6, in <module>
    from .__version__ import __version__
ImportError: attempted relative import with no known parent package

the . in .__version__ means it was a relative import, if i change it into __version__ it was ok to run, but there too many . to delete. Is there any good ways to inspect and do some dev work on your program?

HelloJocelynLu commented 2 years ago

Hi,

Thank you for reporting these issues. For the first issue, it should get fixed at #63a6924 For the second issue, unfortunately we use relative import here because t5chem is intent to be called like this after successfully installation (from anywhere rather than only in the same directory):

t5chem train --data_dir t5chem/data/MW/ --output_dir model/ --pretrain t5chem/models/pretrain/simple/ --task_type regression --num_epoch 1

Changing them to relative imports will raise import errors when calling in this way. Based on your suggestion, now I've added a "develop" branch #779f2a6 so that one can directly call t5chem without installation something like:

python t5chem/__main__.py train --data_dir data/MW/ --output_dir model/ --pretrain models/pretrain/simple/ --task_type regression --num_epoch 1

Please let me know if you have more questions.

Jocelyn

zhaisilong commented 2 years ago

Thank you so much, that was very kind of you.