Skip to content

Commit 76c0932

Browse files
committed
refactoring
1 parent be7e1e2 commit 76c0932

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

services/web/server/src/simcore_service_webserver/notifications/_rabbitmq_exclusive_queue_consumers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
from aiohttp import web
88
from models_library.groups import GroupID
9+
from models_library.projects_state import RunningState
910
from models_library.rabbitmq_messages import (
1011
ComputationalPipelineStatusMessage,
1112
EventRabbitMessage,

services/web/server/src/simcore_service_webserver/projects/_projects_service.py

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -560,11 +560,11 @@ async def update_project_node_resources_from_hardware_info(
560560
return
561561
try:
562562
rabbitmq_rpc_client = get_rabbitmq_rpc_client(app)
563-
unordered_list_ec2_instance_types: list[EC2InstanceTypeGet] = (
564-
await get_instance_type_details(
565-
rabbitmq_rpc_client,
566-
instance_type_names=set(hardware_info.aws_ec2_instances),
567-
)
563+
unordered_list_ec2_instance_types: list[
564+
EC2InstanceTypeGet
565+
] = await get_instance_type_details(
566+
rabbitmq_rpc_client,
567+
instance_type_names=set(hardware_info.aws_ec2_instances),
568568
)
569569

570570
assert unordered_list_ec2_instance_types # nosec
@@ -1367,9 +1367,10 @@ async def is_node_id_present_in_any_project_workbench(
13671367
async def _get_node_share_state(
13681368
app: web.Application,
13691369
*,
1370-
user_id: UserID,
13711370
project_uuid: ProjectID,
13721371
node_id: NodeID,
1372+
computational_pipeline_running: bool,
1373+
user_primrary_groupid: GroupID,
13731374
) -> NodeShareState:
13741375
node = await _projects_nodes_repository.get(
13751376
app, project_id=project_uuid, node_id=node_id
@@ -1405,11 +1406,11 @@ async def _get_node_share_state(
14051406
return NodeShareState(locked=False)
14061407

14071408
# if the service is computational and no pipeline is running it is not locked
1408-
if await director_v2_service.is_pipeline_running(app, user_id, project_uuid):
1409+
if computational_pipeline_running:
14091410
return NodeShareState(
14101411
locked=True,
14111412
current_user_groupids=[
1412-
await users_service.get_user_primary_group_id(app, user_id)
1413+
user_primrary_groupid,
14131414
],
14141415
status=NodeShareStatus.OPENED,
14151416
)
@@ -1913,6 +1914,11 @@ async def add_project_states_for_user(
19131914
)
19141915

19151916
# compose the node states
1917+
is_pipeline_running = (
1918+
await director_v2_service.is_pipeline_running(app, user_id, project["uuid"])
1919+
or True
1920+
)
1921+
user_primary_group_id = await users_service.get_user_primary_group_id(app, user_id)
19161922
for node_uuid, node in project["workbench"].items():
19171923
assert isinstance(node_uuid, str) # nosec
19181924
assert isinstance(node, dict) # nosec
@@ -1921,9 +1927,10 @@ async def add_project_states_for_user(
19211927
with contextlib.suppress(NodeShareStateCannotBeComputedError):
19221928
node_lock_state = await _get_node_share_state(
19231929
app,
1924-
user_id=user_id,
19251930
project_uuid=project["uuid"],
19261931
node_id=NodeID(node_uuid),
1932+
computational_pipeline_running=is_pipeline_running,
1933+
user_primrary_groupid=user_primary_group_id,
19271934
)
19281935
if NodeID(node_uuid) in computational_node_states:
19291936
node_state = computational_node_states[NodeID(node_uuid)].model_copy(

0 commit comments

Comments
 (0)