Skip to content
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

♻️Maintenance: remove backward compatibility code #4632

Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import json
import logging
import warnings
from collections.abc import Mapping
from typing import Any, Final

Expand Down Expand Up @@ -136,7 +135,7 @@ async def _get_service_latest_task(service_id: str) -> Mapping[str, Any]:
filters={"service": f"{service_id}"}
)
if not service_associated_tasks:
raise DockerServiceNotFoundError(service_id=service_id) # noqa: TRY301
raise DockerServiceNotFoundError(service_id=service_id)

# The service might have more then one task because the
# previous might have died out.
Expand Down Expand Up @@ -184,7 +183,7 @@ async def _get_task_data_when_service_running(service_id: str) -> Mapping[str, A
service_state = task["Status"]["State"]

if service_state not in TASK_STATES_RUNNING:
raise TryAgain()
raise TryAgain
return task

task = await _get_task_data_when_service_running(service_id=service_id)
Expand Down Expand Up @@ -250,28 +249,21 @@ async def _list_docker_services(
# shall be removed after 1-2 releases without issues
# backwards compatibility part

def _make_filters(*, backwards_compatible: bool) -> Mapping[str, Any]:
def _make_filters() -> Mapping[str, Any]:
filters = {
"label": [
f"{'swarm_stack_name' if backwards_compatible else to_simcore_runtime_docker_label_key('swarm_stack_name')}={swarm_stack_name}",
f"{to_simcore_runtime_docker_label_key('swarm_stack_name')}={swarm_stack_name}",
],
}
if node_id:
filters["label"].append(
f"{'uuid' if backwards_compatible else to_simcore_runtime_docker_label_key('node_id')}={node_id}"
f"{to_simcore_runtime_docker_label_key('node_id')}={node_id}"
)
if return_only_sidecars:
filters["name"] = [f"{DYNAMIC_SIDECAR_SERVICE_PREFIX}"]
return filters

warnings.warn(
"After PR#4453 [https://github.com/ITISFoundation/osparc-simcore/pull/4453] reaches"
" production, the backwards compatible code may be removed",
stacklevel=2,
)
services_list: list[Mapping] = await client.services.list(
filters=_make_filters(backwards_compatible=True)
) + await client.services.list(filters=_make_filters(backwards_compatible=False))
services_list: list[Mapping] = await client.services.list(filters=_make_filters())
return services_list


Expand Down Expand Up @@ -465,7 +457,7 @@ async def _update_service_spec(
e.status == status.HTTP_500_INTERNAL_SERVER_ERROR
and "out of sequence" in e.message
):
raise TryAgain() from e
raise TryAgain from e
raise


Expand Down