Skip to content

Commit

Permalink
Fix Progressor class method and update version 🎉
Browse files Browse the repository at this point in the history
- Updated `done` method to be called correctly in `as_progress`.
- Bumped version from `0.4.0` to `0.4.1` in `pyproject.toml`.
- Changed assertions from `task.done` to `task.done()` in tests.
  • Loading branch information
horta committed Jan 21, 2025
1 parent 5104f40 commit dd0127e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions worker/deciphon_worker/progressor.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,12 @@ def set_exception(self, exception):
def as_progress(self, timeout: float | None = None):
last_progress = self._progress
with self._progressing:
while not self.done:
while not self.done():
self._progressing.wait(timeout=timeout)
if self._progress != last_progress:
last_progress = self._progress
self._condition.release()
yield self._progress
self._condition.acquire()
yield self._progress
self._condition.release()

self.result()
2 changes: 1 addition & 1 deletion worker/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "hatchling.build"

[project]
name = "deciphon-worker"
version = "0.4.0"
version = "0.4.1"
description = "Deciphon worker."
authors = [{ name = "Danilo Horta", email = "[email protected]" }]
requires-python = "~=3.9"
Expand Down
2 changes: 1 addition & 1 deletion worker/tests/test_press.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def test_press(tmp_path, files_path: Path):
hmmfile = HMMFile(path=Path("minifam.hmm"))
task = press(hmmfile, Gencode.BAPP, 0.01)
dbfile = task.result()
assert task.done
assert task.done()
assert task.progress == 100
assert dbfile.path.name == "minifam.dcp"
assert os.path.getsize(dbfile.path) == 3609858
8 changes: 4 additions & 4 deletions worker/tests/test_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def test_scanner_2(tmp_path, files_path: Path):
with scanner:
task = scanner.put(NewSnapFile(path=Path("result.dcs")), sequences)
task.result()
assert task.done
assert task.done()
assert task.progress == 100


Expand All @@ -106,7 +106,7 @@ def test_scanner_3(tmp_path, files_path: Path):
]
for x in products:
x.result()
assert x.done
assert x.done()
assert x.progress == 100

scanner = launch_scanner(dbfile).result()
Expand All @@ -128,7 +128,7 @@ def test_scanner_3(tmp_path, files_path: Path):
]
for x in products:
x.result()
assert x.done
assert x.done()
assert x.progress == 100


Expand All @@ -146,5 +146,5 @@ def test_scanner_4(tmp_path, files_path: Path):
task = scanner.put(NewSnapFile(path=Path("result.1.dcs")), sequences)
for i in task.as_progress():
pass
assert task.done
assert task.done()
assert task.progress == 100

0 comments on commit dd0127e

Please sign in to comment.