Uh oh!
There was an error while loading. Please reload this page.
store types as tuple of abstract types - #33
Conversation
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
fcec207 to
4b5a82dComparemikaelarguedas
commented
Mar 28, 2019
@dirk-thomas this has been rebased and modified to match changes from #34 and #35. In order to test that it fixes ros2/ros2cli#59, it needs to be used along ros2/ros2cli#209 (commit ros2/ros2cli@571d1eb) |
dirk-thomas
left a comment
There was a problem hiding this comment.
A few other packages are currently using get_fields_and_field_types: rqt_py_common, rqt_plot, rqt_publisher, rqt_service_caller. Do you think it is possible to update those to use the new API too?
Uh oh!
There was an error while loading. Please reload this page.
| '@(str(type_.maximum_size))')@ | ||
| @[ elif isinstance(type_, NamespacedType)]@ | ||
| @('/'.join([type_.namespaces[0], type_.name]))@ | ||
| ['@("', '".join(type_.namespaces))'], '@(type_.name)')@ |
There was a problem hiding this comment.
This is wrong if namespaces is empty.
There was a problem hiding this comment.
In which scenario would someone use a NamespacedType without namespace?
Is the expected syntax the following ?
NamespacedType([], 'myname')
instead of
NamespacedType([''], 'myname')
I can fix it in here, wouldn't the other places in this file using this logic need to be updated as well ?
e.g.
There was a problem hiding this comment.
In which scenario would someone use a NamespacedType without namespace?
There isn't a specific case where it is used atm but the code could be defensive and not rely on that assumption.
NamespacedType([], 'myname')
Correct.
wouldn't the other places in this file using this logic need to be updated as well ?
Probably, doesn't have to happen in this PR though. It's more a future proofing thing.
There was a problem hiding this comment.
Sounds good, added coverage for the empty namespaces in b95d02d
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
mikaelarguedas
commented
Apr 1, 2019
Yes it is possible, does this mean adding an explicit dependency on |
dirk-thomas
commented
Apr 1, 2019
Only if they would use any symbols directly from that package. Otherwise no, each message package will already depend on |
Uh oh!
There was an error while loading. Please reload this page.
mikaelarguedas
commented
Apr 1, 2019
Ok so either these packages use what is provided in the message itself ( Do you have a preference for the rqt packages? |
Uh oh!
There was an error while loading. Please reload this page.
dirk-thomas
commented
Apr 1, 2019
I don't have a preference. Either way is fine with me. |
mikaelarguedas
commented
Apr 1, 2019
Sounds good. |
Uh oh!
There was an error while loading. Please reload this page.
| field_elem_type = import_message_from_namespaced_type(rosidl_type) | ||
| for n in range(len(value)): | ||
| submsg = field_elem_type() | ||
| set_message_fields(submsg, value[n]) |
There was a problem hiding this comment.
value[n] looks weird here? Can you please extend the existing test of set_message_fields to cover this case of a nested namespaced type to make sure this works as expected.
Uh oh!
There was an error while loading. Please reload this page.
| @@ -33,4 +38,13 @@ def set_message_fields(msg: Any, values: Dict[str, str]) -> None: | |||
| except TypeError: | |||
| value = field_type() | |||
There was a problem hiding this comment.
I am surprised this works in cases where the field type is numpy.ndarray or array.array. Can you please also add a test with a static array (which would cover the numpy case).
There was a problem hiding this comment.
Yeah it surprised me as well that the code comparing to list didn't need to be updated after the numpy array PR..
Static array test case added in 712d4da
mikaelarguedas
commented
Apr 3, 2019
@dirk-thomas looking briefly at the impacted rqt packages: In multiple instances it looks like the code is meant to be interacting with the user friendly string representing a message and not a Python type per se. In some cases it's unclear if it is a design decision to rely on the Overall the amount of code + design in rqt to grasp and maybe rewrite will be significant, and I don't think I will have time to adapt it. Is there a path forward for this PR without these rqt changes? I can reopen a PR not using the abstract types but the msg ones if this allows a fix for ros2/ros2cli#59 to be merged |
dirk-thomas
commented
Apr 19, 2019
I don't think this ticket has to consider what might come out of that design ticket. Until that is actually merged this PR can focus on the current state of master.
I am not entirely sure what you mean but I would answer with: no.
As long as the patch removes currently available API which is used by rqt it can only land if it also updates the code using the API. That being said the alternatives are:
|
dirk-thomas
commented
May 1, 2019
@mikaelarguedas Friendly ping. |
So I looked at this again. as updating all the rqt packages is not something I will be able to do, I moved to a minimal patch not modifying message generation at all but just the runtime functions (a redo of https://github.com/ros2/ros2cli/pull/197/files). I submitted the patch at #52.
that was a valuable alternative, I considered this, the current blocker for such an approach is that the |
Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> update tests Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> simplify logic by printing member type directly Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> move dict construction to rosidl_runtime_py Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> add utility to import complex message and add support for nested array in set_message Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> update tests and remove coverage for dict to avoid circular dependency Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> more descriptive variable name Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> refactor import logic according to ros2#35 Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> move imports to top of file Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> string maximum size doesn't need quoting or str conversion Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> update docblock Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> slot_types_dict_from_message -> get_message_slot_types Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> check Abstrct type instead of 'list' Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> use NestedType Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> add conditional is namespaces is an empty list Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> one liner Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> extend test suite to cover NesteTypes of NamespacedTypes Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> single message fixture to use Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> use NestedType Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> add coverage for static array of nested messages Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> restore old API Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> SLOT_TYPES improvement from dirk-thomas Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> resolve conflicts Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
712d4da to
64003b6Comparemikaelarguedas
commented
May 3, 2019
As per discussion here and in #52. This PR now does the following:
|
dirk-thomas
commented
May 3, 2019
* store types as constant and return ordered dict Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> update tests Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> simplify logic by printing member type directly Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> move dict construction to rosidl_runtime_py Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> add utility to import complex message and add support for nested array in set_message Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> update tests and remove coverage for dict to avoid circular dependency Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> more descriptive variable name Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> refactor import logic according to ros2/rosidl_python#35 Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> move imports to top of file Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> string maximum size doesn't need quoting or str conversion Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> update docblock Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> slot_types_dict_from_message -> get_message_slot_types Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> check Abstrct type instead of 'list' Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> use NestedType Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> add conditional is namespaces is an empty list Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> one liner Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> extend test suite to cover NesteTypes of NamespacedTypes Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> single message fixture to use Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> use NestedType Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> add coverage for static array of nested messages Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> restore old API Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> SLOT_TYPES improvement from dirk-thomas Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> resolve conflicts Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> * add back I100 ignore Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> * use new rosidl_parser.definition types and new test interfaces Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com> * restore original test, add test for SLOT_TYPES Signed-off-by: Mikael Arguedas <mikael.arguedas@gmail.com>
Replaces #30 now that #24 has merged
Required by ros2/ros2cli#207
Blocked by #34