Skip to content

Commit f83db20

Browse files
author
Andrei Neagu
committed
added docstrings
1 parent a6677f7 commit f83db20

File tree

7 files changed

+58
-3
lines changed

7 files changed

+58
-3
lines changed

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/api/rest/containers.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,13 @@ async def containers_docker_inspect(
6464
)
6565

6666

67-
@router.get(
68-
"/containers/activity",
69-
)
67+
@router.get("/containers/activity")
7068
@cancel_on_disconnect
7169
async def get_containers_activity(request: Request) -> ActivityInfoOrNone:
70+
"""
71+
If user service declared an inactivity hook, this enpoint provides
72+
inforamtion about how much time has passed since the service became inactive.
73+
"""
7274
_ = request
7375
return await containers.get_containers_activity(app=request.app)
7476

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/api/rpc/_containers.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ async def create_compose_spec(
1919
*,
2020
containers_compose_spec: ContainersComposeSpec,
2121
) -> None:
22+
"""
23+
Validates and stores the docker compose spec for the user services.
24+
"""
2225
await containers.create_compose_spec(
2326
app, containers_compose_spec=containers_compose_spec
2427
)
@@ -28,19 +31,38 @@ async def create_compose_spec(
2831
async def containers_docker_inspect(
2932
app: FastAPI, *, only_status: bool
3033
) -> dict[str, Any]:
34+
"""
35+
Returns entire docker inspect data, if only_state is True,
36+
the status of the containers is returned
37+
"""
3138
return await containers.containers_docker_inspect(app, only_status=only_status)
3239

3340

3441
@router.expose()
3542
async def get_containers_activity(app: FastAPI) -> ActivityInfoOrNone:
43+
"""
44+
If user service declared an inactivity hook, this enpoint provides
45+
inforamtion about how much time has passed since the service became inactive.
46+
"""
3647
return await containers.get_containers_activity(app=app)
3748

3849

3950
@router.expose()
4051
async def get_containers_name(app: FastAPI, *, filters: str) -> str | dict[str, Any]:
52+
"""
53+
Searches for the container's name given the network
54+
on which the proxy communicates with it.
55+
Supported filters:
56+
network: matches against the exact network name
57+
assigned to the container; `will include`
58+
containers
59+
exclude: matches if contained in the name of the
60+
container; `will exclude` containers
61+
"""
4162
return await containers.get_containers_name(app=app, filters=filters)
4263

4364

4465
@router.expose()
4566
async def inspect_container(app: FastAPI, *, container_id: str) -> dict[str, Any]:
67+
"""Returns information about the container, like docker inspect command"""
4668
return await containers.inspect_container(app=app, container_id=container_id)

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/api/rpc/_containers_extension.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
async def toggle_ports_io(
1212
app: FastAPI, *, enable_outputs: bool, enable_inputs: bool
1313
) -> None:
14+
"""Enable/disable ports i/o"""
1415
await container_extensions.toggle_ports_io(
1516
app, enable_outputs=enable_outputs, enable_inputs=enable_inputs
1617
)
@@ -20,13 +21,20 @@ async def toggle_ports_io(
2021
async def create_output_dirs(
2122
app: FastAPI, *, outputs_labels: dict[str, ServiceOutput]
2223
) -> None:
24+
"""
25+
Creates the output directories declared by the docker images's labels.
26+
It is more convenient to pass the labels from director-v2,
27+
since it already has all the machinery to call into director-v0
28+
to retrieve them.
29+
"""
2330
await container_extensions.create_output_dirs(app, outputs_labels=outputs_labels)
2431

2532

2633
@router.expose()
2734
async def attach_container_to_network(
2835
app: FastAPI, *, container_id: str, network_id: str, network_aliases: list[str]
2936
) -> None:
37+
"""attach container to a network, if not already attached"""
3038
_ = app
3139
await container_extensions.attach_container_to_network(
3240
container_id=container_id,
@@ -39,6 +47,7 @@ async def attach_container_to_network(
3947
async def detach_container_from_network(
4048
app: FastAPI, *, container_id: str, network_id: str
4149
) -> None:
50+
"""detach container from a network, if not already detached"""
4251
_ = app
4352
await container_extensions.detach_container_from_network(
4453
container_id=container_id, network_id=network_id

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/api/rpc/_containers_long_running_tasks.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
async def pull_user_services_images(
1414
app: FastAPI, *, lrt_namespace: LRTNamespace
1515
) -> TaskId:
16+
"""Pulls all the docker container images for the user services"""
1617
rpc_client = get_rabbitmq_rpc_client(app)
1718
return await containers_long_running_tasks.pull_user_services_images(
1819
rpc_client, lrt_namespace
@@ -23,6 +24,14 @@ async def pull_user_services_images(
2324
async def create_user_services(
2425
app: FastAPI, *, lrt_namespace: LRTNamespace, containers_create: ContainersCreate
2526
) -> TaskId:
27+
"""
28+
Starts the containers as defined in ContainerCreate by:
29+
- cleaning up resources from previous runs if any
30+
- starting the containers
31+
32+
Progress may be obtained through URL
33+
Process may be cancelled through URL
34+
"""
2635
rpc_client = get_rabbitmq_rpc_client(app)
2736
return await containers_long_running_tasks.create_user_services(
2837
rpc_client, lrt_namespace, containers_create
@@ -31,6 +40,7 @@ async def create_user_services(
3140

3241
@router.expose()
3342
async def remove_user_services(app: FastAPI, *, lrt_namespace: LRTNamespace) -> TaskId:
43+
"""Remove the previously started containers"""
3444
rpc_client = get_rabbitmq_rpc_client(app)
3545
return await containers_long_running_tasks.remove_user_services(
3646
rpc_client, lrt_namespace
@@ -41,6 +51,7 @@ async def remove_user_services(app: FastAPI, *, lrt_namespace: LRTNamespace) ->
4151
async def restore_user_services_state_paths(
4252
app: FastAPI, *, lrt_namespace: LRTNamespace
4353
) -> TaskId:
54+
"""Restores the state of the dynamic service"""
4455
rpc_client = get_rabbitmq_rpc_client(app)
4556
return await containers_long_running_tasks.restore_user_services_state_paths(
4657
rpc_client, lrt_namespace
@@ -51,6 +62,7 @@ async def restore_user_services_state_paths(
5162
async def save_user_services_state_paths(
5263
app: FastAPI, *, lrt_namespace: LRTNamespace
5364
) -> TaskId:
65+
"""Stores the state of the dynamic service"""
5466
rpc_client = get_rabbitmq_rpc_client(app)
5567
return await containers_long_running_tasks.save_user_services_state_paths(
5668
rpc_client, lrt_namespace
@@ -64,6 +76,7 @@ async def pull_user_services_input_ports(
6476
lrt_namespace: LRTNamespace,
6577
port_keys: list[str] | None,
6678
) -> TaskId:
79+
"""Pull input ports data"""
6780
rpc_client = get_rabbitmq_rpc_client(app)
6881
return await containers_long_running_tasks.pull_user_services_input_ports(
6982
rpc_client, lrt_namespace, port_keys
@@ -77,6 +90,7 @@ async def pull_user_services_output_ports(
7790
lrt_namespace: LRTNamespace,
7891
port_keys: list[str] | None,
7992
) -> TaskId:
93+
"""Pull output ports data"""
8094
rpc_client = get_rabbitmq_rpc_client(app)
8195
return await containers_long_running_tasks.pull_user_services_output_ports(
8296
rpc_client, lrt_namespace, port_keys
@@ -87,6 +101,7 @@ async def pull_user_services_output_ports(
87101
async def push_user_services_output_ports(
88102
app: FastAPI, *, lrt_namespace: LRTNamespace
89103
) -> TaskId:
104+
"""Push output ports data"""
90105
rpc_client = get_rabbitmq_rpc_client(app)
91106
return await containers_long_running_tasks.push_user_services_output_ports(
92107
rpc_client, lrt_namespace
@@ -95,6 +110,7 @@ async def push_user_services_output_ports(
95110

96111
@router.expose()
97112
async def restart_user_services(app: FastAPI, *, lrt_namespace: LRTNamespace) -> TaskId:
113+
"""Restarts previously started user services"""
98114
rpc_client = get_rabbitmq_rpc_client(app)
99115
return await containers_long_running_tasks.restart_user_services(
100116
rpc_client, lrt_namespace

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/api/rpc/_disk.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@
88

99
@router.expose()
1010
async def free_reserved_disk_space(_: FastAPI) -> None:
11+
"""Frees up reserved disk space"""
1112
disk.free_reserved_disk_space()

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/api/rpc/_disk_usage.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@
1515
@router.expose()
1616
@validate_call(config={"arbitrary_types_allowed": True})
1717
async def update_disk_usage(app: FastAPI, *, usage: dict[str, DiskUsage]) -> None:
18+
"""
19+
Updates the report disk usage to the forntend via external tooling.
20+
Used by the efs guardian.
21+
"""
1822
disk_usage_monitor = get_disk_usage_monitor(app)
1923

2024
if disk_usage_monitor is None:

services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/api/rpc/_volumes.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@
1313
async def update_volume_status(
1414
app: FastAPI, *, status: VolumeStatus, category: VolumeCategory
1515
) -> None:
16+
"""Updates the state of the volume"""
1617
await volumes.update_volume_status(app, status=status, category=category)

0 commit comments

Comments
 (0)