Skip to content

Make CLI more robust to discovery latency.#421

Closed
hidmic wants to merge 10 commits intomasterfrom
hidmic/more-robust-cli
Closed

Make CLI more robust to discovery latency.#421
hidmic wants to merge 10 commits intomasterfrom
hidmic/more-robust-cli

Conversation

@hidmic
Copy link
Copy Markdown

@hidmic hidmic commented Dec 9, 2019

Closes #419. Follow up after #420. This pull request extends daemon API support a bit more and adapts all CLI verbs to make use of it.

if inspect.isfunction(function):
function_signature = inspect.signature(function)
if 'node' == tuple(function_signature.parameters)[0]:
return functools.partial(function, self)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This is not really nice.
It would be better if DaemonNode could be used as a "normal node", instead of patching the DaemonNode and modifying the DirectNode to work in the same way.
Probably, this is not possible using XML-RPC. Maybe we could use a different IPC mechanism?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Yeap, I agree. But the problem isn't the IPC mechanism, really. Graph API for actions in rclpy departs from the pattern that the rest follow and on which NodeStrategy implementation rests upon. On a regular node, you'd simply call rclpy.action.get_action_*(node, *args), but those simply forward down to the C layer (see here). The pattern doesn't lend itself well to polymorphism. That's why I made DirectNode look like NodeStrategy, and not the other way around.

I have yet to come up with a way to do this nicely and transparent for those who write API like that of rclpy.action. We could make our C calls through the handle, like:

def get_action_client_names_and_types_by_node(
    node: Node,
    remote_node_name: str,
    remote_node_namespace: str
) -> List[Tuple[str, List[str]]]:
    get_action_client_names_and_types_by_node = node.handle.bind(
        _rclpy_action.rclpy_action_get_client_names_and_types_by_node)
    return get_action_client_names_and_types_by_node(
        remote_node_name, remote_node_namespace)

It isn't pretty, but it gives us a chance to proxy calls.

Tagging @jacobperron @wjwwood, both probably have thoughts on this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I like that proposal.
It's much more work though, but the result is cleaner.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I agree that we could be more consistent with the API in rclpy. I think any refactoring in rclpy can be left as part of a more thorough design review. For now, what if we just add a couple action specific functions to the DirectNode API?
I think it's easier to understand than inspecting function signatures, e.g.

class DirectNode:

    # ...

    def get_action_names_and_types():
        return rclpy.action.get_action_names_and_types(self.node)

    def get_action_client_names_and_types_by_node(node_name, node_ns):
        return rclpy.action.get_action_client_names_and_types_by_node(self.node, node_name, node_ns)

     # ... etc

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

I was trying to not do that :). But I'm fine with being explicit. See c0a78fe.

Copy link
Copy Markdown
Member

@jacobperron jacobperron Dec 10, 2019

Choose a reason for hiding this comment

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

I understand, but I think the diff is easier to parse with override functions (obviously just an opinion). The TODO still holds in any case.

@ivanpauno ivanpauno added the in review Waiting for review (Kanban column) label Dec 10, 2019
@hidmic
Copy link
Copy Markdown
Author

hidmic commented Dec 10, 2019

@jacobperron @ivanpauno once you are both OK with this patch, I'll rebase and run CI.

ivanpauno
ivanpauno previously approved these changes Dec 10, 2019
), timeout=10)
assert topic_command.wait_for_shutdown(timeout=10)

@launch_testing.markers.retry_on_failure(times=5)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why are these changes needed and how are they related to this PR?

Copy link
Copy Markdown
Author

@hidmic hidmic Dec 10, 2019

Choose a reason for hiding this comment

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

Those changes slipped in, my bad. These tests flaked me once locally, and later I forgot to take decorators out. We can split into their own PR if you'd like. Or drop them, truth is I cannot consistently reproduce the flake -- and I highly doubt it had anything to do with this patch.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah, splitting sounds reasonable since nobody will expect this change in the squashed commit after the fact.

jacobperron
jacobperron previously approved these changes Dec 10, 2019
Copy link
Copy Markdown
Member

@jacobperron jacobperron left a comment

Choose a reason for hiding this comment

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

LGTM with Dirks question answered and green CI.

@hidmic hidmic force-pushed the hidmic/more-robust-cli branch from c0a78fe to d6e475e Compare December 11, 2019 18:49
@hidmic
Copy link
Copy Markdown
Author

hidmic commented Dec 11, 2019

Running CI up to ros2cli, ros2topic, ros2action, ros2component, ros2service, ros2node:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • OSX Build Status
  • Windows Build Status

@hidmic
Copy link
Copy Markdown
Author

hidmic commented Dec 11, 2019

@jacobperron @dirk-thomas @ivanpauno I've rebased to leave a clean history. I plan to keep each commit. PTAL while CI runs.

@hidmic hidmic force-pushed the hidmic/more-robust-cli branch from d6e475e to 981a4db Compare December 11, 2019 19:52
dirk-thomas
dirk-thomas previously approved these changes Dec 11, 2019
@hidmic
Copy link
Copy Markdown
Author

hidmic commented Dec 12, 2019

Checking CI failures I came across a small pre-existing bug (645b3ee). Of course I cannot locally reproduce any of these failures. Let's see what comes out of a Windows CI now.

hidmic added 7 commits April 1, 2020 16:52
Support ROS graph API for actions plus basic node queries.

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic hidmic force-pushed the hidmic/more-robust-cli branch from b7b2eb6 to 4decccf Compare April 1, 2020 19:55
hidmic added 2 commits April 6, 2020 13:24
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic
Copy link
Copy Markdown
Author

hidmic commented Apr 6, 2020

Running CI again up to ros2cli, ros2topic, ros2action, ros2component, ros2service, ros2node:

  • Linux Build Status
  • Linux-aarch64 Build Status
  • OSX Build Status
  • Windows Build Status

Signed-off-by: Michel Hidalgo <michel@ekumenlabs.com>
@hidmic
Copy link
Copy Markdown
Author

hidmic commented Apr 21, 2020

Ok, CI's green, which I attribute to many ros2cli tests being disabled under Windows. @jacobperron @dirk-thomas what would you like to do with this patch? Do we merge it now or do we defer?

@dirk-thomas dirk-thomas dismissed stale reviews from jacobperron, ivanpauno, and themself April 21, 2020 17:56

Significant changes

@dirk-thomas
Copy link
Copy Markdown
Member

(I invalidated all previous reviews since there have been significant changes to the PR since then.)

Imo the current patch contains too many unrelated changes to land in a single PR. It should be split up into individually reviewed changes.

@hidmic
Copy link
Copy Markdown
Author

hidmic commented Apr 21, 2020

Imo the current patch contains too many unrelated changes to land in a single PR. It should be split up into individually reviewed changes.

Fair enough, I can split it.

@hidmic
Copy link
Copy Markdown
Author

hidmic commented Apr 22, 2020

Alright, now that #493 and #494 are up we can close this one.

@hidmic hidmic closed this Apr 22, 2020
@hidmic hidmic deleted the hidmic/more-robust-cli branch April 22, 2020 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in review Waiting for review (Kanban column)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Deal with discovery latency consistently

4 participants