From 0fad7f1c2a7e43cf9e0ba664e26f8551ccdbb498 Mon Sep 17 00:00:00 2001 From: Jin Yong Yoo Date: Sat, 14 Nov 2020 13:20:36 -0500 Subject: [PATCH] fix readthedocs module load --- .readthedocs.yml | 2 ++ .../language_models/google_language_model/lm_utils.py | 5 ++--- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.readthedocs.yml b/.readthedocs.yml index 8b4f8f9c..f53df83f 100644 --- a/.readthedocs.yml +++ b/.readthedocs.yml @@ -17,3 +17,5 @@ python: - requirements: requirements.txt - method: pip path: . + extra_requirements: + - docs diff --git a/textattack/constraints/grammaticality/language_models/google_language_model/lm_utils.py b/textattack/constraints/grammaticality/language_models/google_language_model/lm_utils.py index 15d6e0a6..4026d268 100644 --- a/textattack/constraints/grammaticality/language_models/google_language_model/lm_utils.py +++ b/textattack/constraints/grammaticality/language_models/google_language_model/lm_utils.py @@ -10,8 +10,7 @@ import sys from textattack.shared.utils import LazyLoader tf = LazyLoader("tensorflow", globals(), "tensorflow") - -from google.protobuf import text_format # noqa: E402 +protobuf = LazyLoader("google.protobuf", globals(), "google.protobuf") def LoadModel(sess, graph, gd_file, ckpt_file): @@ -30,7 +29,7 @@ def LoadModel(sess, graph, gd_file, ckpt_file): with tf.io.gfile.GFile(gd_file) as f: s = f.read() gd = tf.compat.v1.GraphDef() - text_format.Merge(s, gd) + protobuf.text_format.Merge(s, gd) tf.compat.v1.logging.info("Recovering Graph %s", gd_file) t = {}