Skip to content
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

Remove agnostic lib #82

Merged
merged 3 commits into from
May 10, 2017
Merged

Remove agnostic lib #82

merged 3 commits into from
May 10, 2017

Conversation

dirk-thomas
Copy link
Member

@dirk-thomas dirk-thomas commented May 10, 2017

Since the rclpy lib is now agnostic to the RMW impl. there is no need to keep some functions in a separate library. And since the loaded Python extension is always the same I removed all the fancy loading logic around it.

The second commit addresses a test failure. Instead of passing a known invalid parameter to the C function raise a ValueError instead.

Build Status fixes the failing rclpytestst (http://ci.ros2.org/view/nightly/job/nightly_win_deb/lastCompletedBuild/testReport/(root)/projectroot/rclpytests/).

@dirk-thomas dirk-thomas added in progress Actively being worked on (Kanban column) in review Waiting for review (Kanban column) and removed in progress Actively being worked on (Kanban column) labels May 10, 2017
@@ -57,6 +57,7 @@ if(WIN32)
endif()

target_link_libraries(${PROJECT_NAME}
${rcl_LIBRARIES}
Copy link
Member

Choose a reason for hiding this comment

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

Isn't this redundant with the ament_target_dependencies call below?

Copy link
Member Author

@dirk-thomas dirk-thomas May 10, 2017

Choose a reason for hiding this comment

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

Absolutely, I moved it from the other library target and noticed the duplicate. Removed in a699313.

# ensure that the passed node contains a valid capsule
class_ = self.handle.__class__
if not class_ or class_.__name__ != 'PyCapsule':
raise ValueError()
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this have a message?

Copy link
Member Author

@dirk-thomas dirk-thomas May 10, 2017

Choose a reason for hiding this comment

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

It was only used in one bizarre test (which modified the internal handle of a node instance) so I thought it isn't a real world case. Added a message in 117eac9.

@@ -20,7 +20,7 @@
def run_catch_report_raise(func, *args, **kwargs):
try:
return func(*args, **kwargs)
except:
except Exception:
Copy link
Member

Choose a reason for hiding this comment

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

Is this necessary?

Copy link
Member Author

Choose a reason for hiding this comment

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

Not necessary but recommended in PEP 8 and some linters will warn about it:

When catching exceptions, mention specific exceptions whenever possible instead of using a bare except:

@dirk-thomas dirk-thomas merged commit 38c4c91 into master May 10, 2017
@dirk-thomas dirk-thomas deleted the remove_agnostic_lib branch May 10, 2017 18:56
@dirk-thomas dirk-thomas removed the in review Waiting for review (Kanban column) label May 10, 2017
@wjwwood
Copy link
Member

wjwwood commented May 19, 2017

Unfortunately I didn't catch this before, but the removal of the proxy object machinery has caused a regression in the check that rclpy.init() has been called before using other functions. Now you get a general RuntimeError rather than the more specific rclpy.exceptions.NotInitializedException when doing something like this:

In [1]: import rclpy

In [2]: node = rclpy.create_node('foo')
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-25-e3302d2d805e> in <module>()
----> 1 node = rclpy.create_node('foo')

/Users/william/ros2_ws/install/lib/python3.6/site-packages/rclpy/__init__.py in create_node(node_name, namespace)
     26
     27 def create_node(node_name, *, namespace=None):
---> 28     node_handle = _rclpy.rclpy_create_node(node_name, namespace or '')
     29     return Node(node_handle)
     30

RuntimeError: Failed to create node: rcl_init() has not been called, at /Users/william/ros2_ws/src/ros2/rcl/rcl/src/rcl/node.c:92

Please restore the proxy object stuff or check that rclpy.init() has been called in each of the cases and raise the right exception.

This is the code that checked on each access of _rclpy and raise if init() had not been called:

https://github.com/ros2/rclpy/pull/82/files#diff-7486716035fb1f918746b7f5b1b31b35L49

@wjwwood
Copy link
Member

wjwwood commented May 19, 2017

I created #84 to track the issue since this cannot be reopened.

@wjwwood
Copy link
Member

wjwwood commented May 19, 2017

Also, after this pr, NoImplementationAvailableException is no longer used anywhere. I'll remove it in my upcoming pr.

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.

None yet

2 participants