-
Couldn't load subscription status.
- Fork 0
Implement connect() and disconnect() #5
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
Merged
mikeprosserni
merged 17 commits into
main
from
users/mprosser/task-3095680-connect-disconnect
Apr 26, 2025
Merged
Changes from 12 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
c971b3a
first draft (breaks tests)
394b74a
PanelNotFoundError when gRPC status code is NOT_FOUND
5d5404f
fix linter issues
d0835f1
create a basic fake server and passing basic tests for it
fc049cc
use FakePanel to fix failing tests
a6c76d6
move fixture to conftest.py
bb5ea94
remove unused serve() function
a7e4914
cleanup
c7f5f78
use a channel pool
d971106
add a retry if connect fails, and remove PanelNotFoundError
426aa54
cleanup
74847dc
refactor to use PanelClient
e3bc460
misc feedback and FakePythonPanelService
13cc155
PanelClient cleanup
2e1aeb2
use channel parameter for testing instead of PortPanel, and move prov…
5b0cf66
misc feedback
5f873b7
don't return tuples from fixtures
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,144 @@ | ||
| """ | ||
| @generated by mypy-protobuf. Do not edit manually! | ||
| isort:skip_file | ||
| """ | ||
|
|
||
| import builtins | ||
| import google.protobuf.any_pb2 | ||
| import google.protobuf.descriptor | ||
| import google.protobuf.message | ||
| import typing | ||
|
|
||
| DESCRIPTOR: google.protobuf.descriptor.FileDescriptor | ||
|
|
||
| @typing.final | ||
| class ConnectRequest(google.protobuf.message.Message): | ||
| DESCRIPTOR: google.protobuf.descriptor.Descriptor | ||
|
|
||
| PANEL_ID_FIELD_NUMBER: builtins.int | ||
| PANEL_URI_FIELD_NUMBER: builtins.int | ||
| panel_id: builtins.str | ||
| """Unique ID of the panel""" | ||
| panel_uri: builtins.str | ||
| """Absolute path of the panel's file on disk, or network path to the file""" | ||
| def __init__( | ||
| self, | ||
| *, | ||
| panel_id: builtins.str = ..., | ||
| panel_uri: builtins.str = ..., | ||
| ) -> None: ... | ||
| def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id", "panel_uri", b"panel_uri"]) -> None: ... | ||
|
|
||
| global___ConnectRequest = ConnectRequest | ||
|
|
||
| @typing.final | ||
| class ConnectResponse(google.protobuf.message.Message): | ||
| DESCRIPTOR: google.protobuf.descriptor.Descriptor | ||
|
|
||
| def __init__( | ||
| self, | ||
| ) -> None: ... | ||
|
|
||
| global___ConnectResponse = ConnectResponse | ||
|
|
||
| @typing.final | ||
| class DisconnectRequest(google.protobuf.message.Message): | ||
| DESCRIPTOR: google.protobuf.descriptor.Descriptor | ||
|
|
||
| PANEL_ID_FIELD_NUMBER: builtins.int | ||
| panel_id: builtins.str | ||
| """Unique ID of the panel""" | ||
| def __init__( | ||
| self, | ||
| *, | ||
| panel_id: builtins.str = ..., | ||
| ) -> None: ... | ||
| def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id"]) -> None: ... | ||
|
|
||
| global___DisconnectRequest = DisconnectRequest | ||
|
|
||
| @typing.final | ||
| class DisconnectResponse(google.protobuf.message.Message): | ||
| DESCRIPTOR: google.protobuf.descriptor.Descriptor | ||
|
|
||
| def __init__( | ||
| self, | ||
| ) -> None: ... | ||
|
|
||
| global___DisconnectResponse = DisconnectResponse | ||
|
|
||
| @typing.final | ||
| class GetValueRequest(google.protobuf.message.Message): | ||
| DESCRIPTOR: google.protobuf.descriptor.Descriptor | ||
|
|
||
| PANEL_ID_FIELD_NUMBER: builtins.int | ||
| VALUE_ID_FIELD_NUMBER: builtins.int | ||
| panel_id: builtins.str | ||
| """Unique ID of the panel""" | ||
| value_id: builtins.str | ||
| """Unique ID of value""" | ||
| def __init__( | ||
| self, | ||
| *, | ||
| panel_id: builtins.str = ..., | ||
| value_id: builtins.str = ..., | ||
| ) -> None: ... | ||
| def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id", "value_id", b"value_id"]) -> None: ... | ||
|
|
||
| global___GetValueRequest = GetValueRequest | ||
|
|
||
| @typing.final | ||
| class GetValueResponse(google.protobuf.message.Message): | ||
| DESCRIPTOR: google.protobuf.descriptor.Descriptor | ||
|
|
||
| VALUE_FIELD_NUMBER: builtins.int | ||
| @property | ||
| def value(self) -> google.protobuf.any_pb2.Any: | ||
| """The value""" | ||
|
|
||
| def __init__( | ||
| self, | ||
| *, | ||
| value: google.protobuf.any_pb2.Any | None = ..., | ||
| ) -> None: ... | ||
| def HasField(self, field_name: typing.Literal["value", b"value"]) -> builtins.bool: ... | ||
| def ClearField(self, field_name: typing.Literal["value", b"value"]) -> None: ... | ||
|
|
||
| global___GetValueResponse = GetValueResponse | ||
|
|
||
| @typing.final | ||
| class SetValueRequest(google.protobuf.message.Message): | ||
| DESCRIPTOR: google.protobuf.descriptor.Descriptor | ||
|
|
||
| PANEL_ID_FIELD_NUMBER: builtins.int | ||
| VALUE_ID_FIELD_NUMBER: builtins.int | ||
| VALUE_FIELD_NUMBER: builtins.int | ||
| panel_id: builtins.str | ||
| """Unique ID of the panel""" | ||
| value_id: builtins.str | ||
| """Unique ID of the value""" | ||
| @property | ||
| def value(self) -> google.protobuf.any_pb2.Any: | ||
| """The value""" | ||
|
|
||
| def __init__( | ||
| self, | ||
| *, | ||
| panel_id: builtins.str = ..., | ||
| value_id: builtins.str = ..., | ||
| value: google.protobuf.any_pb2.Any | None = ..., | ||
| ) -> None: ... | ||
| def HasField(self, field_name: typing.Literal["value", b"value"]) -> builtins.bool: ... | ||
| def ClearField(self, field_name: typing.Literal["panel_id", b"panel_id", "value", b"value", "value_id", b"value_id"]) -> None: ... | ||
|
|
||
| global___SetValueRequest = SetValueRequest | ||
|
|
||
| @typing.final | ||
| class SetValueResponse(google.protobuf.message.Message): | ||
| DESCRIPTOR: google.protobuf.descriptor.Descriptor | ||
|
|
||
| def __init__( | ||
| self, | ||
| ) -> None: ... | ||
|
|
||
| global___SetValueResponse = SetValueResponse |
146 changes: 146 additions & 0 deletions
146
src/ni/pythonpanel/v1/python_panel_service_pb2_grpc.pyi
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,146 @@ | ||
| """ | ||
| @generated by mypy-protobuf. Do not edit manually! | ||
| isort:skip_file | ||
| """ | ||
|
|
||
| import abc | ||
| import collections.abc | ||
| import grpc | ||
| import grpc.aio | ||
| import ni.pythonpanel.v1.python_panel_service_pb2 | ||
| import typing | ||
|
|
||
| _T = typing.TypeVar("_T") | ||
|
|
||
| class _MaybeAsyncIterator(collections.abc.AsyncIterator[_T], collections.abc.Iterator[_T], metaclass=abc.ABCMeta): ... | ||
|
|
||
| class _ServicerContext(grpc.ServicerContext, grpc.aio.ServicerContext): # type: ignore[misc, type-arg] | ||
| ... | ||
|
|
||
| class PythonPanelServiceStub: | ||
| """Service interface for connecting to python panels""" | ||
|
|
||
| def __init__(self, channel: typing.Union[grpc.Channel, grpc.aio.Channel]) -> None: ... | ||
| Connect: grpc.UnaryUnaryMultiCallable[ | ||
| ni.pythonpanel.v1.python_panel_service_pb2.ConnectRequest, | ||
| ni.pythonpanel.v1.python_panel_service_pb2.ConnectResponse, | ||
| ] | ||
| """Connect to a panel and open it | ||
| Status Codes for errors: | ||
| - NOT_FOUND: the file for the panel was not found | ||
| """ | ||
|
|
||
| Disconnect: grpc.UnaryUnaryMultiCallable[ | ||
| ni.pythonpanel.v1.python_panel_service_pb2.DisconnectRequest, | ||
| ni.pythonpanel.v1.python_panel_service_pb2.DisconnectResponse, | ||
| ] | ||
| """Disconnect from a panel (does not close the panel) | ||
| Status Codes for errors: | ||
| - NOT_FOUND: the panel with the specified id was not found | ||
| """ | ||
|
|
||
| GetValue: grpc.UnaryUnaryMultiCallable[ | ||
| ni.pythonpanel.v1.python_panel_service_pb2.GetValueRequest, | ||
| ni.pythonpanel.v1.python_panel_service_pb2.GetValueResponse, | ||
| ] | ||
| """Get a value for a control on the panel | ||
| Status Codes for errors: | ||
| - NOT_FOUND: the panel with the specified id was not found | ||
| """ | ||
|
|
||
| SetValue: grpc.UnaryUnaryMultiCallable[ | ||
| ni.pythonpanel.v1.python_panel_service_pb2.SetValueRequest, | ||
| ni.pythonpanel.v1.python_panel_service_pb2.SetValueResponse, | ||
| ] | ||
| """Set a value for a control on the panel | ||
| Status Codes for errors: | ||
| - NOT_FOUND: the panel with the specified id was not found | ||
| """ | ||
|
|
||
| class PythonPanelServiceAsyncStub: | ||
| """Service interface for connecting to python panels""" | ||
|
|
||
| Connect: grpc.aio.UnaryUnaryMultiCallable[ | ||
| ni.pythonpanel.v1.python_panel_service_pb2.ConnectRequest, | ||
| ni.pythonpanel.v1.python_panel_service_pb2.ConnectResponse, | ||
| ] | ||
| """Connect to a panel and open it | ||
| Status Codes for errors: | ||
| - NOT_FOUND: the file for the panel was not found | ||
| """ | ||
|
|
||
| Disconnect: grpc.aio.UnaryUnaryMultiCallable[ | ||
| ni.pythonpanel.v1.python_panel_service_pb2.DisconnectRequest, | ||
| ni.pythonpanel.v1.python_panel_service_pb2.DisconnectResponse, | ||
| ] | ||
| """Disconnect from a panel (does not close the panel) | ||
| Status Codes for errors: | ||
| - NOT_FOUND: the panel with the specified id was not found | ||
| """ | ||
|
|
||
| GetValue: grpc.aio.UnaryUnaryMultiCallable[ | ||
| ni.pythonpanel.v1.python_panel_service_pb2.GetValueRequest, | ||
| ni.pythonpanel.v1.python_panel_service_pb2.GetValueResponse, | ||
| ] | ||
| """Get a value for a control on the panel | ||
| Status Codes for errors: | ||
| - NOT_FOUND: the panel with the specified id was not found | ||
| """ | ||
|
|
||
| SetValue: grpc.aio.UnaryUnaryMultiCallable[ | ||
| ni.pythonpanel.v1.python_panel_service_pb2.SetValueRequest, | ||
| ni.pythonpanel.v1.python_panel_service_pb2.SetValueResponse, | ||
| ] | ||
| """Set a value for a control on the panel | ||
| Status Codes for errors: | ||
| - NOT_FOUND: the panel with the specified id was not found | ||
| """ | ||
|
|
||
| class PythonPanelServiceServicer(metaclass=abc.ABCMeta): | ||
| """Service interface for connecting to python panels""" | ||
|
|
||
| @abc.abstractmethod | ||
| def Connect( | ||
| self, | ||
| request: ni.pythonpanel.v1.python_panel_service_pb2.ConnectRequest, | ||
| context: _ServicerContext, | ||
| ) -> typing.Union[ni.pythonpanel.v1.python_panel_service_pb2.ConnectResponse, collections.abc.Awaitable[ni.pythonpanel.v1.python_panel_service_pb2.ConnectResponse]]: | ||
| """Connect to a panel and open it | ||
| Status Codes for errors: | ||
| - NOT_FOUND: the file for the panel was not found | ||
| """ | ||
|
|
||
| @abc.abstractmethod | ||
| def Disconnect( | ||
| self, | ||
| request: ni.pythonpanel.v1.python_panel_service_pb2.DisconnectRequest, | ||
| context: _ServicerContext, | ||
| ) -> typing.Union[ni.pythonpanel.v1.python_panel_service_pb2.DisconnectResponse, collections.abc.Awaitable[ni.pythonpanel.v1.python_panel_service_pb2.DisconnectResponse]]: | ||
| """Disconnect from a panel (does not close the panel) | ||
| Status Codes for errors: | ||
| - NOT_FOUND: the panel with the specified id was not found | ||
| """ | ||
|
|
||
| @abc.abstractmethod | ||
| def GetValue( | ||
| self, | ||
| request: ni.pythonpanel.v1.python_panel_service_pb2.GetValueRequest, | ||
| context: _ServicerContext, | ||
| ) -> typing.Union[ni.pythonpanel.v1.python_panel_service_pb2.GetValueResponse, collections.abc.Awaitable[ni.pythonpanel.v1.python_panel_service_pb2.GetValueResponse]]: | ||
| """Get a value for a control on the panel | ||
| Status Codes for errors: | ||
| - NOT_FOUND: the panel with the specified id was not found | ||
| """ | ||
|
|
||
| @abc.abstractmethod | ||
| def SetValue( | ||
| self, | ||
| request: ni.pythonpanel.v1.python_panel_service_pb2.SetValueRequest, | ||
| context: _ServicerContext, | ||
| ) -> typing.Union[ni.pythonpanel.v1.python_panel_service_pb2.SetValueResponse, collections.abc.Awaitable[ni.pythonpanel.v1.python_panel_service_pb2.SetValueResponse]]: | ||
| """Set a value for a control on the panel | ||
| Status Codes for errors: | ||
| - NOT_FOUND: the panel with the specified id was not found | ||
| """ | ||
|
|
||
| def add_PythonPanelServiceServicer_to_server(servicer: PythonPanelServiceServicer, server: typing.Union[grpc.Server, grpc.aio.Server]) -> None: ... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.