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

Ros2cli diagnostics #301

Draft
wants to merge 25 commits into
base: ros2
Choose a base branch
from
Draft

Ros2cli diagnostics #301

wants to merge 25 commits into from

Conversation

robobe
Copy link

@robobe robobe commented Apr 26, 2023

Add ros2cli for diagnostics as alternative for diagnostics_analysis
The project add diagnostics command to ROS2 cli with there verbs.

  • list
  • show
  • csv

check README.md for more

Copy link
Collaborator

@ct2034 ct2034 left a comment

Choose a reason for hiding this comment

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

Hi @robobe. Thanks for your PR. This looks amazing. 😁
I hope I will find the time for a proper review soon. Just something I noticed:

  • All source files are missing copyright headers
  • Please update the package.xml and do what else is required for the buildfarm to run.

@ct2034 ct2034 self-assigned this Apr 26, 2023
Copy link
Collaborator

@ct2034 ct2034 left a comment

Choose a reason for hiding this comment

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

Please move the work on diagnostics_tutorial to a separate PR, such that I can review the ros2diagnostics_cli separately. And if you are still working on this, please use the draft PR feature. Otherwise, this creates a lot of overhead. Some points:

In general this seems very work in progress. Please make this a draft PR, then.

@ct2034 ct2034 marked this pull request as draft May 4, 2023 09:40
@ct2034
Copy link
Collaborator

ct2034 commented May 4, 2023

I was able to make it into a draft myself, nvm. Just click Ready for review when you are. Or let me know when you need help. I generally suggest to focus on one or two well-implemented verbs and extend on it later.

Signed-off-by: Christian Henkel <[email protected]>
Copy link
Collaborator

@ct2034 ct2034 left a comment

Choose a reason for hiding this comment

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

Can you please describe the intended use case for the list and show verb? I feel like there is an overlap. In my opinion, two verbs are required:
list - it lists all available diagnostics sources and the exits
echo - it will run forever and echo all the diagnostics info on a specific source.
Basically similar to how theses two verbs work for the topic command right now

base_dir = pathlib.Path(csv_file).parents[0]
folder_exists = pathlib.Path(base_dir).is_dir()
if not folder_exists:
raise Exception(
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use a more specific exception type

Comment on lines +50 to +53
b'\x00': ('OK', GREEN + 'OK' + COLOR_DEFAULT),
b'\x01': ('WARN', YELLOW + 'WARN' + COLOR_DEFAULT),
b'\x02': ('ERROR', RED + 'ERROR' + COLOR_DEFAULT),
b'\x03': ('STALE', RED + 'STALE' + COLOR_DEFAULT),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Please use the constants declared in dagnostic_msgs.msg.DiagnosticStatus

Copy link
Collaborator

Choose a reason for hiding this comment

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

And you can also use f-strings here

<test_depend>ament_flake8</test_depend>
<!-- <test_depend>ament_pep257</test_depend> -->
<test_depend>python3-pytest</test_depend>
<depend>ros2cli</depend>
Copy link
Collaborator

Choose a reason for hiding this comment

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

All required packages from this repo must be declared here

try:
self.csv = open_file_for_output(args.output)
except Exception as error:
print(str(error))
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
print(str(error))
print(error)

]
if verbose:
kv: KeyValue
for kv in status.values:
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
for kv in status.values:
line.extend(kv.value for kv in status.values)

)

def render(self, status: DiagnosticStatus, time_sec, verbose=False):
level_name, _ = convert_level_to_str(status.level)
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't see how this is imported

Comment on lines +101 to +102
if not self.__levels:
return False
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if not self.__levels:
return False
return False if not self.__levels else level not in self.__levels


def add_common_arguments(parser: ArgumentParser):
"""Add common arguments for csv and show verbs."""
parser.add_argument('-1', '--once', action='store_true', help='run only once')
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
parser.add_argument('-1', '--once', action='store_true', help='run only once')
parser.add_argument(
'-1',
'--once',
action='store_true',
help='run only once')

"""Add common arguments for csv and show verbs."""
parser.add_argument('-1', '--once', action='store_true', help='run only once')
parser.add_argument(
'-f', '--filter', type=str, help='filter diagnostic status name'
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
'-f', '--filter', type=str, help='filter diagnostic status name'
'-f',
'--filter',
type=str,
help='filter diagnostic status name'

@russkel
Copy link

russkel commented Jul 31, 2023

This looks useful - has there been movement on this?

@russkel
Copy link

russkel commented Sep 19, 2023

@robobe do you mind if I take over this PR if you're not interested/don't have the time?

@ct2034 ct2034 added enhancement This tackles a new feature of the code (and not a bug) ros2 PR tackling a ROS2 branch needs more work Someone has worked on this but more work is needed labels Sep 26, 2023
@ct2034
Copy link
Collaborator

ct2034 commented Sep 26, 2023

Hi @russkel, thanks for your interest. Since @robobe is fairly unresponsive for quite some time, please feel free to take this over.

@russkel
Copy link

russkel commented Sep 27, 2023

Hi @ct2034 will do when I get some time.

@russkel
Copy link

russkel commented Oct 7, 2023

Hi @ct2034

I have begun the work: https://github.com/russkel/diagnostics/tree/ros2cli_diagnostics

I have addressed your suggestions and am going to do the following:

  • rename to ros2diagnostics to follow convention
  • as per your suggestion change verbs to list/echo.
  • convert csv to an output format option on echo: ros2 diagnostics echo -f csv > my-csv.csv (unix philosophy)
  • refactor DiagnosticsParser into a generator with a WaitSet and remove mode
  • add self test verb
  • add tests

Are you able to change the repo of this PR or should I create a new one?

@ct2034
Copy link
Collaborator

ct2034 commented Dec 12, 2023

Thanks for your work @russkel. I can not edit the branch this PR is from. Please create a new one. Than I can close this one

@russkel russkel mentioned this pull request Jan 21, 2024
7 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement This tackles a new feature of the code (and not a bug) needs more work Someone has worked on this but more work is needed ros2 PR tackling a ROS2 branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants