Skip to content

Commit 1f6f789

Browse files
committed
Revert to single pbar and set maxinterval
Matching with polling interval
1 parent 8d4b641 commit 1f6f789

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
* Fixed an issue where source and target IDs of relationships in heterogeneous OGBL graphs were not parsed correctly.
2121
* Fixed an issue where configuration parameters such as `aggregation` were ignored by `gds.graph.toUndirected`.
2222
* Fixed an issue where the `database` given for the `GraphDataScience` construction was not used for metadata retrieval, causing an exception to be raised if the default "neo4j" database was missing.
23-
* Fixed an issue where progress bars would not complete.
23+
* Fixed an issue where progress bars would not always complete.
2424

2525

2626
## Improvements

graphdatascience/query_runner/neo4j_query_runner.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,19 @@ def _forward_cypher_warnings(self, notification: Dict[str, Any]) -> None:
226226
self._logger.info(notification)
227227

228228
def _log(self, job_id: str, future: "Future[Any]", database: Optional[str] = None) -> None:
229-
pbars: Dict[str, tqdm[NoReturn]] = {}
229+
pbar: Optional[tqdm[NoReturn]] = None
230230
warn_if_failure = True
231231

232232
while wait([future], timeout=self._LOG_POLLING_INTERVAL).not_done:
233233
try:
234234
tier = "beta." if self._server_version < ServerVersion(2, 5, 0) else ""
235+
# we only retrieve the progress of the root task
235236
progress = self.run_cypher(
236-
f"CALL gds.{tier}listProgress('{job_id}') YIELD taskName, progress", database=database
237+
f"CALL gds.{tier}listProgress('{job_id}')"
238+
+ " YIELD taskName, progress"
239+
+ " RETURN taskName, progress"
240+
+ " LIMIT 1",
241+
database=database,
237242
)
238243
except Exception as e:
239244
# Do nothing if the procedure either:
@@ -251,15 +256,14 @@ def _log(self, job_id: str, future: "Future[Any]", database: Optional[str] = Non
251256
if progress_percent == "n/a":
252257
return
253258

254-
task_name = progress["taskName"][0].split("|--")[-1][1:]
255-
if task_name not in pbars:
256-
pbars[task_name] = tqdm(total=100, unit="%", desc=task_name)
257-
pbar = pbars[task_name]
259+
root_task_name = progress["taskName"][0].split("|--")[-1][1:]
260+
if not pbar:
261+
pbar = tqdm(total=100, unit="%", desc=root_task_name, maxinterval=self._LOG_POLLING_INTERVAL)
258262

259263
parsed_progress = float(progress_percent[:-1])
260264
pbar.update(parsed_progress - pbar.n)
261265

262-
for pbar in pbars.values():
266+
if pbar:
263267
pbar.update(100 - pbar.n)
264268
pbar.refresh()
265269

mypy.ini

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ ignore_missing_imports = True
88
[mypy-pyarrow.flight]
99
ignore_missing_imports = True
1010

11-
[mypy-tqdm.auto]
12-
ignore_missing_imports = True
13-
1411
[mypy-textdistance]
1512
ignore_missing_imports = True
1613

0 commit comments

Comments
 (0)