DeepChainBio / bio-transformers

bio-transformers is a wrapper on top of the ESM/Protbert model, trained on millions on proteins and used to predict embeddings.
https://bio-transformers.readthedocs.io/en/latest/getting_started/install.html
Apache License 2.0
143 stars 31 forks source link

Use absolute import instead of relative import #8

Closed mathpluscode closed 3 years ago

mathpluscode commented 3 years ago

In the current code, we use relative imports such as https://github.com/DeepChainBio/bio-transformers/blob/main/biotransformers/esm_wrappers.py#L12

I believe the absolute imports are recommended.

In general, absolute imports are preferred over relative imports.

https://chrisyeh96.github.io/2017/08/08/definitive-guide-python-imports.html#absolute-vs-relative-import

Thus, our package named bio-transformers, the source folder is biotransformers, we should import like

from biotransformers.transformers_wrappers import (
    NATURAL_AAS,
    TransformersInferenceConfig,
    TransformersModelProperties,
    TransformersWrapper,
)

instead of

from .transformers_wrappers import (
    NATURAL_AAS,
    TransformersInferenceConfig,
    TransformersModelProperties,
    TransformersWrapper,
)

I think this is clearer? What do you think?

delfosseaurelien commented 3 years ago

I think that we should follow the best practices, I saw a lot of my favorite package which are using relative import, but considering we are flexible, we will switch to absolute import