-
Notifications
You must be signed in to change notification settings - Fork 32
♻️ TasksManager uses Redis for task data #8131
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mrnicegyu11
merged 144 commits into
ITISFoundation:master
from
GitHK:pr-osparc-long-running-tasks-refactor-6
Aug 6, 2025
Merged
Changes from 75 commits
Commits
Show all changes
144 commits
Select commit
Hold shift + click to select a range
fb8628a
added in memory store to TasksManager
cb7f96d
remove unused and renamed DB
52d5a8f
renamed
878db59
moved interface to lrt_api
d8ccee4
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
b8efe90
add support for cancellation
ae3d7ef
cancelled tasks now are detected and removed
33b8ea2
erge remote-tracking branch 'upstream/master' into pr-osparc-long-run…
41db9fa
tasks are singularly tracked
dc7a13c
adjusted task cleanup
572d100
added missing test case
3ce8fa3
added redis store
f62f4b3
using new task manager with Redis peristency
f0330dd
added redis to tasksmanager
0e6516a
added Redis storage to long running tasks
2cda61e
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
41636d7
fixed tests
85cdd6b
repalced serializers
792d597
added test for multiple namespaces with redis store
9fbf1cf
fixed tests
e526df5
Revert "fixed tests"
0452113
fixed tests which required redis
e0cbc7b
fixed tests
cb79b56
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
a027afd
mypy
afb6eac
progress updates are now async and saved to storage
a73f920
fixed tests
61a5c1e
fixed broken tests
b57923f
updated interface
915ab48
fixed tests
6ee1d9f
mypy
ab3f0bd
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
827aa5e
fixed tests
f3b5e83
fixed tests
57db7eb
fixed test
1e92a2d
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
fc96620
added exclusive lock
2d5cf7a
changed mock
d4230fb
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
d39443f
mypy
8ca56b2
pylint
a42b243
fixed test
de5bb6d
fixed cli tests
68a6671
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
7baad68
fixed redis client sdk being stuck
0339d2e
added note for issue
28feba3
bumped timeout
b36ea0a
revert change
b206956
added timeout
1180187
trying to avoid lockup on teardown
9397869
avoid error on cancellation
9c35202
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
3a43c56
fixed client
ed87d5f
revert change, since it does nothing
fdc3ad7
removed is healthy
89f6bbb
fixed test
bae95a1
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
a82a8b8
fixed haning tests
1ec0334
pylint
402a6ac
refactor
e36eb8d
removed
89201e6
refactor client
7feeff6
fixed test
28e56ed
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
f883dfe
fixed in memory long running tasks for tests
a13cf50
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
fd3814d
copilot
2671668
added network to dynamic-sidecar
17b5ccc
fixed broken tests
6cb0631
added tests using multiple managers in parallel
be76636
fixed test
e05fba5
added transmission of error cancellation
b097ee7
pylint
a07dba7
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
9db9e83
mypy
e81328e
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
2f57230
added custom serializers
c3f919e
refactor
8a71108
mypy
def4201
fixed issue
355ccec
removed type
b7acc6c
relative imports
18a2075
comment update
3f99d97
refactor with retry
1717a94
moved to the requested place
15f6d18
simplify settings
c05fed9
refactor
b44d641
refactor
da4edf4
repalced with inmemory redis
81b41ea
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
ec08d2f
added missing dependency
b7043b3
fixed test
035685c
fixeed cli tests
ee63948
fixed flaky test
4d4a274
fixed test
093592f
moved fixture
9409199
refactoed fixture
fcd3e8a
fixed issue with removal of tasks
6561be5
mypy
6b257d0
removed in memoery
f699cd2
use proper patch
fac176e
refactir cancellation
1fddd08
fixeed removal and task cancellation
b9f1581
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
3a1bc33
removed task timeout
d07cfda
refactored test
91c4651
avoid CI fro getting stuck
13b705d
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
3573bdd
added fakeredis
abab05f
fixed stuck tests and renamed namespace to redis_namespace
01f0e5e
added missing dependencies
e5dc682
added missing test dependency
66f1915
enhanced waiting for progress to be delivered
5d7e723
using in memory
49a79b2
applied suggestion
6e5eeb3
fixed interface
a8c6353
using correct definition
a190275
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
0271ba8
fixed broke ntests
c6c0f14
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
67d3f51
docstring
5ddd8ef
use in-memory-redis
7f021d0
replaced with example
9ecca80
no longer hangs on client teardown
52f97c8
removed unnecessary
6e03a7f
rename
7e512eb
renamed
7e28787
removed unused
dc4b657
simplified names
e2422a7
used better name
b079ac5
added comments
c43ad07
use in memory redis
0722ff4
reverted
72b9d06
try to fix tests
7a99147
ensure no data remains
505547d
refactor
7860ae9
working
169f617
use in memory redis
c0e328a
bumped timeout
af796c8
use in_memory redis
0ffced5
changed wait policy
e14acad
removed debug log message
acee55a
removed unused
5780e3e
Merge remote-tracking branch 'upstream/master' into pr-osparc-long-ru…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
packages/pytest-simcore/src/pytest_simcore/long_running_tasks.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # pylint: disable=unused-argument | ||
|
|
||
| import functools | ||
|
|
||
| import pytest | ||
| from pytest_mock import MockerFixture | ||
| from servicelib.long_running_tasks import task | ||
| from servicelib.long_running_tasks._store.in_memory import InMemoryStore | ||
|
|
||
|
|
||
| def _mock_decorator_with_args(*decorator_args, **decorator_kwargs): | ||
| def decorator(func): | ||
| @functools.wraps(func) | ||
| async def wrapper(*func_args, **func_kwargs): | ||
| return await func(*func_args, **func_kwargs) | ||
|
|
||
| return wrapper | ||
|
|
||
| return decorator | ||
|
|
||
|
|
||
| @pytest.fixture | ||
| def use_in_memory_long_running_tasks(mocker: MockerFixture) -> None: | ||
| mocker.patch.object(task, "RedisStore", InMemoryStore) | ||
| # for testing the exclsive is not required so it's disabled | ||
| mocker.patch.object(task, "exclusive", _mock_decorator_with_args) | ||
GitHK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
40 changes: 40 additions & 0 deletions
40
packages/service-library/src/servicelib/long_running_tasks/_store/base.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,40 @@ | ||
| from abc import abstractmethod | ||
|
|
||
| from ..models import TaskContext, TaskData, TaskId | ||
|
|
||
|
|
||
| class BaseStore: | ||
|
|
||
| @abstractmethod | ||
| async def get_task_data(self, task_id: TaskId) -> TaskData | None: | ||
| """Retrieve a tracked task by its key.""" | ||
|
|
||
| @abstractmethod | ||
| async def set_task_data(self, task_id: TaskId, value: TaskData) -> None: | ||
| """Set a tracked task with its key.""" | ||
GitHK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| @abstractmethod | ||
| async def list_tasks_data(self) -> list[TaskData]: | ||
| """List all tracked tasks.""" | ||
|
|
||
| @abstractmethod | ||
| async def delete_task_data(self, task_id: TaskId) -> None: | ||
| """Delete a tracked task by its key.""" | ||
GitHK marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| @abstractmethod | ||
| async def set_as_cancelled( | ||
| self, task_id: TaskId, with_task_context: TaskContext | ||
| ) -> None: | ||
| """Mark a tracked task as cancelled.""" | ||
|
|
||
| @abstractmethod | ||
| async def get_cancelled(self) -> dict[TaskId, TaskContext]: | ||
| """Get cancelled tasks.""" | ||
|
|
||
GitHK marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| @abstractmethod | ||
| async def setup(self) -> None: | ||
| """Setup the store, if needed.""" | ||
|
|
||
| @abstractmethod | ||
| async def shutdown(self) -> None: | ||
| """Shutdown the store, if needed.""" | ||
36 changes: 36 additions & 0 deletions
36
packages/service-library/src/servicelib/long_running_tasks/_store/in_memory.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| from ..models import TaskContext, TaskData, TaskId | ||
| from .base import BaseStore | ||
|
|
||
|
|
||
| class InMemoryStore(BaseStore): | ||
| def __init__(self, *args, **kwargs): | ||
| _ = args | ||
| _ = kwargs | ||
| self._tasks_data: dict[TaskId, TaskData] = {} | ||
| self._cancelled_tasks: dict[TaskId, TaskContext] = {} | ||
|
|
||
| async def setup(self) -> None: | ||
| pass | ||
|
|
||
| async def shutdown(self) -> None: | ||
| pass | ||
|
|
||
| async def get_task_data(self, task_id: TaskId) -> TaskData | None: | ||
| return self._tasks_data.get(task_id, None) | ||
|
|
||
| async def set_task_data(self, task_id: TaskId, value: TaskData) -> None: | ||
| self._tasks_data[task_id] = value | ||
|
|
||
| async def list_tasks_data(self) -> list[TaskData]: | ||
| return list(self._tasks_data.values()) | ||
|
|
||
| async def delete_task_data(self, task_id: TaskId) -> None: | ||
| self._tasks_data.pop(task_id, None) | ||
|
|
||
| async def set_as_cancelled( | ||
| self, task_id: TaskId, with_task_context: TaskContext | ||
| ) -> None: | ||
| self._cancelled_tasks[task_id] = with_task_context | ||
|
|
||
| async def get_cancelled(self) -> dict[TaskId, TaskContext]: | ||
| return self._cancelled_tasks |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.