From 783538686673fa6db6e3bfc989cbbfdbc748309e Mon Sep 17 00:00:00 2001 From: abheesht17 Date: Mon, 23 May 2022 21:28:12 +0530 Subject: [PATCH 1/2] Fix loose dep code snippet in API_DESIGN_GUIDE.md --- API_DESIGN_GUIDE.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/API_DESIGN_GUIDE.md b/API_DESIGN_GUIDE.md index 151463e4da..ec011b2035 100644 --- a/API_DESIGN_GUIDE.md +++ b/API_DESIGN_GUIDE.md @@ -41,12 +41,13 @@ try: except ImportError: pass -class RougeL(keras.metrics.Metric): +class Rouge(keras.metrics.Metric): def __init__(self): - if rouge_score is None: + if "rouge_score" not in sys.modules: raise ImportError( - 'RougeL metrics requires the rouge_score package. ' - '`pip install rouge-score`.') + "ROUGE metric requires the `rouge_score` package." + "Please install it with `pip install rouge_score`." + ) ``` ## Keep computation inside TensorFlow graph From 796bb395205d0b8f193fcdfe1d2bb2f415fea3ed Mon Sep 17 00:00:00 2001 From: abheesht17 Date: Tue, 24 May 2022 17:56:42 +0530 Subject: [PATCH 2/2] Address review comments - I --- API_DESIGN_GUIDE.md | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/API_DESIGN_GUIDE.md b/API_DESIGN_GUIDE.md index ec011b2035..e1536ff130 100644 --- a/API_DESIGN_GUIDE.md +++ b/API_DESIGN_GUIDE.md @@ -39,17 +39,20 @@ and add installation instructions for the specific symbol: try: import rouge_score except ImportError: - pass + rouge_score = None class Rouge(keras.metrics.Metric): def __init__(self): - if "rouge_score" not in sys.modules: + if rouge_score is None: raise ImportError( "ROUGE metric requires the `rouge_score` package." "Please install it with `pip install rouge_score`." ) ``` +Additionally, to ensure that unit tests don't fail, please add the corresponding +library to the `extras_require["tests"]` list in `setup.py`. + ## Keep computation inside TensorFlow graph Our layers, metrics, and tokenizers should be fast and efficient, which means