Skip to content

Check/Report package versions #356

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

Closed
wants to merge 32 commits into from

Conversation

claireyywang
Copy link
Contributor

@claireyywang claireyywang commented Oct 10, 2019

close #343
Check locally installed package versions against ones on rosdistro. Local versions are obtained by parsing package.xml found in install space.

claireyywang added 8 commits October 7, 2019 16:33
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
@claireyywang claireyywang added the in progress Actively being worked on (Kanban column) label Oct 10, 2019
@claireyywang claireyywang self-assigned this Oct 10, 2019
@claireyywang claireyywang changed the title #343: Check/Report package versions close #343: Check/Report package versions Oct 10, 2019
@claireyywang claireyywang changed the title close #343: Check/Report package versions Check/Report package versions Oct 10, 2019
@@ -9,6 +9,7 @@

<depend>ros2cli</depend>

<exec_depend>ament_index</exec_depend>
Copy link
Member

Choose a reason for hiding this comment

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

There is no package with that name. I guess you need ament_index_python.

return
xml_file = os.path.join(prefix, 'share', package_name, 'package.xml')
try:
root = ET.parse(xml_file).getroot()
Copy link
Member

Choose a reason for hiding this comment

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

Instead of parsing the manifest file yourself please use the API provided by the Python package catkin_pkg (rosdep key python3-catkin-pkg-modules) instead.

if distro_ver[:3] != local_ver[:3]: # 0.8.0 vs. 0.8.0-1
result.add_warning('`%s` has different local version %s from \
required version %s' % (package_name, distro_ver, local_ver))
return result
Copy link
Member

Choose a reason for hiding this comment

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

Instead of getting all packages and versions from rosdistro and then checking if they exist on the system I would suggest the opposite: collect all packages found and their versions and then compare them to the information from rosdistro.

claireyywang added 2 commits October 10, 2019 10:53
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
@claireyywang claireyywang added the in review Waiting for review (Kanban column) label Oct 10, 2019

:return: a dictionary contains package name, release, source and status
"""
distro_name = os.environ.get('ROS_DISTRO')
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this will raise RuntimeError if ROS_DISTRO is unset. What should PackageCheck and PackageReport do in that case?

>>> import rosdistro
>>> url = rosdistro.get_index_url()
>>> i = rosdistro.get_index(url)
>>> data = rosdistro.get_distribution(i, None).get_data()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3/dist-packages/rosdistro/__init__.py", line 114, in get_distribution
    dist_file = get_distribution_file(index, dist_name)
  File "/usr/lib/python3/dist-packages/rosdistro/__init__.py", line 119, in get_distribution_file
    data = _get_dist_file_data(index, dist_name, 'distribution')
  File "/usr/lib/python3/dist-packages/rosdistro/__init__.py", line 186, in _get_dist_file_data
    raise RuntimeError("Unknown release: '{0}'. Valid release names are: {1}".format(dist_name, ', '.join(sorted(index.distributions.keys()))))
RuntimeError: Unknown release: 'None'. Valid release names are: ardent, bouncy, crystal, dashing, eloquent, groovy, hydro, indigo, jade, kinetic, lunar, melodic, noetic

Copy link
Contributor Author

@claireyywang claireyywang Oct 14, 2019

Choose a reason for hiding this comment

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

I'll add RuntimeError to the except block in PackageCheck and PackageReport. In check, it will pass error message to result; in report, it will output an empty report with report name only.

"""Check packages within the directory where command is called."""
result = Result()
try:
distro_packages_info = get_ros_packages_info()
Copy link
Contributor

Choose a reason for hiding this comment

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

Recommend distro_packages_info -> distro_repositories_info and get_ros_packages_info -> get_ros_repositories_info since it's a dictionary of repositories, which may have 1 or more packages in them.

return result
for package_name, package_prefix in local_packages_prefixes.items():
file_path = os.path.join(package_prefix, 'share', package_name)
if package_name in distro_packages_info:
Copy link
Contributor

Choose a reason for hiding this comment

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

It looks like this won't work for repositories that have more than one package. For example, rcl_action is in the repository rcl.

>>> distro_packages_info['rcl']
{'doc': {'type': 'git', 'url': 'https://github.com/ros2/rcl.git', 'version': 'dashing'}, 'release': {'url': 'https://github.com/ros2-gbp/rcl-release.git', 'version': '0.7.7-1', 'tags': {'release': 'release/dashing/{package}/{version}'}, 'packages': ['rcl', 'rcl_action', 'rcl_lifecycle', 'rcl_yaml_param_parser']}, 'source': {'type': 'git', 'url': 'https://github.com/ros2/rcl.git', 'version': 'dashing', 'test_pull_requests': True}, 'status': 'developed'}

Note the rcl repo has a key packages which is a list of packages in the repo, which includes rcl_action.

There is no repo rcl_action.

>>> distro_packages_info['rcl_action']
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
KeyError: 'rcl_action'

result.add_warning('Unable to parse `%s` package.xml file.' % package_name)
local_ver = ''
if required_ver and local_ver:
if required_ver[:3] != package_obj.version[:3]:
Copy link
Contributor

Choose a reason for hiding this comment

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

Recommend warning only if the released version is greater than the installed version, meaning the user needs to upgrade their packages. If the installed version is greater, the person calling ros2 doctor may be intentionally building a newer version from source.

if distro_packages_info and local_package_prefixes:
for package_name, package_prefix in local_package_prefixes.items():
try:
package_info = distro_packages_info.get(package_name)
Copy link
Contributor

Choose a reason for hiding this comment

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

Same comment about distro_packages_info being repository info, and this not working for repos with multiple packages.

claireyywang added 13 commits October 15, 2019 11:43
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
claireyywang added 2 commits October 15, 2019 16:21
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
@claireyywang claireyywang force-pushed the claire/check-package-version branch from 5ae1456 to e20baaf Compare October 15, 2019 23:29
claireyywang added 7 commits October 16, 2019 10:11
Signed-off-by: claireyywang <[email protected]>
This reverts commit 28f284c.
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
Signed-off-by: claireyywang <[email protected]>
@claireyywang claireyywang removed the in progress Actively being worked on (Kanban column) label Oct 16, 2019
@claireyywang claireyywang requested a review from tfoote October 24, 2019 17:34
@claireyywang
Copy link
Contributor Author

messed up local, gonna make a new branch and PR

@claireyywang claireyywang deleted the claire/check-package-version branch October 25, 2019 22:42
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.

ros2doctor: add support for warning on out of date packages
3 participants