Skip to content

Commit

Permalink
Make tqdm optional cause it interferes with thread monkey patching in…
Browse files Browse the repository at this point in the history
… gevent
  • Loading branch information
ddorian committed Mar 25, 2024
1 parent 4ed0b8d commit 76b2474
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion dl_translate/_translation_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,11 @@ def translate(
data_loader = torch.utils.data.DataLoader(text, batch_size=batch_size)
output_text = []

tqdm_iterator = data_loader
if verbose is True:
tqdm_iterator = tqdm
with torch.no_grad():
for batch in tqdm(data_loader, disable=not verbose):
for batch in tqdm_iterator(data_loader, disable=not verbose):
encoded = self._tokenizer(batch, return_tensors="pt", padding=True)
encoded.to(self.device)

Expand Down

0 comments on commit 76b2474

Please sign in to comment.