Skip to content

Commit

Permalink
Add Session node setting method
Browse files Browse the repository at this point in the history
  • Loading branch information
markheik committed Aug 30, 2023
1 parent 2b05e6e commit f762b83
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion src/labone/core/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import capnp
from typing_extensions import Literal, NotRequired, TypeAlias, TypedDict

from labone.core import errors
from labone.core import errors, result
from labone.core import value as annotated_value
from labone.core.connection_layer import (
KernelInfo,
ServerInfo,
Expand Down Expand Up @@ -405,3 +406,25 @@ async def list_nodes_info(
raise TypeError(msg) from error
response = await _send_and_wait_request(request)
return json.loads(response.nodeProps)

async def set_value(
self,
value: annotated_value.AnnotatedValue,
) -> annotated_value.AnnotatedValue:
"""Set the value of a node.
TODO: Tests
Args:
value: Annotated value of the node.
TODO: To accept list of `AnnotatedValue`s
Raises:
LabOneConnectionError: If there is a problem in the connection.
"""
request = self._session.setValue_request()
request.path = value.path
request.value = value.value
response = await _send_and_wait_request(request)
res = result.unwrap(response.result)
return annotated_value.AnnotatedValue.from_capnp(res)

0 comments on commit f762b83

Please sign in to comment.