Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Add mechanism to differentiate between modules using EAGER_IMPORT #117

Copy link
Copy link
Open
@Erotemic

Description

@Erotemic
Issue body actions

The EAGER_IMPORT environment variable is a way to test that all of your lazy imports were correctly specified.

Every module that uses lazy_loader checks this and attempts to access all of its members if the envion is set.

    if os.environ.get("EAGER_IMPORT", ""):
        for attr in set(attr_to_modules.keys()) | submodules:
            __getattr__(attr)

This is a useful feature to have, but I'm running into an issue where the huggingface library is using lazy_loader, and attempting to test my module with EAGER_IMPORT causes failures. I just want to test my module. To avoid this I'm thinking about how the user can specify only a specific module to eager import.

Perhaps EAGER_IMPORT could be given as a pattern, and if __name__ matches the pattern, then it can trigger the case, or if it is a special code like "1", or "True", then it triggers for every module (i.e. implements the existing behavior).

Another option is to make separate environs for each module, but casing seems like it might cause confusion.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.