Fix example logs repeating themselves (#16669)

Move declaration of log streams to before tests, so that results won't get compounded on top of each other
This commit is contained in:
Zachary Mueller
2022-04-11 16:25:16 -04:00
committed by GitHub
parent dce33f2150
commit 69233cf03b
5 changed files with 19 additions and 99 deletions

View File

@@ -18,6 +18,9 @@ from transformers.testing_utils import (
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger()
stream_handler = logging.StreamHandler(sys.stdout)
logger.addHandler(stream_handler)
class RagFinetuneExampleTests(TestCasePlus):
def _create_dummy_data(self, data_dir):
@@ -31,9 +34,6 @@ class RagFinetuneExampleTests(TestCasePlus):
f.write(content)
def _run_finetune(self, gpus: int, distributed_retriever: str = "pytorch"):
stream_handler = logging.StreamHandler(sys.stdout)
logger.addHandler(stream_handler)
tmp_dir = self.get_auto_remove_tmp_dir()
output_dir = os.path.join(tmp_dir, "output")
data_dir = os.path.join(tmp_dir, "data")