Skip to content

Conversation

@mikeprosserni
Copy link
Collaborator

@mikeprosserni mikeprosserni commented Jul 14, 2025

What does this Pull Request accomplish?

Renames PythonPanelService.GetValue() to TryGetValue(), and add a .GetValue() that throws NOT_FOUND when the value is not found.

Also updates PanelClient accordingly.

Why should this Pull Request be merged?

Since GetValue() returns a boolean indicating success rather than throwing an exception, it would be better to call it TryGetValue(). But we also want a GetValue() that throws if the value is not found.

What testing has been done?

test___no_value___get_value___raises_exception
test___set_value___get_value___gets_response
test___no_value___try_get_value___gets_no_value
test___set_value___try_get_value___gets_response
test___get_unset_value___raises_exception
test___try_get_unset_value___returns_not_found

@github-actions
Copy link
Contributor

github-actions bot commented Jul 14, 2025

Test Results

   10 files  ± 0     10 suites  ±0   22s ⏱️ -9s
  221 tests + 5    221 ✅ + 5  0 💤 ±0  0 ❌ ±0 
2 160 runs  +50  2 160 ✅ +50  0 💤 ±0  0 ❌ ±0 

Results for commit 628d03a. ± Comparison against base commit 098c4b2.

This pull request removes 1 and adds 6 tests. Note that renamed tests count towards both.
tests.unit.test_panel_client ‑ test___get_unset_value___returns_not_found
tests.unit.test_convert ‑ test___none_value___to_any___raises_type_error
tests.unit.test_panel_client ‑ test___get_unset_value___raises_exception
tests.unit.test_panel_client ‑ test___try_get_unset_value___returns_none
tests.unit.test_python_panel_service_stub ‑ test___no_value___get_value___raises_exception
tests.unit.test_python_panel_service_stub ‑ test___no_value___try_get_value___gets_no_value
tests.unit.test_python_panel_service_stub ‑ test___set_value___try_get_value___gets_response

♻️ This comment has been updated with latest results.

@mikeprosserni mikeprosserni requested a review from Copilot July 14, 2025 21:26
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

A concise description of the purpose of the PR, followed by summarized bullets of changes

  • Introduce a non-throwing TryGetValue RPC alongside the existing GetValue RPC
  • Update client code and test fixtures to call try_get_value and handle missing values without exceptions
  • Revise gRPC stubs, servicer, and proto definitions to include TryGetValue and TryGetValueResponse

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/utils/_fake_python_panel_servicer.py Added TryGetValue method and imported TryGetValueResponse
tests/unit/test_python_panel_service_stub.py Added tests for TryGetValue and updated exception test for GetValue
tests/unit/test_panel_client.py Renamed exception test for get_value, added try_get_value tests
src/nipanel/_panel_value_accessor.py Switched from get_value to try_get_value internally
src/nipanel/_panel_client.py Refactored get_value, added try_get_value and updated stubs
src/ni/pythonpanel/v1/python_panel_service_pb2_grpc.pyi Updated stub interface and documentation for TryGetValue
src/ni/pythonpanel/v1/python_panel_service_pb2_grpc.py Added TryGetValue to both stub and servicer definitions
src/ni/pythonpanel/v1/python_panel_service_pb2.pyi Introduced TryGetValueResponse type and updated alias
src/ni/pythonpanel/v1/python_panel_service_pb2.py Updated serialized descriptor to include TryGetValueResponse and RPC
protos/ni/pythonpanel/v1/python_panel_service.proto Added TryGetValue RPC and TryGetValueResponse message
Comments suppressed due to low confidence (2)

src/nipanel/_panel_client.py:129

  • The variable name try_get_value_request in get_value is misleading since this method uses the GetValue RPC; rename it to get_value_request for clarity.
        try_get_value_request = GetValueRequest(panel_id=panel_id, value_id=value_id)

src/nipanel/_panel_client.py:119

  • Add a Raises: section to the docstring noting that a grpc.RpcError with StatusCode.NOT_FOUND is thrown if the value isn't set.
    def get_value(self, panel_id: str, value_id: str) -> object:

@mikeprosserni mikeprosserni changed the title Rename PythonPanelService.GetValue to TryGetValue PythonPanelService.GetValue() and .TryGetValue() Jul 14, 2025
@mikeprosserni mikeprosserni marked this pull request as ready for review July 14, 2025 22:07
@mikeprosserni mikeprosserni requested a review from csjall as a code owner July 14, 2025 22:07
Copy link
Collaborator

@bkeryan bkeryan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with suggestions

@mikeprosserni mikeprosserni merged commit d50966b into main Jul 15, 2025
14 checks passed
@mikeprosserni mikeprosserni deleted the users/mprosser/try-get-value branch July 15, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants