Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lazy module loading #298

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Add lazy module loading #298

wants to merge 1 commit into from

Conversation

mariosasko
Copy link
Collaborator

@mariosasko mariosasko commented Mar 1, 2021

Discussed this change with @mttk on Slack.

Features:

  • lazy module loading
  • makes it possible to import DiskBackedDataset, HFDatasetConverter and YAKE from the top level __init__.py but only if the required dependencies are installed (pyarrow for DiskBackedDatasets, datasets for HFDatasetConverter, yake for YAKE).

Copy link
Collaborator

@ivansmokovic ivansmokovic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Good idea.

Copy link
Member

@mttk mttk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, from what I understand, every exposed module would be importable by doing from podium import <module>.
In some cases, I would prefer if we maintained different submodules, for cases of implemented datasets (from podium.datasets import SST, IMDB) or preprocessing tools, etc.

How difficult/ugly do you think it would be to maintain some degree of import hierarchy?

Copy link
Collaborator

@FilipBolt FilipBolt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this change since it is sort of more in line what I see from more recent frameworks: flair, huggingface. I know a bit older frameworks like torch, numpy, or scikit-learn still have hierarchy, but if there is no performance difference I don't see much value in keeping imports separate.

@mariosasko
Copy link
Collaborator Author

@mttk from podium.datasets import SST, IMDB still works just fine. The import hierarchy is left untouched. I understand what you are saying, but I think the hierarchy is irrelevant to the user and by exposing the public componets in the top level __init__.py , it's easier for the user to reach them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants