Skip to content

Commit

Permalink
Merge branch 'master' into pr-osparc-cleanup-untracked-services
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHK authored Oct 29, 2024
2 parents 80f9674 + 50076aa commit 6654195
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 48 deletions.
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
from typing import Final

from pydantic import parse_obj_as

from ..rabbitmq_basic_types import RPCNamespace

DYNAMIC_SIDECAR_RPC_NAMESPACE: Final[RPCNamespace] = parse_obj_as(
RPCNamespace, "dynamic-sidecar"
)
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import logging

from models_library.api_schemas_dynamic_sidecar import DYNAMIC_SIDECAR_RPC_NAMESPACE
from models_library.api_schemas_dynamic_sidecar.telemetry import DiskUsage
from models_library.rabbitmq_basic_types import RPCMethodName
from models_library.projects_nodes_io import NodeID
from models_library.rabbitmq_basic_types import RPCMethodName, RPCNamespace
from pydantic import parse_obj_as
from servicelib.logging_utils import log_decorator
from servicelib.rabbitmq import RabbitMQRPCClient
Expand All @@ -12,11 +12,15 @@

@log_decorator(_logger, level=logging.DEBUG)
async def update_disk_usage(
rabbitmq_rpc_client: RabbitMQRPCClient, *, usage: dict[str, DiskUsage]
rabbitmq_rpc_client: RabbitMQRPCClient,
*,
node_id: NodeID,
usage: dict[str, DiskUsage],
) -> None:
rpc_namespace = RPCNamespace.from_entries(
{"service": "dy-sidecar", "node_id": f"{node_id}"}
)
result = await rabbitmq_rpc_client.request(
DYNAMIC_SIDECAR_RPC_NAMESPACE,
parse_obj_as(RPCMethodName, "update_disk_usage"),
usage=usage,
rpc_namespace, parse_obj_as(RPCMethodName, "update_disk_usage"), usage=usage
)
assert result is None # nosec
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from fastapi import FastAPI
from models_library.api_schemas_dynamic_sidecar import DYNAMIC_SIDECAR_RPC_NAMESPACE
from models_library.rabbitmq_basic_types import RPCNamespace
from servicelib.rabbitmq import RPCRouter

from ...core.rabbitmq import get_rabbitmq_rpc_server
from ...core.settings import ApplicationSettings
from . import _disk_usage

ROUTERS: list[RPCRouter] = [
Expand All @@ -13,7 +14,12 @@
def setup_rpc_api_routes(app: FastAPI) -> None:
async def startup() -> None:
rpc_server = get_rabbitmq_rpc_server(app)
settings: ApplicationSettings = app.state.settings

rpc_namespace = RPCNamespace.from_entries(
{"service": "dy-sidecar", "node_id": f"{settings.DY_SIDECAR_NODE_ID}"}
)
for router in ROUTERS:
await rpc_server.register_router(router, DYNAMIC_SIDECAR_RPC_NAMESPACE, app)
await rpc_server.register_router(router, rpc_namespace, app)

app.add_event_handler("startup", startup)
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
from settings_library.rabbit import RabbitSettings
from settings_library.redis import RedisSettings
from simcore_service_dynamic_sidecar.core.application import create_app
from simcore_service_dynamic_sidecar.core.settings import ApplicationSettings
from simcore_service_dynamic_sidecar.modules.system_monitor._disk_usage import (
get_disk_usage_monitor,
)
Expand Down Expand Up @@ -69,8 +70,11 @@ async def test_get_state(app: FastAPI, rpc_client: RabbitMQRPCClient):
total=ByteSize(0), used=ByteSize(0), free=ByteSize(0), used_percent=0
)
}
settings: ApplicationSettings = app.state.settings

result = await disk_usage.update_disk_usage(rpc_client, usage=usage)
result = await disk_usage.update_disk_usage(
rpc_client, node_id=settings.DY_SIDECAR_NODE_ID, usage=usage
)
assert result is None

assert get_disk_usage_monitor(app)._usage_overwrite == usage # noqa: SLF001
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@ qx.Class.define("osparc.ui.basic.LinkLabel", {

members: {
__applyUrl: function(url) {
this.set({
url,
cursor: "pointer",
font: "link-label-12"
});

this.addListener("click", this.__onClick);
if (url) {
this.set({
cursor: "pointer",
font: "link-label-12",
});
this.addListener("click", this.__onClick);
} else {
this.resetCursor();
this.resetFont();
}
},

__onClick: function() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -474,15 +474,15 @@ qx.Class.define("osparc.workbench.NodeUI", {
const width = 150;
this.__setNodeUIWidth(width);

const label = new qx.ui.basic.Label().set({
const linkLabel = new osparc.ui.basic.LinkLabel().set({
paddingLeft: 5,
font: "text-18"
font: "text-12"
});
const chipContainer = this.getChildControl("chips");
chipContainer.add(label);
chipContainer.add(linkLabel);

this.getNode().getPropsForm().addListener("linkFieldModified", () => this.__setProbeValue(label), this);
this.__setProbeValue(label);
this.getNode().getPropsForm().addListener("linkFieldModified", () => this.__setProbeValue(linkLabel), this);
this.__setProbeValue(linkLabel);
},

__checkTurnIntoIteratorUI: function() {
Expand All @@ -504,21 +504,19 @@ qx.Class.define("osparc.workbench.NodeUI", {
}
},

__setProbeValue: function(label) {
const replaceByLinkLabel = val => {
__setProbeValue: function(linkLabel) {
const populateLinkLabel = linkInfo => {
const download = true;
const locationId = val.store;
const fileId = val.path;
const locationId = linkInfo.store;
const fileId = linkInfo.path;
osparc.store.Data.getInstance().getPresignedLink(download, locationId, fileId)
.then(presignedLinkData => {
if ("resp" in presignedLinkData && presignedLinkData.resp) {
const filename = val.filename || osparc.file.FilePicker.getFilenameFromPath(val);
const linkLabel = new osparc.ui.basic.LinkLabel(filename, presignedLinkData.resp.link).set({
font: "link-label-12"
const filename = linkInfo.filename || osparc.file.FilePicker.getFilenameFromPath(linkInfo);
linkLabel.set({
value: filename,
url: presignedLinkData.resp.link
});
const chipContainer = this.getChildControl("chips");
chipContainer.remove(label);
chipContainer.add(linkLabel);
}
});
}
Expand All @@ -529,19 +527,15 @@ qx.Class.define("osparc.workbench.NodeUI", {
const portKey = link["output"];
const inputNode = this.getNode().getWorkbench().getNode(inputNodeId);
if (inputNode) {
inputNode.bind("outputs", label, "value", {
inputNode.bind("outputs", linkLabel, "value", {
converter: outputs => {
if (portKey in outputs && "value" in outputs[portKey]) {
if (portKey in outputs && "value" in outputs[portKey] && outputs[portKey]["value"]) {
const val = outputs[portKey]["value"];
if (this.getNode().getMetaData()["key"].includes("probe/array")) {
return "[" + val.join(",") + "]";
} else if (this.getNode().getMetaData()["key"].includes("probe/file")) {
const filename = val.filename || osparc.file.FilePicker.getFilenameFromPath(val);
label.set({
font: "text-12",
rich: true
});
replaceByLinkLabel(val);
populateLinkLabel(val);
return filename;
}
return String(val);
Expand All @@ -551,7 +545,7 @@ qx.Class.define("osparc.workbench.NodeUI", {
});
}
} else {
label.setValue("");
linkLabel.setValue("");
}
},

Expand Down

0 comments on commit 6654195

Please sign in to comment.