-
-
Notifications
You must be signed in to change notification settings - Fork 6
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
feat: Add information knowledge panel #124
base: main
Are you sure you want to change the base?
Conversation
5b90d47
to
9003c6a
Compare
9003c6a
to
510dd82
Compare
package upgrade broke previous method of exposing prometheus metrics
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems we are going to implement it in product opener instead… so I didn't finish the review.
def unique_items(cls, v): | ||
count = Counter( | ||
(item.lang, item.tag_type, item.value_tag, item.country, item.category_tag) | ||
for item in v | ||
) | ||
most_common = count.most_common(1) | ||
if most_common and most_common[0][1] > 1: | ||
raise ValueError(f"more than 1 item with fields={most_common[0][0]}") | ||
return v |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a doc string to explain a bit more what you are doing here (what and why ?)
add_contribution_panels: bool = True, | ||
add_information_panels: bool = True, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I proposed to instead use an include/exclude list, as it may be more flexible in the future. see #38
If we start to use this API instead, we will lack this flexibility.
if soon_value.value: | ||
panels.update(soon_value.value) | ||
|
||
if add_information_panels and value_tag is not None: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why don't you use active_translation here ? If it's legit, add a comment to explain why.
facet_tag_safe = secure_filename(facet_tag) | ||
value_tag_safe = secure_filename(value_tag) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
if facet_tag_safe and value_tag_safe: | ||
file_path = find_kp_html_path( | ||
HTML_DIR, facet_tag_safe, value_tag_safe, country, lang_code | ||
) | ||
panel = None | ||
if file_path is not None: | ||
async with async_open(file_path, "r") as f: | ||
html_content = await f.read() | ||
panel = { | ||
"elements": [{"element_type": "text", "text_element": {"html": html_content}}], | ||
"title_element": {"title": "Description"}, | ||
} | ||
panels["Description"] = panel |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why didn't you follow the pattern above and just add a function to do things asynchronously ? It seem to me it hinders readability to break the pattern.
Normally the add_information_panels can be check to decide to add or not the task to soon_panels.
And all the rest should be done inside the method (you can return None to have no panel added).
Add a first implementation of information knowledge panel for facets.
Example of input YAML file: