Skip to content

Fix Loose Dependency Imports #198

@abheesht17

Description

@abheesht17

In https://github.com/keras-team/keras-nlp/blob/master/API_DESIGN_GUIDE.md#avoid-new-dependencies,

try:
    import rouge_score
except ImportError:
    pass

class RougeL(keras.metrics.Metric):
    def __init__(self):
        if rouge_score is None:
            raise ImportError(
                'RougeL metrics requires the rouge_score package. '
                '`pip install rouge-score`.')

raises a NameError if rouge_score is not installed. We can change this to

try:
    import rouge_score
except ImportError:
    pass

class RougeL(keras.metrics.Metric):
    def __init__(self):
        if "rouge_score" not in sys.modules:
            raise ImportError(
                'RougeL metrics requires the rouge_score package. '

Also, all the tests fail because we haven't added rouge_score to setup.py. How do we deal with this issue?

Metadata

Metadata

Assignees

No one assigned

    Labels

    type:BugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions