Skip to content
Merged
Show file tree
Hide file tree
Changes from 26 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7f9be17
moved inputs to services
Aug 18, 2025
5d0d7be
fixed
Aug 18, 2025
27dcbd1
refactr
Aug 18, 2025
c689ed8
added tests
Aug 18, 2025
1a19df7
reverted inputs placement
Aug 18, 2025
a7e6c43
properly extracted internals
Aug 18, 2025
a674736
refactor interface
Aug 18, 2025
7c604d4
added rpc interface for create_output_dirs
Aug 18, 2025
10f15d0
extracted common interface
Aug 18, 2025
f9e757f
Merge remote-tracking branch 'upstream/master' into pr-osparc-dy-side…
Aug 28, 2025
5bee321
added API for attach/detach container extentions
Aug 28, 2025
df779bb
Merge remote-tracking branch 'upstream/master' into pr-osparc-dy-side…
Aug 28, 2025
544f8d4
extracted common containers interface
Aug 28, 2025
30e5521
removed unused code
Aug 28, 2025
100fbb7
refactored messages
Aug 28, 2025
57efa22
moved tests
Aug 28, 2025
db5a1a2
finished adding RPC interface
Aug 29, 2025
8caad07
Merge remote-tracking branch 'upstream/master' into pr-osparc-dy-side…
Aug 29, 2025
d4184f6
refactor
Aug 29, 2025
0cfd263
fixed reimports
Aug 29, 2025
c4219a8
fixed error message
Aug 29, 2025
8a625ae
fixed tests
Aug 29, 2025
a6677f7
updated descriptions and docs
Aug 29, 2025
f83db20
added docstrings
Aug 29, 2025
a557f24
updated specs
Aug 29, 2025
a5ed3a3
Merge branch 'master' into pr-osparc-dy-sidecar-ports-migrate
GitHK Aug 29, 2025
707b704
removed unused
Aug 29, 2025
19821b9
drop unused
Aug 29, 2025
e03bb8b
copilot suggestions
Aug 29, 2025
bcef2c4
Merge remote-tracking branch 'upstream/master' into pr-osparc-dy-side…
Aug 29, 2025
ff22ecc
Merge branch 'pr-osparc-dy-sidecar-ports-migrate' of github.com:GitHK…
Aug 29, 2025
90569a3
Merge remote-tracking branch 'upstream/master' into pr-osparc-dy-side…
Sep 1, 2025
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
@@ -0,0 +1,84 @@
import logging

from models_library.projects_nodes_io import NodeID
from models_library.rabbitmq_basic_types import RPCMethodName
from models_library.services import ServiceOutput
from pydantic import TypeAdapter

from ....logging_utils import log_decorator
from ... import RabbitMQRPCClient
from ._utils import get_rpc_namespace

_logger = logging.getLogger(__name__)


@log_decorator(_logger, level=logging.DEBUG)
async def toggle_ports_io(
rabbitmq_rpc_client: RabbitMQRPCClient,
*,
node_id: NodeID,
enable_outputs: bool,
enable_inputs: bool
) -> None:
rpc_namespace = get_rpc_namespace(node_id)
result = await rabbitmq_rpc_client.request(
rpc_namespace,
TypeAdapter(RPCMethodName).validate_python("toggle_ports_io"),
enable_outputs=enable_outputs,
enable_inputs=enable_inputs,
)
assert result is None # nosec


@log_decorator(_logger, level=logging.DEBUG)
async def create_output_dirs(
rabbitmq_rpc_client: RabbitMQRPCClient,
*,
node_id: NodeID,
outputs_labels: dict[str, ServiceOutput]
) -> None:
rpc_namespace = get_rpc_namespace(node_id)
result = await rabbitmq_rpc_client.request(
rpc_namespace,
TypeAdapter(RPCMethodName).validate_python("create_output_dirs"),
outputs_labels=outputs_labels,
)
assert result is None # nosec


@log_decorator(_logger, level=logging.DEBUG)
async def attach_container_to_network(
rabbitmq_rpc_client: RabbitMQRPCClient,
*,
node_id: NodeID,
container_id: str,
network_id: str,
network_aliases: list[str]
) -> None:
rpc_namespace = get_rpc_namespace(node_id)
result = await rabbitmq_rpc_client.request(
rpc_namespace,
TypeAdapter(RPCMethodName).validate_python("attach_container_to_network"),
container_id=container_id,
network_id=network_id,
network_aliases=network_aliases,
)
assert result is None # nosec


@log_decorator(_logger, level=logging.DEBUG)
async def detach_container_from_network(
rabbitmq_rpc_client: RabbitMQRPCClient,
*,
node_id: NodeID,
container_id: str,
network_id: str
) -> None:
rpc_namespace = get_rpc_namespace(node_id)
result = await rabbitmq_rpc_client.request(
rpc_namespace,
TypeAdapter(RPCMethodName).validate_python("detach_container_from_network"),
container_id=container_id,
network_id=network_id,
)
assert result is None # nosec
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import logging
from typing import Any

from models_library.api_schemas_directorv2.dynamic_services import ContainersComposeSpec
from models_library.api_schemas_dynamic_sidecar.containers import ActivityInfoOrNone
from models_library.projects_nodes_io import NodeID
from models_library.rabbitmq_basic_types import RPCMethodName
from pydantic import TypeAdapter
Expand All @@ -26,3 +28,60 @@ async def create_compose_spec(
containers_compose_spec=containers_compose_spec,
)
assert result is None # nosec


@log_decorator(_logger, level=logging.DEBUG)
async def containers_docker_inspect(
rabbitmq_rpc_client: RabbitMQRPCClient,
*,
node_id: NodeID,
only_status: bool,
) -> dict[str, Any]:
rpc_namespace = get_rpc_namespace(node_id)
result = await rabbitmq_rpc_client.request(
rpc_namespace,
TypeAdapter(RPCMethodName).validate_python("containers_docker_inspect"),
only_status=only_status,
)
assert isinstance(result, dict) # nosec
return result


@log_decorator(_logger, level=logging.DEBUG)
async def get_containers_activity(
rabbitmq_rpc_client: RabbitMQRPCClient, *, node_id: NodeID
) -> ActivityInfoOrNone:
rpc_namespace = get_rpc_namespace(node_id)
result = await rabbitmq_rpc_client.request(
rpc_namespace,
TypeAdapter(RPCMethodName).validate_python("get_containers_activity"),
)
return TypeAdapter(ActivityInfoOrNone).validate_python(result) if result else None


@log_decorator(_logger, level=logging.DEBUG)
async def get_containers_name(
rabbitmq_rpc_client: RabbitMQRPCClient, *, node_id: NodeID, filters: str
) -> str:
rpc_namespace = get_rpc_namespace(node_id)
result = await rabbitmq_rpc_client.request(
rpc_namespace,
TypeAdapter(RPCMethodName).validate_python("get_containers_name"),
filters=filters,
)
assert isinstance(result, str)
return result


@log_decorator(_logger, level=logging.DEBUG)
async def inspect_container(
rabbitmq_rpc_client: RabbitMQRPCClient, *, node_id: NodeID, container_id: str
) -> dict[str, Any]:
rpc_namespace = get_rpc_namespace(node_id)
result = await rabbitmq_rpc_client.request(
rpc_namespace,
TypeAdapter(RPCMethodName).validate_python("inspect_container"),
container_id=container_id,
)
assert isinstance(result, dict)
return result
50 changes: 33 additions & 17 deletions services/dynamic-sidecar/openapi.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@
"tags": [
"containers"
],
"summary": "Store Compose Spec",
"summary": "Create Compose Spec",
"description": "Validates and stores the docker compose spec for the user services.",
"operationId": "store_compose_spec_v1_containers_compose_spec_post",
"operationId": "create_compose_spec_v1_containers_compose_spec_post",
"requestBody": {
"content": {
"application/json": {
Expand Down Expand Up @@ -164,7 +164,8 @@
"tags": [
"containers"
],
"summary": "Starts the containers as defined in ContainerCreate by:\n- cleaning up resources from previous runs if any\n- starting the containers\n\nProgress may be obtained through URL\nProcess may be cancelled through URL",
"summary": "Create Containers",
"description": "Starts the containers as defined in ContainerCreate by:\n- cleaning up resources from previous runs if any\n- starting the containers\n\nProgress may be obtained through URL\nProcess may be cancelled through URL",
"operationId": "create_containers_v1_containers_post",
"requestBody": {
"required": true,
Expand Down Expand Up @@ -207,6 +208,7 @@
"containers"
],
"summary": "Get Containers Activity",
"description": "If user service declared an inactivity hook, this enpoint provides\ninforamtion about how much time has passed since the service became inactive.",
"operationId": "get_containers_activity_v1_containers_activity_get",
"responses": {
"200": {
Expand Down Expand Up @@ -336,7 +338,8 @@
"tags": [
"containers"
],
"summary": "Enable/disable ports i/o",
"summary": "Toggle Ports Io",
"description": "Enable/disable ports i/o",
"operationId": "toggle_ports_io_v1_containers_ports_io_patch",
"requestBody": {
"content": {
Expand Down Expand Up @@ -370,7 +373,8 @@
"tags": [
"containers"
],
"summary": "Creates the output directories declared by the docker images's labels. It is more convenient to pass the labels from director-v2, since it already has all the machinery to call into director-v0 to retrieve them.",
"summary": "Create Output Dirs",
"description": "Creates the output directories declared by the docker images's labels.\nIt is more convenient to pass the labels from director-v2,\nsince it already has all the machinery to call into director-v0\nto retrieve them.",
"operationId": "create_output_dirs_v1_containers_ports_outputs_dirs_post",
"requestBody": {
"content": {
Expand Down Expand Up @@ -404,7 +408,8 @@
"tags": [
"containers"
],
"summary": "attach container to a network, if not already attached",
"summary": "Attach Container To Network",
"description": "attach container to a network, if not already attached",
"operationId": "attach_container_to_network_v1_containers__id__networks_attach_post",
"parameters": [
{
Expand Down Expand Up @@ -449,7 +454,8 @@
"tags": [
"containers"
],
"summary": "detach container from a network, if not already detached",
"summary": "Detach Container From Network",
"description": "detach container from a network, if not already detached",
"operationId": "detach_container_from_network_v1_containers__id__networks_detach_post",
"parameters": [
{
Expand Down Expand Up @@ -494,7 +500,8 @@
"tags": [
"containers"
],
"summary": "Pulls all the docker container images for the user services",
"summary": "Pull Container Images",
"description": "Pulls all the docker container images for the user services",
"operationId": "pull_container_images_v1_containers_images_pull_post",
"responses": {
"202": {
Expand All @@ -516,7 +523,8 @@
"tags": [
"containers"
],
"summary": "Remove the previously started containers",
"summary": "Down Containers",
"description": "Remove the previously started containers",
"operationId": "down_containers_v1_containers_down_post",
"responses": {
"202": {
Expand All @@ -538,7 +546,8 @@
"tags": [
"containers"
],
"summary": "Restores the state of the dynamic service",
"summary": "Restore Containers State Paths",
"description": "Restores the state of the dynamic service",
"operationId": "restore_containers_state_paths_v1_containers_state_restore_post",
"responses": {
"202": {
Expand All @@ -560,7 +569,8 @@
"tags": [
"containers"
],
"summary": "Stores the state of the dynamic service",
"summary": "Save Containers State Paths",
"description": "Stores the state of the dynamic service",
"operationId": "save_containers_state_paths_v1_containers_state_save_post",
"responses": {
"202": {
Expand All @@ -582,7 +592,8 @@
"tags": [
"containers"
],
"summary": "Pull input ports data",
"summary": "Pull Container Port Inputs",
"description": "Pull input ports data",
"operationId": "pull_container_port_inputs_v1_containers_ports_inputs_pull_post",
"requestBody": {
"content": {
Expand Down Expand Up @@ -634,7 +645,8 @@
"tags": [
"containers"
],
"summary": "Pull output ports data",
"summary": "Pull Container Port Outputs",
"description": "Pull output ports data",
"operationId": "pull_container_port_outputs_v1_containers_ports_outputs_pull_post",
"requestBody": {
"content": {
Expand Down Expand Up @@ -686,7 +698,8 @@
"tags": [
"containers"
],
"summary": "Push output ports data",
"summary": "Push Container Port Outputs",
"description": "Push output ports data",
"operationId": "push_container_port_outputs_v1_containers_ports_outputs_push_post",
"responses": {
"202": {
Expand All @@ -708,7 +721,8 @@
"tags": [
"containers"
],
"summary": "Restarts previously started user services",
"summary": "Restart Containers",
"description": "Restarts previously started user services",
"operationId": "restart_containers_v1_containers_restart_post",
"responses": {
"202": {
Expand All @@ -730,7 +744,8 @@
"tags": [
"volumes"
],
"summary": "Updates the state of the volume",
"summary": "Put Volume State",
"description": "Updates the state of the volume",
"operationId": "put_volume_state_v1_volumes__id__put",
"parameters": [
{
Expand Down Expand Up @@ -774,7 +789,8 @@
"tags": [
"disk"
],
"summary": "Frees up reserved disk space",
"summary": "Free Reserved Disk Space",
"description": "Frees up reserved disk space",
"operationId": "free_reserved_disk_space_v1_disk_reserved_free_post",
"responses": {
"204": {
Expand Down
Loading
Loading