Skip to content

Commit 52f7525

Browse files
committed
test callback mechanism
1 parent 10069ac commit 52f7525

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

services/director-v2/src/simcore_service_director_v2/modules/comp_scheduler/_manager.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,9 +113,7 @@ async def _get_pipeline_dag(project_id: ProjectID, db_engine: Engine) -> nx.DiGr
113113

114114
@exclusive(
115115
get_redis_client_from_app,
116-
lock_key=get_redis_lock_key(
117-
MODULE_NAME_SCHEDULER, unique_lock_key_builder=lambda: ""
118-
),
116+
lock_key=get_redis_lock_key(MODULE_NAME_SCHEDULER, unique_lock_key_builder=None),
119117
)
120118
async def schedule_pipelines(app: FastAPI) -> None:
121119
with log_context(_logger, logging.DEBUG, msg="scheduling pipelines"):

services/director-v2/src/simcore_service_director_v2/modules/comp_scheduler/_utils.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,15 @@ def get_redis_client_from_app(*args, **kwargs) -> RedisClientSDK:
9393

9494

9595
def get_redis_lock_key(
96-
suffix: str, *, unique_lock_key_builder: Callable[..., str]
96+
suffix: str, *, unique_lock_key_builder: Callable[..., str] | None
9797
) -> Callable[..., str]:
9898
def _(*args, **kwargs) -> str:
9999
app = _get_app_from_args(*args, **kwargs)
100-
unique_lock_part = unique_lock_key_builder(*args, **kwargs)
101-
return f"{app.title}-{suffix}-{unique_lock_part}"
100+
unique_lock_part = (
101+
unique_lock_key_builder(*args, **kwargs) if unique_lock_key_builder else ""
102+
)
103+
if unique_lock_part:
104+
unique_lock_part = f"-{unique_lock_part}"
105+
return f"{app.title}-{suffix}{unique_lock_part}"
102106

103107
return _

services/director-v2/src/simcore_service_director_v2/modules/comp_scheduler/_worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def _get_scheduler_worker(app: FastAPI) -> BaseCompScheduler:
2626

2727

2828
def _unique_key_builder(
29-
user_id: UserID, project_id: ProjectID, iteration: Iteration
29+
_app, user_id: UserID, project_id: ProjectID, iteration: Iteration
3030
) -> str:
3131
return f"{user_id}:{project_id}:{iteration}"
3232

services/director-v2/tests/unit/with_dbs/comp_scheduler/test_worker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def mocked_get_scheduler_worker(
4848

4949

5050
async def test_worker_properly_calls_scheduler_api(
51+
with_disabled_auto_scheduling: mock.Mock,
5152
initialized_app: FastAPI,
5253
mocked_get_scheduler_worker: mock.Mock,
5354
published_project: PublishedProject,

0 commit comments

Comments
 (0)