Yale-LILY / SummerTime

An open-source text summarization toolkit for non-experts. EMNLP'2021 Demo
https://arxiv.org/abs/2108.12738
Apache License 2.0
269 stars 30 forks source link

Try to avoid using relative import #24

Closed niansong1996 closed 3 years ago

niansong1996 commented 3 years ago

I recently found that relative import can easily break things. So let's try to use absolute import.

In case someone doesn't know what this means: if you are trying to import SummModel in model/base_model.py from model/bart_model.py use from model.base_model import SummModel rather than from .base_model import SummModel

zhangir-azerbayev commented 3 years ago

I've updated the `zhangir-azerbayev/evaluation_refactoring' branch to not use relative imports. However, this breaks 'demo.ipynb' because it seems that you cannot 'import SummerTime' from within the 'SummerTime' directory.

There are also other problems related to the demo being within the package. For example, in the demo we have to write 'import model' instead of 'import SummerTime.model'.

I propose we remove the demo from the repository and instead link to it in the readme.

niansong1996 commented 3 years ago

I've updated the `zhangir-azerbayev/evaluation_refactoring' branch to not use relative imports. However, this breaks 'demo.ipynb' because it seems that you cannot 'import SummerTime' from within the 'SummerTime' directory.

There are also other problems related to the demo being within the package. For example, in the demo we have to write 'import model' instead of 'import SummerTime.model'.

@zhangir-azerbayev Interesting, what would happen if you do absolute imports like import model.base_model rather than import SummerTime.mode.base_model? I've always been using the previous way, I think the reason you can use the second way is because you did python setup.py install/develop, which installed it locally so you can reference it like an external lib.

niansong1996 commented 3 years ago

This is no longer relevant.