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

Car docs bot: diff on generated readme file #33273

Closed
wants to merge 17 commits into from

Conversation

marcellofuschi
Copy link

@marcellofuschi marcellofuschi commented Aug 12, 2024

Closes #32690

  • Doesn't use pickle, it just compares the markdown files (the one in master and the one in a PR).
  • Only the car docs table is compared. The rest of the file is ignored.
  • It relies on the (Make, Model) pair from the table to identify a row. If a column value was changed but the pair remained the same, that's shown as a column change in the PR comment (as opposed to an addition+removal).
  • Adds the Detail sentence as an expandable button in the docs (like "Hardware Needed").

Here's an example result: marcellofuschi#2 (comment)
Detail sentence isn't visible in the example because that column is not in master yet.

Copy link
Contributor

github-actions bot commented Aug 12, 2024

Thanks for contributing to openpilot! In order for us to review your PR as quickly as possible, check the following:

  • Convert your PR to a draft unless it's ready to review
  • Read the contributing docs
  • Before marking as "ready for review", ensure:
    • the goal is clearly stated in the description
    • all the tests are passing
    • the change is something we merge
    • include a route or your device' dongle ID if relevant

@marcellofuschi
Copy link
Author

marcellofuschi commented Aug 12, 2024

Need to fix: the code for parsing the markdown table is too naive and doesn't handle potential escaped pipes. Will do it in a bit.

@sshane
Copy link
Contributor

sshane commented Aug 12, 2024

The sentence is not very easy to read, is there something we can do about that? Tooltip, comment? We don't currently show it, so it's not a requirement to show it now.

image

And does this satisfy this point in the issue?

Changes to column values should be picked up as a column change, not addition and removal. GitHub already does that for us!

@marcellofuschi
Copy link
Author

marcellofuschi commented Aug 12, 2024

The sentence is not very easy to read, is there something we can do about that?

Pushed a change that should improve that. I automatically add some   to the column value so that once rendered the table prefers overflowing with scroll (up to a certain point). Here is the result.

And does this satisfy this point in the issue?
"Changes to column values should be picked up as a column change, not addition and removal. [...]"

I think so, as long as the changes aren't made to the columns I use for identifying a row (i.e., Make and Model). See here for an example.


I also added a length limit to the generated comment, so that it won't show more than 10 rows per category, with an indication of the number of hidden rows (e.g., + 31 other rows). I believe the comment would get truncated anyway if too long so it's better to handle it more gracefully.


Need to fix: the code for parsing the markdown table is too naive and doesn't handle potential escaped pipes.

Still gotta fix this.

@sshane
Copy link
Contributor

sshane commented Aug 12, 2024

Getting this, why doesn't CI catch it?:

batman@workstation-shane:~/openpilot/selfdrive/debug$ python3 print_docs_diff.py 
  File "/home/batman/openpilot/selfdrive/debug/print_docs_diff.py", line 22
    results = {f'{r['Make']} {r['Model']}': r for r in results}
                     ^^^^
SyntaxError: f-string: unmatched '['

I would say it's okay to hide the sentence for now, it changes the style of the table too much and pushes the other columns near the end off the screen. Another user put it in the markdown file as comments, with some small special handling.

The current differ makes use of the platform name to detect model year/name changes, which while would be nice to keep, are a bit more difficult if we just have the column values, so I'm fine with losing that ability for now.

I see some re.subs, it's important to do the simplest thing first. I would use a str.replace if it's a drop-in replacement for example.

selfdrive/debug/print_docs_diff.py Outdated Show resolved Hide resolved
Comment on lines +62 to +66
base_headers, base_cars = get_cars_docs_in_markdown(base_docs_content)
new_headers, new_cars = get_cars_docs_in_markdown(new_docs_content)
Copy link
Contributor

Choose a reason for hiding this comment

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

It makes more sense if new_docs_content is hardcoded using BASEDIR + CARS.md file locally, and base_docs_content should be passed in as a path, using the base commit on the PR (downloaded in the Action)

Copy link
Author

@marcellofuschi marcellofuschi Aug 13, 2024

Choose a reason for hiding this comment

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

I made the change (ce8c77c) and tested it in my fork

selfdrive/debug/print_docs_diff.py Outdated Show resolved Hide resolved
@marcellofuschi
Copy link
Author

marcellofuschi commented Aug 12, 2024

I would say it's okay to hide the sentence for now, it changes the style of the table too much and pushes the other columns near the end off the screen. Another user put it in the markdown file as comments, with some small special handling.

This was partly because I had also enlarged the Supported Package column. I reverted it now, so the table should look a bit more familiar. Let me know if this could work.

Regarding re.subs, the first one would be the easiest to remove. However, I believe it's more robust to check for a word boundary before the appearance of assets/ when performing the replacement. Let me know if you agree; otherwise, I'll change it to .replace('assets/', 'https://media.githubusercontent.com/media/commaai/openpilot/master/docs/assets/')

I'll look into the other points you raised. Thanks for the feedback.

@marcellofuschi
Copy link
Author

marcellofuschi commented Aug 13, 2024

Getting this, why doesn't CI catch it?:

I reproduced the error, I think it has to do with wrong quotes. Demo example:

Screenshot 2024-08-13 at 4 04 30 PM

I've fixed it in the code, so it should be fine now. I'm not sure why CI didn't catch it.

@@ -289,9 +289,9 @@ jobs:
ref: ${{ github.event.pull_request.base.ref }}
Copy link
Contributor

Choose a reason for hiding this comment

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

We want to get rid of the two checkouts in this PR and just use curl/wget

Copy link
Author

@marcellofuschi marcellofuschi Aug 14, 2024

Choose a reason for hiding this comment

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

Done (ddbe964)

@marcellofuschi
Copy link
Author

marcellofuschi commented Aug 21, 2024

Rebased after the recent changes, and tested again here

The Detail sentence is missing from the docs because docs_definitions.py was moved to opendbc, so the generated diff doesn't currently include Detail sentence.

I think it looked fine when we added it to the table as a new column (with formatting done through   usage). In case you agree, I opened a PR to opendbc to re-add it: commaai/opendbc#1182

This way, Detail will also be involved in the diff.

Copy link
Contributor

This PR has had no activity for 9 days. It will be automatically closed in 2 days if there is no activity.

@github-actions github-actions bot added the stale label Aug 31, 2024
Copy link
Contributor

github-actions bot commented Sep 2, 2024

This PR has been automatically closed due to inactivity. Feel free to re-open once activity resumes.

@github-actions github-actions bot closed this Sep 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Car docs bot: diff on generated readme file
2 participants