Skip to content

Celery task structure improvements - #300

Merged
brianhelba merged 3 commits into
mainfrom
tasks
Jan 14, 2026
Merged

brianhelba merged 3 commits into
mainfrom
tasks

Conversation

@brianhelba

Copy link
Copy Markdown
Member
  • Add missing __init__.py files to tasks
    • These are essential to making these into actual importable modules. Otherwise, they will be considered to be "implicit namespace modules", which have different behavior in subtle ways.
  • Move tasks below the bats_ai.core package
    • This is the canonical location for Celery tasks in Resonant.
    • This is necessary to make app.autodiscover_tasks() work properly, as it scans the INSTALLED_APPS (in this case, core) for a tasks module. Perhaps this also wasn't working before due to the lack of __init__.py, so tasks wasn't considered a real module.
  • Use @app.task instead of @shared_task
    • Previously, @shared_task was preferred by Resonant, but I realized that @app.task will be able to provide better typechecking. @shared_task is essential only for reusable apps (and core isn't reusable). I'll make an upstream change to the Resonant cookiecutter to prefer @app.task too.

These are essential to making these into actual importable modules.
Otherwise, they will be considered to be "implicit namespace
modules", which have different behavior in subtle ways.
This is the canonical location for Celery tasks in Resonant.

This is necessary to make `app.autodiscover_tasks()` work properly,
as it scans the `INSTALLED_APPS` (in this case, `core`) for a
`tasks` module. Perhaps this also wasn't working before due to the
lack of `__init__.py`, so `tasks` wasn't considered a real module.
Previously, `@shared_task` was preferred by Resonant, but I realized
that `@app.task` will be able to provide better typechecking.
`@shared_task` is essential only for reusable apps (and `core` isn't
reusable). I'll make an upstream change to the Resonant
cookiecutter to prefer `@app.task` too.

@BryonLewis BryonLewis left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM - did a quick onceover, pulled and tested some tasks and everything seems to work well.
We'll be switching a lot of internal tasks to using a new tool created by vision (BatBot) for spectrogram generation anyways, I'll clean up then some of the mess of ./tasks/tasks and other stuff. Should be simplified a bit using BatBot.

@brianhelba
brianhelba merged commit ddddd1c into main Jan 14, 2026
5 checks passed
@brianhelba
brianhelba deleted the tasks branch January 14, 2026 18:54
@brianhelba

Copy link
Copy Markdown
Member Author

@naglepuff I'd suggest just looking at the description of this PR, to be aware of the rationale.

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.

2 participants