BerkeleyAutomation/perception

Python setup.py tests not succesfull

rickstaa opened this issue · 1 comments

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Ubuntu 16.04 singularity v3.2.1 container
  • Python version: 2.7.12 & 3.5.2
  • Installed using pip or ROS: ROS
  • Camera: Kinect v2 (Libfreenect2 library)
  • Gripper: Parallel jaw gripper
  • Robot: Emika Franka Panda robot
  • GPU model (if applicable): Nvidia M1000M GPU
  • ROS version: kinetic

Problem

I have some problems with successfully running the python setup.py test command both in a python2 ass well as a python3 environment.

Python 2.7 errors

After installing the requirements using pip install -e . and running the python setup.py test commands. I get the following error:

running test
running egg_info
writing requirements to autolab_perception.egg-info/requires.txt
writing autolab_perception.egg-info/PKG-INFO
writing top-level names to autolab_perception.egg-info/top_level.txt
writing dependency_links to autolab_perception.egg-info/dependency_links.txt
reading manifest file 'autolab_perception.egg-info/SOURCES.txt'
writing manifest file 'autolab_perception.egg-info/SOURCES.txt'
running build_ext
WARNING:root:Failed to import geometry msgs in rigid_transformations.py.
WARNING:root:Failed to import ros dependencies in rigid_transforms.py
WARNING:root:autolab_core not installed as catkin package, RigidTransform ros methods will be unavailable
WARNING:root:Unable to import CNN modules! Likely due to missing tensorflow.
WARNING:root:TensorFlow can be installed following the instructions in https://www.tensorflow.org/get_started/os_setup
WARNING:root:Unable to import pylibfreenect2. Python-only Kinect driver may not work properly.
WARNING:root:Failed to import ROS in Kinect2_sensor.py. Kinect will not be able to be used in bridged mode
WARNING:root:Unable to import openni2 driver. Python-only Primesense driver may not work properly
WARNING:root:Unable to import pyrealsense2.
WARNING:root:Failed to import ROS in ensenso_sensor.py. ROS functionality not available
WARNING:root:Failed to import ROS in phoxi_sensor.py. PhoXiSensor functionality unavailable.
WARNING:root:Unable to import weight sensor modules!
test_binary_init (tests.test_image.TestImage) ... ok
test_color_init (tests.test_image.TestImage) ... ok
test_depth_init (tests.test_image.TestImage) ... ok
test_grayscale_init (tests.test_image.TestImage) ... ok
test_indexing (tests.test_image.TestImage) ... ok
test_io (tests.test_image.TestImage) ... ok
test_mask_by_ind (tests.test_image.TestImage) ... ok
test_nc_init (tests.test_image.TestImage) ... ok
test_pc_init (tests.test_image.TestImage) ... ok
test_resize (tests.test_image.TestImage) ... ok
test_segment_init (tests.test_image.TestImage) ... ok
test_shape_comp (tests.test_image.TestImage) ... ok
test_transform (tests.test_image.TestImage) ... ok
test_registration (tests.test_registration.TestRegistration) ... ERROR

======================================================================
ERROR: test_registration (tests.test_registration.TestRegistration)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ricks/panda_autograsp/perception/tests/test_registration.py", line 41, in test_registration
    matcher, num_iterations=NUM_ITERS)
  File "/home/ricks/panda_autograsp/perception/perception/point_registration.py", line 207, in register
    U, S, V = np.linalg.svd(R)
  File "/home/ricks/panda_autograsp/perception/tests/test_perception2/local/lib/python2.7/site-packages/numpy/linalg/linalg.py", line 1612, in svd
    u, s, vh = gufunc(a, signature=signature, extobj=extobj)
TypeError: No loop matching the specified signature and casting
was found for ufunc svd_n_f

----------------------------------------------------------------------
Ran 14 tests in 0.042s

FAILED (errors=1)
Test failed: <unittest.runner.TextTestResult run=14 errors=1 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=14 errors=1 failures=0>

Python 3 errors

running test
running egg_info
writing dependency_links to autolab_perception.egg-info/dependency_links.txt
writing requirements to autolab_perception.egg-info/requires.txt
writing top-level names to autolab_perception.egg-info/top_level.txt
writing autolab_perception.egg-info/PKG-INFO
reading manifest file 'autolab_perception.egg-info/SOURCES.txt'
writing manifest file 'autolab_perception.egg-info/SOURCES.txt'
running build_ext
WARNING:root:Failed to import geometry msgs in rigid_transformations.py.
WARNING:root:Failed to import ros dependencies in rigid_transforms.py
WARNING:root:autolab_core not installed as catkin package, RigidTransform ros methods will be unavailable
WARNING:root:Unable to import CNN modules! Likely due to missing tensorflow.
WARNING:root:TensorFlow can be installed following the instructions in https://www.tensorflow.org/get_started/os_setup
WARNING:root:Unable to import pylibfreenect2. Python-only Kinect driver may not work properly.
WARNING:root:Failed to import ROS in Kinect2_sensor.py. Kinect will not be able to be used in bridged mode
WARNING:root:Unable to import Primsense sensor modules! Likely due to missing OpenNI2.
WARNING:root:Unable to import pyrealsense2.
WARNING:root:Failed to import ROS in ensenso_sensor.py. ROS functionality not available
WARNING:root:Failed to import ROS in phoxi_sensor.py. PhoXiSensor functionality unavailable.
WARNING:root:Unable to import generic sensor modules!.
WARNING:root:Unable to import weight sensor modules!
Traceback (most recent call last):
  File "setup.py", line 56, in <module>
    'empy'
  File "/home/ricks/panda_autograsp/perception/test_perception/lib/python3.5/site-packages/setuptools/__init__.py", line 145, in setup
    return distutils.core.setup(**attrs)
  File "/usr/lib/python3.5/distutils/core.py", line 148, in setup
    dist.run_commands()
  File "/usr/lib/python3.5/distutils/dist.py", line 955, in run_commands
    self.run_command(cmd)
  File "/usr/lib/python3.5/distutils/dist.py", line 974, in run_command
    cmd_obj.run()
  File "/home/ricks/panda_autograsp/perception/test_perception/lib/python3.5/site-packages/setuptools/command/test.py", line 229, in run
    self.run_tests()
  File "/home/ricks/panda_autograsp/perception/test_perception/lib/python3.5/site-packages/setuptools/command/test.py", line 251, in run_tests
    exit=False,
  File "/usr/lib/python3.5/unittest/main.py", line 93, in __init__
    self.parseArgs(argv)
  File "/usr/lib/python3.5/unittest/main.py", line 117, in parseArgs
    self._do_discovery(argv[2:])
  File "/usr/lib/python3.5/unittest/main.py", line 228, in _do_discovery
    self.test = loader.discover(self.start, self.pattern, self.top)
  File "/usr/lib/python3.5/unittest/loader.py", line 341, in discover
    tests = list(self._find_tests(start_dir, pattern))
  File "/usr/lib/python3.5/unittest/loader.py", line 398, in _find_tests
    full_path, pattern, namespace)
  File "/usr/lib/python3.5/unittest/loader.py", line 475, in _find_test_path
    tests = self.loadTestsFromModule(package, pattern=pattern)
  File "/home/ricks/panda_autograsp/perception/test_perception/lib/python3.5/site-packages/setuptools/command/test.py", line 55, in loadTestsFromModule
    tests.append(self.loadTestsFromName(submodule))
  File "/usr/lib/python3.5/unittest/loader.py", line 153, in loadTestsFromName
    module = __import__(module_name)
  File "/home/ricks/panda_autograsp/perception/perception/primesense_sensor.py", line 274
    def __init__(self, depth_image_buffer= None, depth_absolute=False, color_image_buffer=None, color_absolute=False,
SyntaxError: import * only allowed at module level

Fix

As explained in this StackOverflow post wildcard imports at function level are no longer allowed in py>2.6. As a result, the line 278 of primesense_sensor.py needs to be changed from:

from perception.srv import *

into:

from perception.srv import ImageBufferResponse

I verified that the fix is back compatible with python 2 versions however I did not test the real sense implementation as I do not have a real sense camera. After I fixed the issue above I get the following errors:

======================================================================
ERROR: weight_sensor (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: weight_sensor
Traceback (most recent call last):
  File "/opt/conda/envs/autograsp/lib/python3.7/unittest/loader.py", line 154, in loadTestsFromName
    module = __import__(module_name)
  File "/home/ricks/catkin_ws/src/perception/perception/weight_sensor.py", line 4, in <module>
    import rospy
ModuleNotFoundError: No module named 'rospy'


======================================================================
ERROR: test_registration (tests.test_registration.TestRegistration)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/ricks/catkin_ws/src/perception/tests/test_registration.py", line 41, in test_registration
    matcher, num_iterations=NUM_ITERS)
  File "/home/ricks/catkin_ws/src/perception/perception/point_registration.py", line 207, in register
    U, S, V = np.linalg.svd(R)
  File "/opt/conda/envs/tf-gpu/lib/python3.7/site-packages/numpy/linalg/linalg.py", line 1612, in svd
    u, s, vh = gufunc(a, signature=signature, extobj=extobj)
TypeError: No loop matching the specified signature and casting
was found for ufunc svd_n_f

----------------------------------------------------------------------
Ran 15 tests in 0.036s

Of these errors the rospy error is understandable since I'm in a conda python3 enviroment.