Skip to content

Commit 2910ae5

Browse files
committed
ruff
1 parent acd04a6 commit 2910ae5

File tree

2 files changed

+14
-18
lines changed

2 files changed

+14
-18
lines changed

packages/models-library/src/models_library/projects_nodes_io.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
UUIDStr: TypeAlias = Annotated[str, StringConstraints(pattern=UUID_RE)]
3636

37-
NodeIDStr = UUIDStr
37+
NodeIDStr: TypeAlias = UUIDStr
3838

3939
LocationID = int
4040
LocationName = str

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

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
from models_library.projects import ProjectID
2626
from models_library.projects_nodes_io import NodeID, NodeIDStr
2727
from models_library.projects_state import RunningState
28-
from models_library.services import ServiceKey, ServiceType, ServiceVersion
28+
from models_library.services import ServiceType
2929
from models_library.users import UserID
3030
from networkx.classes.reportviews import InDegreeView
3131
from servicelib.common_headers import UNDEFINED_DEFAULT_SIMCORE_USER_AGENT_VALUE
@@ -179,7 +179,7 @@ async def _get_pipeline_tasks(
179179
) -> dict[NodeIDStr, CompTaskAtDB]:
180180
comp_tasks_repo = CompTasksRepository.instance(self.db_engine)
181181
pipeline_comp_tasks: dict[NodeIDStr, CompTaskAtDB] = {
182-
NodeIDStr(f"{t.node_id}"): t
182+
f"{t.node_id}": t
183183
for t in await comp_tasks_repo.list_computational_tasks(project_id)
184184
if (f"{t.node_id}" in list(pipeline_dag.nodes()))
185185
}
@@ -237,9 +237,9 @@ async def _set_states_following_failed_to_aborted(
237237
for task in tasks.values():
238238
if task.state == RunningState.FAILED:
239239
node_ids_to_set_as_aborted.update(nx.bfs_tree(dag, f"{task.node_id}"))
240-
node_ids_to_set_as_aborted.remove(NodeIDStr(f"{task.node_id}"))
240+
node_ids_to_set_as_aborted.remove(f"{task.node_id}")
241241
for node_id in node_ids_to_set_as_aborted:
242-
tasks[NodeIDStr(f"{node_id}")].state = RunningState.ABORTED
242+
tasks[f"{node_id}"].state = RunningState.ABORTED
243243
if node_ids_to_set_as_aborted:
244244
# update the current states back in DB
245245
comp_tasks_repo = CompTasksRepository.instance(self.db_engine)
@@ -387,8 +387,8 @@ async def _process_started_tasks(
387387
root_parent_node_id=run_metadata.get("project_metadata", {}).get(
388388
"root_parent_node_id"
389389
),
390-
service_key=ServiceKey(t.image.name),
391-
service_version=ServiceVersion(t.image.tag),
390+
service_key=t.image.name,
391+
service_version=t.image.tag,
392392
service_type=ServiceType.COMPUTATIONAL,
393393
service_resources=create_service_resources_from_task(t),
394394
service_additional_metadata={},
@@ -675,9 +675,9 @@ async def _schedule_tasks_to_start( # noqa: C901
675675

676676
# get the tasks to start
677677
tasks_ready_to_start: dict[NodeID, CompTaskAtDB] = {
678-
node_id: comp_tasks[NodeIDStr(f"{node_id}")]
678+
node_id: comp_tasks[f"{node_id}"]
679679
for node_id in next_task_node_ids
680-
if comp_tasks[NodeIDStr(f"{node_id}")].state in TASK_TO_START_STATES
680+
if comp_tasks[f"{node_id}"].state in TASK_TO_START_STATES
681681
}
682682

683683
if not tasks_ready_to_start:
@@ -708,9 +708,7 @@ async def _schedule_tasks_to_start( # noqa: C901
708708
RunningState.WAITING_FOR_CLUSTER,
709709
)
710710
for task in tasks_ready_to_start:
711-
comp_tasks[
712-
NodeIDStr(f"{task}")
713-
].state = RunningState.WAITING_FOR_CLUSTER
711+
comp_tasks[f"{task}"].state = RunningState.WAITING_FOR_CLUSTER
714712

715713
except ComputationalBackendOnDemandNotReadyError as exc:
716714
_logger.info(
@@ -732,9 +730,7 @@ async def _schedule_tasks_to_start( # noqa: C901
732730
RunningState.WAITING_FOR_CLUSTER,
733731
)
734732
for task in tasks_ready_to_start:
735-
comp_tasks[
736-
NodeIDStr(f"{task}")
737-
].state = RunningState.WAITING_FOR_CLUSTER
733+
comp_tasks[f"{task}"].state = RunningState.WAITING_FOR_CLUSTER
738734
except ClustersKeeperNotAvailableError:
739735
_logger.exception("Unexpected error while starting tasks:")
740736
await publish_project_log(
@@ -755,7 +751,7 @@ async def _schedule_tasks_to_start( # noqa: C901
755751
optional_stopped=arrow.utcnow().datetime,
756752
)
757753
for task in tasks_ready_to_start:
758-
comp_tasks[NodeIDStr(f"{task}")].state = RunningState.FAILED
754+
comp_tasks[f"{task}"].state = RunningState.FAILED
759755
raise
760756
except TaskSchedulingError as exc:
761757
_logger.exception(
@@ -773,7 +769,7 @@ async def _schedule_tasks_to_start( # noqa: C901
773769
optional_progress=1.0,
774770
optional_stopped=arrow.utcnow().datetime,
775771
)
776-
comp_tasks[NodeIDStr(f"{exc.node_id}")].state = RunningState.FAILED
772+
comp_tasks[f"{exc.node_id}"].state = RunningState.FAILED
777773
except Exception:
778774
_logger.exception(
779775
"Unexpected error for %s with %s on %s happened when scheduling %s:",
@@ -792,7 +788,7 @@ async def _schedule_tasks_to_start( # noqa: C901
792788
optional_stopped=arrow.utcnow().datetime,
793789
)
794790
for task in tasks_ready_to_start:
795-
comp_tasks[NodeIDStr(f"{task}")].state = RunningState.FAILED
791+
comp_tasks[f"{task}"].state = RunningState.FAILED
796792
raise
797793

798794
return comp_tasks

0 commit comments

Comments
 (0)