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

[#2636] stop using human-friendly names for tasks #1320

Merged
merged 1 commit into from
Jul 24, 2024

Conversation

swrichards
Copy link
Collaborator

@swrichards swrichards commented Jul 24, 2024

The Celery docs make clear that the name parameter of the task decorator should be unique and that generally it functions as an identifier the task. From this we can also infer that names that change at runtime, due to gettext, are undesirable. This in fact created issue with triggering certain periodic tasks in the admin, due to a mismatch between the registered name (English) and the translated name used at runtime (Dutch).

TLDR: let Celery generate the name, and directly translate the periodic task names for Beat so that the entries in the Django periodic task admin are human-readable. This is not ideal as we would like to use (lazy) gettext here, but Celery doesn't allow that, so this strikes the balance between human-readability and predictable task discovery.

Taiga 2636.

@codecov-commenter
Copy link

codecov-commenter commented Jul 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.13%. Comparing base (84a27e8) to head (7e96e60).

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1320      +/-   ##
===========================================
- Coverage    95.13%   95.13%   -0.01%     
===========================================
  Files          991      991              
  Lines        35887    35885       -2     
===========================================
- Hits         34141    34139       -2     
  Misses        1746     1746              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

The Celery docs make clear that the name parameter of the
task decorator should be unique and that generally it functions
as an identifier the task. From this we can also infer that
names that change at runtime, due to gettext, are undesirable.
This in fact created issue with triggering certain periodic tasks
in the admin, due to a mismatch between the registered name (English)
and the translated name used at runtime (Dutch).

TLDR: let Celery generate the name, and directly translate the periodic
task names for Beat so that the entries in the Django periodic task
admin are human-readable. This is not ideal as we would like to use
(lazy) gettext here, but Celery doesn't allow that, so this strikes
the balance between human-readability and predictable task discovery.
@swrichards swrichards force-pushed the issues/2636-fix-task-names branch from e70cc71 to 7e96e60 Compare July 24, 2024 12:22
@swrichards swrichards marked this pull request as ready for review July 24, 2024 12:23
@swrichards swrichards requested a review from pi-sigma July 24, 2024 12:23
@swrichards swrichards merged commit be71938 into develop Jul 24, 2024
18 checks passed
@swrichards swrichards deleted the issues/2636-fix-task-names branch July 24, 2024 12:54
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