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

global: add support for index templates #148

Merged
merged 3 commits into from
Aug 14, 2024

Conversation

zzacharo
Copy link
Member

❤️ Thank you for your contribution!

Description

Please describe briefly your pull request.

Checklist

Ticks in all boxes and 🟢 on all GitHub actions status checks are required to merge:

Frontend

Reminder

By using GitHub, you have already agreed to the GitHub’s Terms of Service including that:

  1. You license your contribution under the same terms as the current repository’s license.
  2. You agree that you have the right to license your contribution under the current repository’s license.

def register_index_templates():
"""Register search index templates for events."""
if not current_app.config["STATS_REGISTER_INDEX_TEMPLATES"]:
return []
Copy link
Contributor

Choose a reason for hiding this comment

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

these functions look a bit too similar and I am worried they will be easily confusing, but I don't have a good idea on how to avoid this. Maybe a bit more elaborate comments on both to explain the backwards compatibility of register_templates vs register_index_templates?
also I guess, we cannot raise errors instead of empty list, because we lose the backwards compatibility ?

@@ -70,6 +70,8 @@ invenio_base.api_blueprints =
invenio_stats = invenio_stats.views:blueprint
invenio_search.templates =
invenio_stats = invenio_stats.templates:register_templates
invenio_search.index_templates =
Copy link
Contributor

Choose a reason for hiding this comment

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

any way of installing one or the other, not both? maybe we need to deprecate invenio_search.templates?

@zzacharo
Copy link
Member Author

After discussing with @slint IRL, we decided to drop the deprecation warning and add it only when we have a documented upgrade path.

def register_templates():
"""Register search templates for events."""
if current_app.config["STATS_REGISTER_INDEX_TEMPLATES"]:
return []
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure if it makes sense to show a deprecation warning without having a "way out". Usually these warnings link to some documentation that explains why the change is happening and how to migrate to the new solution (see example below).

I think to move things forward it would be better to cut a minor release, and include this deprecation warning in a new PR that would also include this extra information in the text (and release as a minor/patch).


GH Actions deprecation warning

image

SQLAlchemy

SADeprecationWarning: When transforming <class '__main__.User'> to a
dataclass, attribute(s) "create_user", "update_user" originates from
superclass <class
'__main__.Mixin'>, which is not a dataclass. This usage is deprecated and
will raise an error in SQLAlchemy 2.1. When declaring SQLAlchemy
Declarative Dataclasses, ensure that all mixin classes and other
superclasses which include attributes are also a subclass of
MappedAsDataclass.

@zzacharo zzacharo force-pushed the index-templates branch 2 times, most recently from a49d5f9 to 18a5340 Compare August 14, 2024 13:59
@zzacharo zzacharo force-pushed the index-templates branch 2 times, most recently from f0321c6 to 6f850d0 Compare August 14, 2024 14:27
@zzacharo zzacharo merged commit 634b376 into inveniosoftware:master Aug 14, 2024
2 checks passed
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