From 8f843d883c5c4664fba7be1ae31a74cbd7288b89 Mon Sep 17 00:00:00 2001 From: Alex Ganose Date: Thu, 8 Jun 2023 09:50:45 +0200 Subject: [PATCH] Use tqdm.auto --- src/maggma/cli/multiprocessing.py | 8 +++++--- src/maggma/cli/serial.py | 2 +- src/maggma/utils.py | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/maggma/cli/multiprocessing.py b/src/maggma/cli/multiprocessing.py index abf6ec7cc..5c9228ae1 100644 --- a/src/maggma/cli/multiprocessing.py +++ b/src/maggma/cli/multiprocessing.py @@ -10,10 +10,10 @@ from concurrent.futures import ProcessPoolExecutor from logging import getLogger from types import GeneratorType -from typing import Any, Awaitable, Callable, Dict, Optional +from typing import Any, Callable, Dict, Optional from aioitertools import enumerate -from tqdm import tqdm +from tqdm.auto import tqdm from maggma.utils import primed @@ -87,7 +87,9 @@ async def process_and_release(self, idx): async def get_from_iterator(self): loop = get_event_loop() async for idx, item in enumerate(self.iterator): - future = loop.run_in_executor(self.executor, safe_dispatch, (self.func, item)) + future = loop.run_in_executor( + self.executor, safe_dispatch, (self.func, item) + ) self.tasks[idx] = future diff --git a/src/maggma/cli/serial.py b/src/maggma/cli/serial.py index e914c6469..688a6b281 100644 --- a/src/maggma/cli/serial.py +++ b/src/maggma/cli/serial.py @@ -4,7 +4,7 @@ import logging from types import GeneratorType -from tqdm import tqdm +from tqdm.auto import tqdm from maggma.core import Builder from maggma.utils import grouper, primed diff --git a/src/maggma/utils.py b/src/maggma/utils.py index 4236f1b95..eb08ce620 100644 --- a/src/maggma/utils.py +++ b/src/maggma/utils.py @@ -18,7 +18,7 @@ from pymongo.collection import Collection # import tqdm Jupyter widget if running inside Jupyter -from tqdm.autonotebook import tqdm +from tqdm.auto import tqdm def primed(iterable: Iterable) -> Iterable: