-
Notifications
You must be signed in to change notification settings - Fork 38
add a virtual printer device #197
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
base: dev
Are you sure you want to change the base?
Conversation
Reviewer's GuideImplements a new VirtualPrinter virtual device that logs and prints received message payloads, wires it into the device registry with appropriate action schemas and status fields, and ensures the cleanup routine reports failure after transitioning the device to an offline state. Class diagram for the new VirtualPrinter deviceclassDiagram
class BaseROS2DeviceNode
class VirtualPrinter {
- BaseROS2DeviceNode _ros_node
- str device_id
- dict config
- Logger logger
- dict data
- str port
- str prefix
- bool pretty
+ VirtualPrinter(device_id: str, config: dict, kwargs: dict)
+ post_init(ros_node: BaseROS2DeviceNode) void
+ initialize() bool
+ cleanup() bool
+ print_message(content: Any, kwargs: dict) dict
+ receive(args: list, kwargs: dict) dict
- _record_and_print(action: str, content: Any, kwargs: dict) void
+ status() str
+ message() str
+ last_received() Any
+ received_count() int
}
VirtualPrinter --> BaseROS2DeviceNode : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey there - I've reviewed your changes - here's some feedback:
- The
print_messageandreceivemethods return amessagefield in their result dicts, but thevirtual_printer.print_messageaction schema only declaressuccessandreturn_info; consider aligning the return shape with the schema or extending the schema to includemessageto avoid downstream assumptions breaking. - In
_record_and_print, thekwargsargument is logged separately butreceivecurrently passeskwargs={}while embedding the original kwargs insidecontent, which may be confusing for consumers expecting top-level kwargs in the record; consider either passing the real kwargs through or removing the extrakwargsfield from the record. - Since this is a virtual device used for debugging, it may still be worth standardizing on logging (
self.logger) instead ofprint(or gatingprintbehind a config flag) to keep output behavior consistent with other devices and avoid noisy stdout in some deployments.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- The `print_message` and `receive` methods return a `message` field in their result dicts, but the `virtual_printer.print_message` action schema only declares `success` and `return_info`; consider aligning the return shape with the schema or extending the schema to include `message` to avoid downstream assumptions breaking.
- In `_record_and_print`, the `kwargs` argument is logged separately but `receive` currently passes `kwargs={}` while embedding the original kwargs inside `content`, which may be confusing for consumers expecting top-level kwargs in the record; consider either passing the real kwargs through or removing the extra `kwargs` field from the record.
- Since this is a virtual device used for debugging, it may still be worth standardizing on logging (`self.logger`) instead of `print` (or gating `print` behind a config flag) to keep output behavior consistent with other devices and avoid noisy stdout in some deployments.
## Individual Comments
### Comment 1
<location> `unilabos/registry/devices/virtual_device.yaml:2549-2558` </location>
<code_context>
+ type: object
+ data:
+ properties:
+ last_received:
+ type: object
+ message:
+ type: string
+ received_count:
+ type: integer
+ status:
+ type: string
+ required:
+ - status
+ - message
+ - received_count
+ - last_received
+ type: object
+ version: 1.0.0
</code_context>
<issue_to_address>
**issue (bug_risk):** `last_received` is declared required and non-nullable in schema but initialized to `None` in code.
In `init_param_schema.data`, `last_received` is required and typed as `object`, but `initialize()` sets it to `None`. This schema/runtime mismatch can break validation or serialization (JSON `object` vs `null`). Please either initialize it as `{}` or update the schema to allow `null` and/or make it optional.
</issue_to_address>Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
| last_received: | ||
| type: object | ||
| message: | ||
| type: string | ||
| received_count: | ||
| type: integer | ||
| status: | ||
| type: string | ||
| required: | ||
| - status |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
issue (bug_risk): last_received is declared required and non-nullable in schema but initialized to None in code.
In init_param_schema.data, last_received is required and typed as object, but initialize() sets it to None. This schema/runtime mismatch can break validation or serialization (JSON object vs null). Please either initialize it as {} or update the schema to allow null and/or make it optional.
add a virtual printer device
cleanup function return False
Summary by Sourcery
Add a virtual printer debugging device that logs received messages and tracks basic status information.
New Features:
Bug Fixes: