Skip to content

[IMP] label_modified_addons: improve performance.#6

Open
legalsylvain wants to merge 2 commits intoacsone:label-pr-modified-addonsfrom
grap:label-pr-modified-addons-imp-performance
Open

[IMP] label_modified_addons: improve performance.#6
legalsylvain wants to merge 2 commits intoacsone:label-pr-modified-addonsfrom
grap:label-pr-modified-addons-imp-performance

Conversation

@legalsylvain
Copy link
Copy Markdown

@legalsylvain legalsylvain commented Apr 7, 2026

Avoid to call github API in a loop
…ny labels, saving API calls and time,

[FIX] remove obsolete labels
@legalsylvain legalsylvain force-pushed the label-pr-modified-addons-imp-performance branch from 876aa48 to cbac322 Compare April 7, 2026 20:07
@legalsylvain legalsylvain marked this pull request as ready for review April 7, 2026 20:46
@manuel-florido
Copy link
Copy Markdown

LGTM

Copy link
Copy Markdown
Member

@sbidoul sbidoul left a comment

Choose a reason for hiding this comment

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

A little suggestion to make it more efficient and simpler?

Otherwise LGTM.

Comment on lines +28 to 31
repo_label_names = [label.name for label in gh_repo.labels()]
issue_label_names = [label.name for label in gh_issue.labels()]

new_labels = set()
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
repo_label_names = [label.name for label in gh_repo.labels()]
issue_label_names = [label.name for label in gh_issue.labels()]
new_labels = set()
repo_label_names = [label.name for label in gh_repo.labels()]
issue_label_names = [label.name for label in gh_issue.labels()]
new_labels = issue_label_names.copy()

Comment on lines +48 to +55
new_labels |= {
x
for x in issue_label_names
if not (x.startswith("mod:") or x.startswith("series:"))
}

if not dry_run and new_labels != set(issue_label_names):
github.gh_call(gh_issue.replace_labels, list(new_labels))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
new_labels |= {
x
for x in issue_label_names
if not (x.startswith("mod:") or x.startswith("series:"))
}
if not dry_run and new_labels != set(issue_label_names):
github.gh_call(gh_issue.replace_labels, list(new_labels))
if not dry_run and new_labels != issue_label_names:
github.gh_call(gh_issue.replace_labels, list(new_labels))

@legalsylvain
Copy link
Copy Markdown
Author

legalsylvain commented Apr 8, 2026

A little suggestion to make it more efficient and simpler?

Hi. I read the code, and I don't think that the algorithm you propose has the same result. new_labels are the list of the labels that should be put. if you copy from the existing list, you'll not fix the @manuel-florido remarks, regarding obsolete labels IMO.

If you think the alogorithm is OK, could you merge my PR, and then make a PR agains acsone:label-pr-modified-addons. So, it will be more easy to read the final code you propose.

I have some difficulties to understand the changes you propose over my changes (#6) that are on top of your changes (OCA#300), in the github review interface.

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.

3 participants