| 1 |
.. _contributing: |
| 2 |
|
| 3 |
============== |
| 4 |
Contributing |
| 5 |
============== |
| 6 |
|
| 7 |
Welcome! |
| 8 |
|
| 9 |
This document is fairly extensive and you aren't really expected |
| 10 |
to study this in detail for small contributions; |
| 11 |
|
| 12 |
The most important rule is that contributing must be easy |
| 13 |
and that the community is friendly and not nitpicking on details, |
| 14 |
such as coding style. |
| 15 |
|
| 16 |
If you're reporting a bug you should read the Reporting bugs section |
| 17 |
below to ensure that your bug report contains enough information |
| 18 |
to successfully diagnose the issue, and if you're contributing code |
| 19 |
you should try to mimic the conventions you see surrounding the code |
| 20 |
you're working on, but in the end all patches will be cleaned up by |
| 21 |
the person merging the changes so don't worry too much. |
| 22 |
|
| 23 |
.. contents:: |
| 24 |
:local: |
| 25 |
|
| 26 |
.. _community-code-of-conduct: |
| 27 |
|
| 28 |
Community Code of Conduct |
| 29 |
========================= |
| 30 |
|
| 31 |
The goal is to maintain a diverse community that's pleasant for everyone. |
| 32 |
That's why we would greatly appreciate it if everyone contributing to and |
| 33 |
interacting with the community also followed this Code of Conduct. |
| 34 |
|
| 35 |
The Code of Conduct covers our behavior as members of the community, |
| 36 |
in any forum, mailing list, wiki, website, Internet relay chat (IRC), public |
| 37 |
meeting or private correspondence. |
| 38 |
|
| 39 |
The Code of Conduct is heavily based on the `Ubuntu Code of Conduct`_, and |
| 40 |
the `Pylons Code of Conduct`_. |
| 41 |
|
| 42 |
.. _`Ubuntu Code of Conduct`: https://www.ubuntu.com/community/conduct |
| 43 |
.. _`Pylons Code of Conduct`: https://pylonsproject.org/community-code-of-conduct.html |
| 44 |
|
| 45 |
Be considerate |
| 46 |
-------------- |
| 47 |
|
| 48 |
Your work will be used by other people, and you in turn will depend on the |
| 49 |
work of others. Any decision you take will affect users and colleagues, and |
| 50 |
we expect you to take those consequences into account when making decisions. |
| 51 |
Even if it's not obvious at the time, our contributions to Celery will impact |
| 52 |
the work of others. For example, changes to code, infrastructure, policy, |
| 53 |
documentation and translations during a release may negatively impact |
| 54 |
others' work. |
| 55 |
|
| 56 |
Be respectful |
| 57 |
------------- |
| 58 |
|
| 59 |
The Celery community and its members treat one another with respect. Everyone |
| 60 |
can make a valuable contribution to Celery. We may not always agree, but |
| 61 |
disagreement is no excuse for poor behavior and poor manners. We might all |
| 62 |
experience some frustration now and then, but we cannot allow that frustration |
| 63 |
to turn into a personal attack. It's important to remember that a community |
| 64 |
where people feel uncomfortable or threatened isn't a productive one. We |
| 65 |
expect members of the Celery community to be respectful when dealing with |
| 66 |
other contributors as well as with people outside the Celery project and with |
| 67 |
users of Celery. |
| 68 |
|
| 69 |
Be collaborative |
| 70 |
---------------- |
| 71 |
|
| 72 |
Collaboration is central to Celery and to the larger free software community. |
| 73 |
We should always be open to collaboration. Your work should be done |
| 74 |
transparently and patches from Celery should be given back to the community |
| 75 |
when they're made, not just when the distribution releases. If you wish |
| 76 |
to work on new code for existing upstream projects, at least keep those |
| 77 |
projects informed of your ideas and progress. It may not be possible to |
| 78 |
get consensus from upstream, or even from your colleagues about the correct |
| 79 |
implementation for an idea, so don't feel obliged to have that agreement |
| 80 |
before you begin, but at least keep the outside world informed of your work, |
| 81 |
and publish your work in a way that allows outsiders to test, discuss, and |
| 82 |
contribute to your efforts. |
| 83 |
|
| 84 |
When you disagree, consult others |
| 85 |
--------------------------------- |
| 86 |
|
| 87 |
Disagreements, both political and technical, happen all the time and |
| 88 |
the Celery community is no exception. It's important that we resolve |
| 89 |
disagreements and differing views constructively and with the help of the |
| 90 |
community and community process. If you really want to go a different |
| 91 |
way, then we encourage you to make a derivative distribution or alternate |
| 92 |
set of packages that still build on the work we've done to utilize as common |
| 93 |
of a core as possible. |
| 94 |
|
| 95 |
When you're unsure, ask for help |
| 96 |
-------------------------------- |
| 97 |
|
| 98 |
Nobody knows everything, and nobody is expected to be perfect. Asking |
| 99 |
questions avoids many problems down the road, and so questions are |
| 100 |
encouraged. Those who are asked questions should be responsive and helpful. |
| 101 |
However, when asking a question, care must be taken to do so in an appropriate |
| 102 |
forum. |
| 103 |
|
| 104 |
Step down considerately |
| 105 |
----------------------- |
| 106 |
|
| 107 |
Developers on every project come and go and Celery is no different. When you |
| 108 |
leave or disengage from the project, in whole or in part, we ask that you do |
| 109 |
so in a way that minimizes disruption to the project. This means you should |
| 110 |
tell people you're leaving and take the proper steps to ensure that others |
| 111 |
can pick up where you left off. |
| 112 |
|
| 113 |
.. _reporting-bugs: |
| 114 |
|
| 115 |
|
| 116 |
Reporting Bugs |
| 117 |
============== |
| 118 |
|
| 119 |
.. _vulnsec: |
| 120 |
|
| 121 |
Security |
| 122 |
-------- |
| 123 |
|
| 124 |
You must never report security related issues, vulnerabilities or bugs |
| 125 |
including sensitive information to the bug tracker, or elsewhere in public. |
| 126 |
Instead sensitive bugs must be sent by email to ``[email protected]``. |
| 127 |
|
| 128 |
If you'd like to submit the information encrypted our PGP key is:: |
| 129 |
|
| 130 |
-----BEGIN PGP PUBLIC KEY BLOCK----- |
| 131 |
Version: GnuPG v1.4.15 (Darwin) |
| 132 |
|
| 133 |
mQENBFJpWDkBCADFIc9/Fpgse4owLNvsTC7GYfnJL19XO0hnL99sPx+DPbfr+cSE |
| 134 |
9wiU+Wp2TfUX7pCLEGrODiEP6ZCZbgtiPgId+JYvMxpP6GXbjiIlHRw1EQNH8RlX |
| 135 |
cVxy3rQfVv8PGGiJuyBBjxzvETHW25htVAZ5TI1+CkxmuyyEYqgZN2fNd0wEU19D |
| 136 |
+c10G1gSECbCQTCbacLSzdpngAt1Gkrc96r7wGHBBSvDaGDD2pFSkVuTLMbIRrVp |
| 137 |
lnKOPMsUijiip2EMr2DvfuXiUIUvaqInTPNWkDynLoh69ib5xC19CSVLONjkKBsr |
| 138 |
Pe+qAY29liBatatpXsydY7GIUzyBT3MzgMJlABEBAAG0MUNlbGVyeSBTZWN1cml0 |
| 139 |
eSBUZWFtIDxzZWN1cml0eUBjZWxlcnlwcm9qZWN0Lm9yZz6JATgEEwECACIFAlJp |
| 140 |
WDkCGwMGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEOArFOUDCicIw1IH/26f |
| 141 |
CViDC7/P13jr+srRdjAsWvQztia9HmTlY8cUnbmkR9w6b6j3F2ayw8VhkyFWgYEJ |
| 142 |
wtPBv8mHKADiVSFARS+0yGsfCkia5wDSQuIv6XqRlIrXUyqJbmF4NUFTyCZYoh+C |
| 143 |
ZiQpN9xGhFPr5QDlMx2izWg1rvWlG1jY2Es1v/xED3AeCOB1eUGvRe/uJHKjGv7J |
| 144 |
rj0pFcptZX+WDF22AN235WYwgJM6TrNfSu8sv8vNAQOVnsKcgsqhuwomSGsOfMQj |
| 145 |
LFzIn95MKBBU1G5wOs7JtwiV9jefGqJGBO2FAvOVbvPdK/saSnB+7K36dQcIHqms |
| 146 |
5hU4Xj0RIJiod5idlRC5AQ0EUmlYOQEIAJs8OwHMkrdcvy9kk2HBVbdqhgAREMKy |
| 147 |
gmphDp7prRL9FqSY/dKpCbG0u82zyJypdb7QiaQ5pfPzPpQcd2dIcohkkh7G3E+e |
| 148 |
hS2L9AXHpwR26/PzMBXyr2iNnNc4vTksHvGVDxzFnRpka6vbI/hrrZmYNYh9EAiv |
| 149 |
uhE54b3/XhXwFgHjZXb9i8hgJ3nsO0pRwvUAM1bRGMbvf8e9F+kqgV0yWYNnh6QL |
| 150 |
4Vpl1+epqp2RKPHyNQftbQyrAHXT9kQF9pPlx013MKYaFTADscuAp4T3dy7xmiwS |
| 151 |
crqMbZLzfrxfFOsNxTUGE5vmJCcm+mybAtRo4aV6ACohAO9NevMx8pUAEQEAAYkB |
| 152 |
HwQYAQIACQUCUmlYOQIbDAAKCRDgKxTlAwonCNFbB/9esir/f7TufE+isNqErzR/ |
| 153 |
aZKZo2WzZR9c75kbqo6J6DYuUHe6xI0OZ2qZ60iABDEZAiNXGulysFLCiPdatQ8x |
| 154 |
8zt3DF9BMkEck54ZvAjpNSern6zfZb1jPYWZq3TKxlTs/GuCgBAuV4i5vDTZ7xK/ |
| 155 |
aF+OFY5zN7ciZHkqLgMiTZ+RhqRcK6FhVBP/Y7d9NlBOcDBTxxE1ZO1ute6n7guJ |
| 156 |
ciw4hfoRk8qNN19szZuq3UU64zpkM2sBsIFM9tGF2FADRxiOaOWZHmIyVZriPFqW |
| 157 |
RUwjSjs7jBVNq0Vy4fCu/5+e+XLOUBOoqtM5W7ELt0t1w9tXebtPEetV86in8fU2 |
| 158 |
=0chn |
| 159 |
-----END PGP PUBLIC KEY BLOCK----- |
| 160 |
|
| 161 |
Other bugs |
| 162 |
---------- |
| 163 |
|
| 164 |
Bugs can always be described to the :ref:`mailing-list`, but the best |
| 165 |
way to report an issue and to ensure a timely response is to use the |
| 166 |
issue tracker. |
| 167 |
|
| 168 |
1) **Create a GitHub account**. |
| 169 |
|
| 170 |
You need to `create a GitHub account`_ to be able to create new issues |
| 171 |
and participate in the discussion. |
| 172 |
|
| 173 |
.. _`create a GitHub account`: https://github.com/signup/free |
| 174 |
|
| 175 |
2) **Determine if your bug is really a bug**. |
| 176 |
|
| 177 |
You shouldn't file a bug if you're requesting support. For that you can use |
| 178 |
the :ref:`mailing-list`, or :ref:`irc-channel`. If you still need support |
| 179 |
you can open a github issue, please prepend the title with ``[QUESTION]``. |
| 180 |
|
| 181 |
3) **Make sure your bug hasn't already been reported**. |
| 182 |
|
| 183 |
Search through the appropriate Issue tracker. If a bug like yours was found, |
| 184 |
check if you have new information that could be reported to help |
| 185 |
the developers fix the bug. |
| 186 |
|
| 187 |
4) **Check if you're using the latest version**. |
| 188 |
|
| 189 |
A bug could be fixed by some other improvements and fixes - it might not have an |
| 190 |
existing report in the bug tracker. Make sure you're using the latest releases of |
| 191 |
celery, billiard, kombu, amqp, and vine. |
| 192 |
|
| 193 |
5) **Collect information about the bug**. |
| 194 |
|
| 195 |
To have the best chance of having a bug fixed, we need to be able to easily |
| 196 |
reproduce the conditions that caused it. Most of the time this information |
| 197 |
will be from a Python traceback message, though some bugs might be in design, |
| 198 |
spelling or other errors on the website/docs/code. |
| 199 |
|
| 200 |
A) If the error is from a Python traceback, include it in the bug report. |
| 201 |
|
| 202 |
B) We also need to know what platform you're running (Windows, macOS, Linux, |
| 203 |
etc.), the version of your Python interpreter, and the version of Celery, |
| 204 |
and related packages that you were running when the bug occurred. |
| 205 |
|
| 206 |
C) If you're reporting a race condition or a deadlock, tracebacks can be |
| 207 |
hard to get or might not be that useful. Try to inspect the process to |
| 208 |
get more diagnostic data. Some ideas: |
| 209 |
|
| 210 |
* Enable Celery's :ref:`breakpoint signal <breakpoint_signal>` and use it |
| 211 |
to inspect the process's state. This will allow you to open a |
| 212 |
:mod:`pdb` session. |
| 213 |
* Collect tracing data using `strace`_(Linux), |
| 214 |
:command:`dtruss` (macOS), and :command:`ktrace` (BSD), |
| 215 |
`ltrace`_, and `lsof`_. |
| 216 |
|
| 217 |
D) Include the output from the :command:`celery report` command: |
| 218 |
|
| 219 |
.. code-block:: console |
| 220 |
|
| 221 |
$ celery -A proj report |
| 222 |
|
| 223 |
This will also include your configuration settings and it will try to |
| 224 |
remove values for keys known to be sensitive, but make sure you also |
| 225 |
verify the information before submitting so that it doesn't contain |
| 226 |
confidential information like API tokens and authentication |
| 227 |
credentials. |
| 228 |
|
| 229 |
E) Your issue might be tagged as `Needs Test Case`. A test case represents |
| 230 |
all the details needed to reproduce what your issue is reporting. |
| 231 |
A test case can be some minimal code that reproduces the issue or |
| 232 |
detailed instructions and configuration values that reproduces |
| 233 |
said issue. |
| 234 |
|
| 235 |
6) **Submit the bug**. |
| 236 |
|
| 237 |
By default `GitHub`_ will email you to let you know when new comments have |
| 238 |
been made on your bug. In the event you've turned this feature off, you |
| 239 |
should check back on occasion to ensure you don't miss any questions a |
| 240 |
developer trying to fix the bug might ask. |
| 241 |
|
| 242 |
.. _`GitHub`: https://github.com |
| 243 |
.. _`strace`: https://en.wikipedia.org/wiki/Strace |
| 244 |
.. _`ltrace`: https://en.wikipedia.org/wiki/Ltrace |
| 245 |
.. _`lsof`: https://en.wikipedia.org/wiki/Lsof |
| 246 |
|
| 247 |
.. _issue-trackers: |
| 248 |
|
| 249 |
Issue Trackers |
| 250 |
-------------- |
| 251 |
|
| 252 |
Bugs for a package in the Celery ecosystem should be reported to the relevant |
| 253 |
issue tracker. |
| 254 |
|
| 255 |
* :pypi:`celery`: https://github.com/celery/celery/issues/ |
| 256 |
* :pypi:`kombu`: https://github.com/celery/kombu/issues |
| 257 |
* :pypi:`amqp`: https://github.com/celery/py-amqp/issues |
| 258 |
* :pypi:`vine`: https://github.com/celery/vine/issues |
| 259 |
* :pypi:`pytest-celery`: https://github.com/celery/pytest-celery/issues |
| 260 |
* :pypi:`librabbitmq`: https://github.com/celery/librabbitmq/issues |
| 261 |
* :pypi:`django-celery-beat`: https://github.com/celery/django-celery-beat/issues |
| 262 |
* :pypi:`django-celery-results`: https://github.com/celery/django-celery-results/issues |
| 263 |
|
| 264 |
If you're unsure of the origin of the bug you can ask the |
| 265 |
:ref:`mailing-list`, or just use the Celery issue tracker. |
| 266 |
|
| 267 |
Contributors guide to the code base |
| 268 |
=================================== |
| 269 |
|
| 270 |
There's a separate section for internal details, |
| 271 |
including details about the code base and a style guide. |
| 272 |
|
| 273 |
Read :ref:`internals-guide` for more! |
| 274 |
|
| 275 |
.. _versions: |
| 276 |
|
| 277 |
Versions |
| 278 |
======== |
| 279 |
|
| 280 |
Version numbers consists of a major version, minor version and a release number. |
| 281 |
Since version 2.1.0 we use the versioning semantics described by |
| 282 |
SemVer: http://semver.org. |
| 283 |
|
| 284 |
Stable releases are published at PyPI |
| 285 |
while development releases are only available in the GitHub git repository as tags. |
| 286 |
All version tags starts with “v”, so version 0.8.0 has the tag v0.8.0. |
| 287 |
|
| 288 |
.. _git-branches: |
| 289 |
|
| 290 |
Branches |
| 291 |
======== |
| 292 |
|
| 293 |
Current active version branches: |
| 294 |
|
| 295 |
* dev (which git calls "main") (https://github.com/celery/celery/tree/main) |
| 296 |
* 4.5 (https://github.com/celery/celery/tree/v4.5) |
| 297 |
* 3.1 (https://github.com/celery/celery/tree/3.1) |
| 298 |
|
| 299 |
You can see the state of any branch by looking at the Changelog: |
| 300 |
|
| 301 |
https://github.com/celery/celery/blob/main/Changelog.rst |
| 302 |
|
| 303 |
If the branch is in active development the topmost version info should |
| 304 |
contain meta-data like: |
| 305 |
|
| 306 |
.. code-block:: restructuredtext |
| 307 |
|
| 308 |
4.3.0 |
| 309 |
====== |
| 310 |
:release-date: TBA |
| 311 |
:status: DEVELOPMENT |
| 312 |
:branch: dev (git calls this main) |
| 313 |
|
| 314 |
The ``status`` field can be one of: |
| 315 |
|
| 316 |
* ``PLANNING`` |
| 317 |
|
| 318 |
The branch is currently experimental and in the planning stage. |
| 319 |
|
| 320 |
* ``DEVELOPMENT`` |
| 321 |
|
| 322 |
The branch is in active development, but the test suite should |
| 323 |
be passing and the product should be working and possible for users to test. |
| 324 |
|
| 325 |
* ``FROZEN`` |
| 326 |
|
| 327 |
The branch is frozen, and no more features will be accepted. |
| 328 |
When a branch is frozen the focus is on testing the version as much |
| 329 |
as possible before it is released. |
| 330 |
|
| 331 |
dev branch |
| 332 |
---------- |
| 333 |
|
| 334 |
The dev branch (called "main" by git), is where development of the next |
| 335 |
version happens. |
| 336 |
|
| 337 |
Maintenance branches |
| 338 |
-------------------- |
| 339 |
|
| 340 |
Maintenance branches are named after the version -- for example, |
| 341 |
the maintenance branch for the 2.2.x series is named ``2.2``. |
| 342 |
|
| 343 |
Previously these were named ``releaseXX-maint``. |
| 344 |
|
| 345 |
The versions we currently maintain is: |
| 346 |
|
| 347 |
* 4.2 |
| 348 |
|
| 349 |
This is the current series. |
| 350 |
|
| 351 |
* 4.1 |
| 352 |
|
| 353 |
Drop support for python 2.6. Add support for python 3.4, 3.5 and 3.6. |
| 354 |
|
| 355 |
* 3.1 |
| 356 |
|
| 357 |
Official support for python 2.6, 2.7 and 3.3, and also supported on PyPy. |
| 358 |
|
| 359 |
Archived branches |
| 360 |
----------------- |
| 361 |
|
| 362 |
Archived branches are kept for preserving history only, |
| 363 |
and theoretically someone could provide patches for these if they depend |
| 364 |
on a series that's no longer officially supported. |
| 365 |
|
| 366 |
An archived version is named ``X.Y-archived``. |
| 367 |
|
| 368 |
To maintain a cleaner history and drop compatibility to continue improving |
| 369 |
the project, we **do not have any archived version** right now. |
| 370 |
|
| 371 |
Feature branches |
| 372 |
---------------- |
| 373 |
|
| 374 |
Major new features are worked on in dedicated branches. |
| 375 |
There's no strict naming requirement for these branches. |
| 376 |
|
| 377 |
Feature branches are removed once they've been merged into a release branch. |
| 378 |
|
| 379 |
Tags |
| 380 |
==== |
| 381 |
|
| 382 |
- Tags are used exclusively for tagging releases. A release tag is |
| 383 |
named with the format ``vX.Y.Z`` -- for example ``v2.3.1``. |
| 384 |
|
| 385 |
- Experimental releases contain an additional identifier ``vX.Y.Z-id`` -- |
| 386 |
for example ``v3.0.0-rc1``. |
| 387 |
|
| 388 |
- Experimental tags may be removed after the official release. |
| 389 |
|
| 390 |
.. _contributing-changes: |
| 391 |
|
| 392 |
Working on Features & Patches |
| 393 |
============================= |
| 394 |
|
| 395 |
.. note:: |
| 396 |
|
| 397 |
Contributing to Celery should be as simple as possible, |
| 398 |
so none of these steps should be considered mandatory. |
| 399 |
|
| 400 |
You can even send in patches by email if that's your preferred |
| 401 |
work method. We won't like you any less, any contribution you make |
| 402 |
is always appreciated! |
| 403 |
|
| 404 |
However, following these steps may make maintainer's life easier, |
| 405 |
and may mean that your changes will be accepted sooner. |
| 406 |
|
| 407 |
Forking and setting up the repository |
| 408 |
------------------------------------- |
| 409 |
|
| 410 |
First you need to fork the Celery repository; a good introduction to this |
| 411 |
is in the GitHub Guide: `Fork a Repo`_. |
| 412 |
|
| 413 |
After you have cloned the repository, you should checkout your copy |
| 414 |
to a directory on your machine: |
| 415 |
|
| 416 |
.. code-block:: console |
| 417 |
|
| 418 |
$ git clone [email protected]:username/celery.git |
| 419 |
|
| 420 |
When the repository is cloned, enter the directory to set up easy access |
| 421 |
to upstream changes: |
| 422 |
|
| 423 |
.. code-block:: console |
| 424 |
|
| 425 |
$ cd celery |
| 426 |
$ git remote add upstream [email protected]:celery/celery.git |
| 427 |
$ git fetch upstream |
| 428 |
|
| 429 |
If you need to pull in new changes from upstream you should |
| 430 |
always use the ``--rebase`` option to ``git pull``: |
| 431 |
|
| 432 |
.. code-block:: console |
| 433 |
|
| 434 |
git pull --rebase upstream main |
| 435 |
|
| 436 |
With this option, you don't clutter the history with merging |
| 437 |
commit notes. See `Rebasing merge commits in git`_. |
| 438 |
If you want to learn more about rebasing, see the `Rebase`_ |
| 439 |
section in the GitHub guides. |
| 440 |
|
| 441 |
If you need to work on a different branch than the one git calls ``main``, you can |
| 442 |
fetch and checkout a remote branch like this:: |
| 443 |
|
| 444 |
git checkout --track -b 5.0-devel upstream/5.0-devel |
| 445 |
|
| 446 |
**Note:** Any feature or fix branch should be created from ``upstream/main``. |
| 447 |
|
| 448 |
.. _`Fork a Repo`: https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/fork-a-repo |
| 449 |
.. _`Rebasing merge commits in git`: |
| 450 |
https://web.archive.org/web/20150627054345/http://marketblog.envato.com/general/rebasing-merge-commits-in-git/ |
| 451 |
.. _`Rebase`: https://docs.github.com/en/get-started/using-git/about-git-rebase |
| 452 |
|
| 453 |
.. _contributing-docker-development: |
| 454 |
|
| 455 |
Developing and Testing with Docker |
| 456 |
---------------------------------- |
| 457 |
|
| 458 |
Because of the many components of Celery, such as a broker and backend, |
| 459 |
`Docker`_ and `docker-compose`_ can be utilized to greatly simplify the |
| 460 |
development and testing cycle. The Docker configuration here requires a |
| 461 |
Docker version of at least 17.13.0 and `docker-compose` 1.13.0+. |
| 462 |
|
| 463 |
The Docker components can be found within the :file:`docker/` folder and the |
| 464 |
Docker image can be built via: |
| 465 |
|
| 466 |
.. code-block:: console |
| 467 |
|
| 468 |
$ docker compose build celery |
| 469 |
|
| 470 |
and run via: |
| 471 |
|
| 472 |
.. code-block:: console |
| 473 |
|
| 474 |
$ docker compose run --rm celery <command> |
| 475 |
|
| 476 |
where <command> is a command to execute in a Docker container. The `--rm` flag |
| 477 |
indicates that the container should be removed after it is exited and is useful |
| 478 |
to prevent accumulation of unwanted containers. |
| 479 |
|
| 480 |
Some useful commands to run: |
| 481 |
|
| 482 |
* ``bash`` |
| 483 |
|
| 484 |
To enter the Docker container like a normal shell |
| 485 |
|
| 486 |
* ``make test`` |
| 487 |
|
| 488 |
To run the test suite. |
| 489 |
**Note:** This will run tests using python 3.12 by default. |
| 490 |
|
| 491 |
* ``tox`` |
| 492 |
|
| 493 |
To run tox and test against a variety of configurations. |
| 494 |
**Note:** This command will run tests for every environment defined in :file:`tox.ini`. |
| 495 |
It takes a while. |
| 496 |
|
| 497 |
* ``pyenv exec python{3.8,3.9,3.10,3.11,3.12} -m pytest t/unit`` |
| 498 |
|
| 499 |
To run unit tests using pytest. |
| 500 |
|
| 501 |
**Note:** ``{3.8,3.9,3.10,3.11,3.12}`` means you can use any of those options. |
| 502 |
e.g. ``pyenv exec python3.12 -m pytest t/unit`` |
| 503 |
|
| 504 |
* ``pyenv exec python{3.8,3.9,3.10,3.11,3.12} -m pytest t/integration`` |
| 505 |
|
| 506 |
To run integration tests using pytest |
| 507 |
|
| 508 |
**Note:** ``{3.8,3.9,3.10,3.11,3.12}`` means you can use any of those options. |
| 509 |
e.g. ``pyenv exec python3.12 -m pytest t/unit`` |
| 510 |
|
| 511 |
By default, docker-compose will mount the Celery and test folders in the Docker |
| 512 |
container, allowing code changes and testing to be immediately visible inside |
| 513 |
the Docker container. Environment variables, such as the broker and backend to |
| 514 |
use are also defined in the :file:`docker/docker-compose.yml` file. |
| 515 |
|
| 516 |
By running ``docker compose build celery`` an image will be created with the |
| 517 |
name ``celery/celery:dev``. This docker image has every dependency needed |
| 518 |
for development installed. ``pyenv`` is used to install multiple python |
| 519 |
versions, the docker image offers python 3.8, 3.9, 3.10, 3.11 and 3.12. |
| 520 |
The default python version is set to 3.12. |
| 521 |
|
| 522 |
The :file:`docker-compose.yml` file defines the necessary environment variables |
| 523 |
to run integration tests. The ``celery`` service also mounts the codebase |
| 524 |
and sets the ``PYTHONPATH`` environment variable to ``/home/developer/celery``. |
| 525 |
By setting ``PYTHONPATH`` the service allows to use the mounted codebase |
| 526 |
as global module for development. If you prefer, you can also run |
| 527 |
``python -m pip install -e .`` to install the codebase in development mode. |
| 528 |
|
| 529 |
If you would like to run a Django or stand alone project to manually test or |
| 530 |
debug a feature, you can use the image built by `docker compose` and mount |
| 531 |
your custom code. Here's an example: |
| 532 |
|
| 533 |
Assuming a folder structure such as: |
| 534 |
|
| 535 |
.. code-block:: console |
| 536 |
|
| 537 |
+ celery_project |
| 538 |
+ celery # repository cloned here. |
| 539 |
+ my_project |
| 540 |
- manage.py |
| 541 |
+ my_project |
| 542 |
- views.py |
| 543 |
|
| 544 |
.. code-block:: yaml |
| 545 |
|
| 546 |
version: "3" |
| 547 |
|
| 548 |
services: |
| 549 |
celery: |
| 550 |
image: celery/celery:dev |
| 551 |
environment: |
| 552 |
TEST_BROKER: amqp://rabbit:5672 |
| 553 |
TEST_BACKEND: redis://redis |
| 554 |
volumes: |
| 555 |
- ../../celery:/home/developer/celery |
| 556 |
- ../my_project:/home/developer/my_project |
| 557 |
depends_on: |
| 558 |
- rabbit |
| 559 |
- redis |
| 560 |
rabbit: |
| 561 |
image: rabbitmq:latest |
| 562 |
redis: |
| 563 |
image: redis:latest |
| 564 |
|
| 565 |
In the previous example, we are using the image that we can build from |
| 566 |
this repository and mounting the celery code base as well as our custom |
| 567 |
project. |
| 568 |
|
| 569 |
.. _`Docker`: https://www.docker.com/ |
| 570 |
.. _`docker-compose`: https://docs.docker.com/compose/ |
| 571 |
|
| 572 |
.. _contributing-testing: |
| 573 |
|
| 574 |
Running the unit test suite |
| 575 |
--------------------------- |
| 576 |
|
| 577 |
If you like to develop using virtual environments or just outside docker, |
| 578 |
you must make sure all necessary dependencies are installed. |
| 579 |
There are multiple requirements files to make it easier to install all dependencies. |
| 580 |
You do not have to use every requirements file but you must use `default.txt`. |
| 581 |
|
| 582 |
.. code-block:: console |
| 583 |
|
| 584 |
# pip install -U -r requirements/default.txt |
| 585 |
|
| 586 |
To run the Celery test suite you need to install |
| 587 |
:file:`requirements/test.txt`. |
| 588 |
|
| 589 |
.. code-block:: console |
| 590 |
|
| 591 |
$ pip install -U -r requirements/test.txt |
| 592 |
$ pip install -U -r requirements/default.txt |
| 593 |
|
| 594 |
After installing the dependencies required, you can now execute |
| 595 |
the test suite by calling :pypi:`pytest <pytest>`: |
| 596 |
|
| 597 |
.. code-block:: console |
| 598 |
|
| 599 |
$ pytest t/unit |
| 600 |
$ pytest t/integration |
| 601 |
|
| 602 |
Some useful options to :command:`pytest` are: |
| 603 |
|
| 604 |
* ``-x`` |
| 605 |
|
| 606 |
Stop running the tests at the first test that fails. |
| 607 |
|
| 608 |
* ``-s`` |
| 609 |
|
| 610 |
Don't capture output |
| 611 |
|
| 612 |
* ``-v`` |
| 613 |
|
| 614 |
Run with verbose output. |
| 615 |
|
| 616 |
If you want to run the tests for a single test file only |
| 617 |
you can do so like this: |
| 618 |
|
| 619 |
.. code-block:: console |
| 620 |
|
| 621 |
$ pytest t/unit/worker/test_worker.py |
| 622 |
|
| 623 |
.. _contributing-coverage: |
| 624 |
|
| 625 |
Calculating test coverage |
| 626 |
~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 627 |
|
| 628 |
To calculate test coverage you must first install the :pypi:`pytest-cov` module. |
| 629 |
|
| 630 |
Installing the :pypi:`pytest-cov` module: |
| 631 |
|
| 632 |
.. code-block:: console |
| 633 |
|
| 634 |
$ pip install -U pytest-cov |
| 635 |
|
| 636 |
Code coverage in HTML format |
| 637 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 638 |
|
| 639 |
#. Run :command:`pytest` with the ``--cov-report=html`` argument enabled: |
| 640 |
|
| 641 |
.. code-block:: console |
| 642 |
|
| 643 |
$ pytest --cov=celery --cov-report=html |
| 644 |
|
| 645 |
#. The coverage output will then be located in the :file:`htmlcov/` directory: |
| 646 |
|
| 647 |
.. code-block:: console |
| 648 |
|
| 649 |
$ open htmlcov/index.html |
| 650 |
|
| 651 |
Code coverage in XML (Cobertura-style) |
| 652 |
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ |
| 653 |
|
| 654 |
#. Run :command:`pytest` with the ``--cov-report=xml`` argument enabled: |
| 655 |
|
| 656 |
.. code-block:: console |
| 657 |
|
| 658 |
$ pytest --cov=celery --cov-report=xml |
| 659 |
|
| 660 |
#. The coverage XML output will then be located in the :file:`coverage.xml` file. |
| 661 |
|
| 662 |
.. _contributing-tox: |
| 663 |
|
| 664 |
Running the tests on all supported Python versions |
| 665 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 666 |
|
| 667 |
There's a :pypi:`tox` configuration file in the top directory of the |
| 668 |
distribution. |
| 669 |
|
| 670 |
To run the tests for all supported Python versions simply execute: |
| 671 |
|
| 672 |
.. code-block:: console |
| 673 |
|
| 674 |
$ tox |
| 675 |
|
| 676 |
Use the ``tox -e`` option if you only want to test specific Python versions: |
| 677 |
|
| 678 |
.. code-block:: console |
| 679 |
|
| 680 |
$ tox -e 3.7 |
| 681 |
|
| 682 |
Building the documentation |
| 683 |
-------------------------- |
| 684 |
|
| 685 |
To build the documentation, you need to install the dependencies |
| 686 |
listed in :file:`requirements/docs.txt` and :file:`requirements/default.txt`: |
| 687 |
|
| 688 |
.. code-block:: console |
| 689 |
|
| 690 |
$ pip install -U -r requirements/docs.txt |
| 691 |
$ pip install -U -r requirements/default.txt |
| 692 |
|
| 693 |
Additionally, to build with no warnings, you will need to install |
| 694 |
the following packages: |
| 695 |
|
| 696 |
.. code-block:: console |
| 697 |
|
| 698 |
$ apt-get install texlive texlive-latex-extra dvipng |
| 699 |
|
| 700 |
After these dependencies are installed, you should be able to |
| 701 |
build the docs by running: |
| 702 |
|
| 703 |
.. code-block:: console |
| 704 |
|
| 705 |
$ cd docs |
| 706 |
$ rm -rf _build |
| 707 |
$ make html |
| 708 |
|
| 709 |
Make sure there are no errors or warnings in the build output. |
| 710 |
After building succeeds, the documentation is available at :file:`_build/html`. |
| 711 |
|
| 712 |
.. _contributing-verify: |
| 713 |
|
| 714 |
Build the documentation using Docker |
| 715 |
------------------------------------ |
| 716 |
|
| 717 |
Build the documentation by running: |
| 718 |
|
| 719 |
.. code-block:: console |
| 720 |
|
| 721 |
$ docker compose -f docker/docker-compose.yml up --build docs |
| 722 |
|
| 723 |
The service will start a local docs server at ``:7000``. The server is using |
| 724 |
``sphinx-autobuild`` with the ``--watch`` option enabled, so you can live |
| 725 |
edit the documentation. Check the additional options and configs in |
| 726 |
:file:`docker/docker-compose.yml` |
| 727 |
|
| 728 |
Verifying your contribution |
| 729 |
--------------------------- |
| 730 |
|
| 731 |
To use these tools, you need to install a few dependencies. These dependencies |
| 732 |
can be found in :file:`requirements/pkgutils.txt`. |
| 733 |
|
| 734 |
Installing the dependencies: |
| 735 |
|
| 736 |
.. code-block:: console |
| 737 |
|
| 738 |
$ pip install -U -r requirements/pkgutils.txt |
| 739 |
|
| 740 |
pyflakes & PEP-8 |
| 741 |
~~~~~~~~~~~~~~~~ |
| 742 |
|
| 743 |
To ensure that your changes conform to :pep:`8` and to run pyflakes |
| 744 |
execute: |
| 745 |
|
| 746 |
.. code-block:: console |
| 747 |
|
| 748 |
$ make flakecheck |
| 749 |
|
| 750 |
To not return a negative exit code when this command fails, use |
| 751 |
the ``flakes`` target instead: |
| 752 |
|
| 753 |
.. code-block:: console |
| 754 |
|
| 755 |
$ make flakes |
| 756 |
|
| 757 |
API reference |
| 758 |
~~~~~~~~~~~~~ |
| 759 |
|
| 760 |
To make sure that all modules have a corresponding section in the API |
| 761 |
reference, please execute: |
| 762 |
|
| 763 |
.. code-block:: console |
| 764 |
|
| 765 |
$ make apicheck |
| 766 |
|
| 767 |
If files are missing, you can add them by copying an existing reference file. |
| 768 |
|
| 769 |
If the module is internal, it should be part of the internal reference |
| 770 |
located in :file:`docs/internals/reference/`. If the module is public, |
| 771 |
it should be located in :file:`docs/reference/`. |
| 772 |
|
| 773 |
For example, if reference is missing for the module ``celery.worker.awesome`` |
| 774 |
and this module is considered part of the public API, use the following steps: |
| 775 |
|
| 776 |
|
| 777 |
Use an existing file as a template: |
| 778 |
|
| 779 |
.. code-block:: console |
| 780 |
|
| 781 |
$ cd docs/reference/ |
| 782 |
$ cp celery.schedules.rst celery.worker.awesome.rst |
| 783 |
|
| 784 |
Edit the file using your favorite editor: |
| 785 |
|
| 786 |
.. code-block:: console |
| 787 |
|
| 788 |
$ vim celery.worker.awesome.rst |
| 789 |
|
| 790 |
# change every occurrence of ``celery.schedules`` to |
| 791 |
# ``celery.worker.awesome`` |
| 792 |
|
| 793 |
|
| 794 |
Edit the index using your favorite editor: |
| 795 |
|
| 796 |
.. code-block:: console |
| 797 |
|
| 798 |
$ vim index.rst |
| 799 |
|
| 800 |
# Add ``celery.worker.awesome`` to the index. |
| 801 |
|
| 802 |
|
| 803 |
Commit your changes: |
| 804 |
|
| 805 |
.. code-block:: console |
| 806 |
|
| 807 |
# Add the file to git |
| 808 |
$ git add celery.worker.awesome.rst |
| 809 |
$ git add index.rst |
| 810 |
$ git commit celery.worker.awesome.rst index.rst \ |
| 811 |
-m "Adds reference for celery.worker.awesome" |
| 812 |
|
| 813 |
Isort |
| 814 |
~~~~~~ |
| 815 |
|
| 816 |
`Isort`_ is a python utility to help sort imports alphabetically and separated into sections. |
| 817 |
The Celery project uses isort to better maintain imports on every module. |
| 818 |
Please run isort if there are any new modules or the imports on an existent module |
| 819 |
had to be modified. |
| 820 |
|
| 821 |
.. code-block:: console |
| 822 |
|
| 823 |
$ isort my_module.py # Run isort for one file |
| 824 |
$ isort -rc . # Run it recursively |
| 825 |
$ isort m_module.py --diff # Do a dry-run to see the proposed changes |
| 826 |
|
| 827 |
.. _`Isort`: https://isort.readthedocs.io/en/latest/ |
| 828 |
|
| 829 |
.. _contributing-pull-requests: |
| 830 |
|
| 831 |
Creating pull requests |
| 832 |
---------------------- |
| 833 |
|
| 834 |
When your feature/bugfix is complete, you may want to submit |
| 835 |
a pull request, so that it can be reviewed by the maintainers. |
| 836 |
|
| 837 |
Before submitting a pull request, please make sure you go through this checklist to |
| 838 |
make it easier for the maintainers to accept your proposed changes: |
| 839 |
|
| 840 |
- [ ] Make sure any change or new feature has a unit and/or integration test. |
| 841 |
If a test is not written, a label will be assigned to your PR with the name |
| 842 |
``Needs Test Coverage``. |
| 843 |
|
| 844 |
- [ ] Make sure unit test coverage does not decrease. |
| 845 |
``pytest -xv --cov=celery --cov-report=xml --cov-report term``. |
| 846 |
You can check the current test coverage here: https://codecov.io/gh/celery/celery |
| 847 |
|
| 848 |
- [ ] Run ``pre-commit`` against the code. The following commands are valid |
| 849 |
and equivalent.: |
| 850 |
|
| 851 |
.. code-block:: console |
| 852 |
|
| 853 |
$ pre-commit run --all-files |
| 854 |
$ tox -e lint |
| 855 |
|
| 856 |
- [ ] Build api docs to make sure everything is OK. The following commands are valid |
| 857 |
and equivalent.: |
| 858 |
|
| 859 |
.. code-block:: console |
| 860 |
|
| 861 |
$ make apicheck |
| 862 |
$ cd docs && sphinx-build -b apicheck -d _build/doctrees . _build/apicheck |
| 863 |
$ tox -e apicheck |
| 864 |
|
| 865 |
- [ ] Build configcheck. The following commands are valid |
| 866 |
and equivalent.: |
| 867 |
|
| 868 |
.. code-block:: console |
| 869 |
|
| 870 |
$ make configcheck |
| 871 |
$ cd docs && sphinx-build -b configcheck -d _build/doctrees . _build/configcheck |
| 872 |
$ tox -e configcheck |
| 873 |
|
| 874 |
- [ ] Run ``bandit`` to make sure there's no security issues. The following commands are valid |
| 875 |
and equivalent.: |
| 876 |
|
| 877 |
.. code-block:: console |
| 878 |
|
| 879 |
$ pip install -U bandit |
| 880 |
$ bandit -b bandit.json celery/ |
| 881 |
$ tox -e bandit |
| 882 |
|
| 883 |
- [ ] Run unit and integration tests for every python version. The following commands are valid |
| 884 |
and equivalent.: |
| 885 |
|
| 886 |
.. code-block:: console |
| 887 |
|
| 888 |
$ tox -v |
| 889 |
|
| 890 |
- [ ] Confirm ``isort`` on any new or modified imports: |
| 891 |
|
| 892 |
.. code-block:: console |
| 893 |
|
| 894 |
$ isort my_module.py --diff |
| 895 |
|
| 896 |
Creating pull requests is easy, and they also let you track the progress |
| 897 |
of your contribution. Read the `Pull Requests`_ section in the GitHub |
| 898 |
Guide to learn how this is done. |
| 899 |
|
| 900 |
You can also attach pull requests to existing issues by following |
| 901 |
the steps outlined here: https://bit.ly/koJoso |
| 902 |
|
| 903 |
You can also use `hub`_ to create pull requests. Example: https://theiconic.tech/git-hub-fbe2e13ef4d1 |
| 904 |
|
| 905 |
.. _`Pull Requests`: http://help.github.com/send-pull-requests/ |
| 906 |
|
| 907 |
.. _`hub`: https://hub.github.com/ |
| 908 |
|
| 909 |
Status Labels |
| 910 |
~~~~~~~~~~~~~~ |
| 911 |
|
| 912 |
There are `different labels`_ used to easily manage github issues and PRs. |
| 913 |
Most of these labels make it easy to categorize each issue with important |
| 914 |
details. For instance, you might see a ``Component:canvas`` label on an issue or PR. |
| 915 |
The ``Component:canvas`` label means the issue or PR corresponds to the canvas functionality. |
| 916 |
These labels are set by the maintainers and for the most part external contributors |
| 917 |
should not worry about them. A subset of these labels are prepended with **Status:**. |
| 918 |
Usually the **Status:** labels show important actions which the issue or PR needs. |
| 919 |
Here is a summary of such statuses: |
| 920 |
|
| 921 |
- **Status: Cannot Reproduce** |
| 922 |
|
| 923 |
One or more Celery core team member has not been able to reproduce the issue. |
| 924 |
|
| 925 |
- **Status: Confirmed** |
| 926 |
|
| 927 |
The issue or PR has been confirmed by one or more Celery core team member. |
| 928 |
|
| 929 |
- **Status: Duplicate** |
| 930 |
|
| 931 |
A duplicate issue or PR. |
| 932 |
|
| 933 |
- **Status: Feedback Needed** |
| 934 |
|
| 935 |
One or more Celery core team member has asked for feedback on the issue or PR. |
| 936 |
|
| 937 |
- **Status: Has Testcase** |
| 938 |
|
| 939 |
It has been confirmed the issue or PR includes a test case. |
| 940 |
This is particularly important to correctly write tests for any new |
| 941 |
feature or bug fix. |
| 942 |
|
| 943 |
- **Status: In Progress** |
| 944 |
|
| 945 |
The PR is still in progress. |
| 946 |
|
| 947 |
- **Status: Invalid** |
| 948 |
|
| 949 |
The issue reported or the PR is not valid for the project. |
| 950 |
|
| 951 |
- **Status: Needs Documentation** |
| 952 |
|
| 953 |
The PR does not contain documentation for the feature or bug fix proposed. |
| 954 |
|
| 955 |
- **Status: Needs Rebase** |
| 956 |
|
| 957 |
The PR has not been rebased with ``main``. It is very important to rebase |
| 958 |
PRs before they can be merged to ``main`` to solve any merge conflicts. |
| 959 |
|
| 960 |
- **Status: Needs Test Coverage** |
| 961 |
|
| 962 |
Celery uses `codecov`_ to verify code coverage. Please make sure PRs do not |
| 963 |
decrease code coverage. This label will identify PRs which need code coverage. |
| 964 |
|
| 965 |
- **Status: Needs Test Case** |
| 966 |
|
| 967 |
The issue or PR needs a test case. A test case can be a minimal code snippet |
| 968 |
that reproduces an issue or a detailed set of instructions and configuration values |
| 969 |
that reproduces the issue reported. If possible a test case can be submitted in |
| 970 |
the form of a PR to Celery's integration suite. The test case will be marked |
| 971 |
as failed until the bug is fixed. When a test case cannot be run by Celery's |
| 972 |
integration suite, then it's better to describe in the issue itself. |
| 973 |
|
| 974 |
- **Status: Needs Verification** |
| 975 |
|
| 976 |
This label is used to notify other users we need to verify the test case offered |
| 977 |
by the reporter and/or we need to include the test in our integration suite. |
| 978 |
|
| 979 |
- **Status: Not a Bug** |
| 980 |
|
| 981 |
It has been decided the issue reported is not a bug. |
| 982 |
|
| 983 |
- **Status: Won't Fix** |
| 984 |
|
| 985 |
It has been decided the issue will not be fixed. Sadly the Celery project does |
| 986 |
not have unlimited resources and sometimes this decision has to be made. |
| 987 |
Although, any external contributors are invited to help out even if an |
| 988 |
issue or PR is labeled as ``Status: Won't Fix``. |
| 989 |
|
| 990 |
- **Status: Works For Me** |
| 991 |
|
| 992 |
One or more Celery core team members have confirmed the issue reported works |
| 993 |
for them. |
| 994 |
|
| 995 |
.. _`different labels`: https://github.com/celery/celery/labels |
| 996 |
.. _`codecov`: https://codecov.io/gh/celery/celery |
| 997 |
|
| 998 |
.. _coding-style: |
| 999 |
|
| 1000 |
Coding Style |
| 1001 |
============ |
| 1002 |
|
| 1003 |
You should probably be able to pick up the coding style |
| 1004 |
from surrounding code, but it is a good idea to be aware of the |
| 1005 |
following conventions. |
| 1006 |
|
| 1007 |
* All Python code must follow the :pep:`8` guidelines. |
| 1008 |
|
| 1009 |
:pypi:`pep8` is a utility you can use to verify that your code |
| 1010 |
is following the conventions. |
| 1011 |
|
| 1012 |
* Docstrings must follow the :pep:`257` conventions, and use the following |
| 1013 |
style. |
| 1014 |
|
| 1015 |
Do this: |
| 1016 |
|
| 1017 |
.. code-block:: python |
| 1018 |
|
| 1019 |
def method(self, arg): |
| 1020 |
"""Short description. |
| 1021 |
|
| 1022 |
More details. |
| 1023 |
|
| 1024 |
""" |
| 1025 |
|
| 1026 |
or: |
| 1027 |
|
| 1028 |
.. code-block:: python |
| 1029 |
|
| 1030 |
def method(self, arg): |
| 1031 |
"""Short description.""" |
| 1032 |
|
| 1033 |
|
| 1034 |
but not this: |
| 1035 |
|
| 1036 |
.. code-block:: python |
| 1037 |
|
| 1038 |
def method(self, arg): |
| 1039 |
""" |
| 1040 |
Short description. |
| 1041 |
""" |
| 1042 |
|
| 1043 |
* Lines shouldn't exceed 78 columns. |
| 1044 |
|
| 1045 |
You can enforce this in :command:`vim` by setting the ``textwidth`` option: |
| 1046 |
|
| 1047 |
.. code-block:: vim |
| 1048 |
|
| 1049 |
set textwidth=78 |
| 1050 |
|
| 1051 |
If adhering to this limit makes the code less readable, you have one more |
| 1052 |
character to go on. This means 78 is a soft limit, and 79 is the hard |
| 1053 |
limit :) |
| 1054 |
|
| 1055 |
* Import order |
| 1056 |
|
| 1057 |
* Python standard library (`import xxx`) |
| 1058 |
* Python standard library (`from xxx import`) |
| 1059 |
* Third-party packages. |
| 1060 |
* Other modules from the current package. |
| 1061 |
|
| 1062 |
or in case of code using Django: |
| 1063 |
|
| 1064 |
* Python standard library (`import xxx`) |
| 1065 |
* Python standard library (`from xxx import`) |
| 1066 |
* Third-party packages. |
| 1067 |
* Django packages. |
| 1068 |
* Other modules from the current package. |
| 1069 |
|
| 1070 |
Within these sections the imports should be sorted by module name. |
| 1071 |
|
| 1072 |
Example: |
| 1073 |
|
| 1074 |
.. code-block:: python |
| 1075 |
|
| 1076 |
import threading |
| 1077 |
import time |
| 1078 |
|
| 1079 |
from collections import deque |
| 1080 |
from Queue import Queue, Empty |
| 1081 |
|
| 1082 |
from .platforms import Pidfile |
| 1083 |
from .utils.time import maybe_timedelta |
| 1084 |
|
| 1085 |
* Wild-card imports must not be used (`from xxx import *`). |
| 1086 |
|
| 1087 |
* For distributions where Python 2.5 is the oldest support version, |
| 1088 |
additional rules apply: |
| 1089 |
|
| 1090 |
* Absolute imports must be enabled at the top of every module:: |
| 1091 |
|
| 1092 |
from __future__ import absolute_import |
| 1093 |
|
| 1094 |
* If the module uses the :keyword:`with` statement and must be compatible |
| 1095 |
with Python 2.5 (celery isn't), then it must also enable that:: |
| 1096 |
|
| 1097 |
from __future__ import with_statement |
| 1098 |
|
| 1099 |
* Every future import must be on its own line, as older Python 2.5 |
| 1100 |
releases didn't support importing multiple features on the |
| 1101 |
same future import line:: |
| 1102 |
|
| 1103 |
# Good |
| 1104 |
from __future__ import absolute_import |
| 1105 |
from __future__ import with_statement |
| 1106 |
|
| 1107 |
# Bad |
| 1108 |
from __future__ import absolute_import, with_statement |
| 1109 |
|
| 1110 |
(Note that this rule doesn't apply if the package doesn't include |
| 1111 |
support for Python 2.5) |
| 1112 |
|
| 1113 |
|
| 1114 |
* Note that we use "new-style" relative imports when the distribution |
| 1115 |
doesn't support Python versions below 2.5 |
| 1116 |
|
| 1117 |
This requires Python 2.5 or later: |
| 1118 |
|
| 1119 |
.. code-block:: python |
| 1120 |
|
| 1121 |
from . import submodule |
| 1122 |
|
| 1123 |
|
| 1124 |
.. _feature-with-extras: |
| 1125 |
|
| 1126 |
Contributing features requiring additional libraries |
| 1127 |
==================================================== |
| 1128 |
|
| 1129 |
Some features like a new result backend may require additional libraries |
| 1130 |
that the user must install. |
| 1131 |
|
| 1132 |
We use setuptools `extra_requires` for this, and all new optional features |
| 1133 |
that require third-party libraries must be added. |
| 1134 |
|
| 1135 |
1) Add a new requirements file in `requirements/extras` |
| 1136 |
|
| 1137 |
For the Cassandra backend this is |
| 1138 |
:file:`requirements/extras/cassandra.txt`, and the file looks like this: |
| 1139 |
|
| 1140 |
.. code-block:: text |
| 1141 |
|
| 1142 |
pycassa |
| 1143 |
|
| 1144 |
These are pip requirement files, so you can have version specifiers and |
| 1145 |
multiple packages are separated by newline. A more complex example could |
| 1146 |
be: |
| 1147 |
|
| 1148 |
.. code-block:: text |
| 1149 |
|
| 1150 |
# pycassa 2.0 breaks Foo |
| 1151 |
pycassa>=1.0,<2.0 |
| 1152 |
thrift |
| 1153 |
|
| 1154 |
2) Modify ``setup.py`` |
| 1155 |
|
| 1156 |
After the requirements file is added, you need to add it as an option |
| 1157 |
to :file:`setup.py` in the ``extras_require`` section:: |
| 1158 |
|
| 1159 |
extra['extras_require'] = { |
| 1160 |
# ... |
| 1161 |
'cassandra': extras('cassandra.txt'), |
| 1162 |
} |
| 1163 |
|
| 1164 |
3) Document the new feature in :file:`docs/includes/installation.txt` |
| 1165 |
|
| 1166 |
You must add your feature to the list in the :ref:`bundles` section |
| 1167 |
of :file:`docs/includes/installation.txt`. |
| 1168 |
|
| 1169 |
After you've made changes to this file, you need to render |
| 1170 |
the distro :file:`README` file: |
| 1171 |
|
| 1172 |
.. code-block:: console |
| 1173 |
|
| 1174 |
$ pip install -U -r requirements/pkgutils.txt |
| 1175 |
$ make readme |
| 1176 |
|
| 1177 |
|
| 1178 |
That's all that needs to be done, but remember that if your feature |
| 1179 |
adds additional configuration options, then these needs to be documented |
| 1180 |
in :file:`docs/configuration.rst`. Also, all settings need to be added to the |
| 1181 |
:file:`celery/app/defaults.py` module. |
| 1182 |
|
| 1183 |
Result backends require a separate section in the :file:`docs/configuration.rst` |
| 1184 |
file. |
| 1185 |
|
| 1186 |
.. _contact_information: |
| 1187 |
|
| 1188 |
Contacts |
| 1189 |
======== |
| 1190 |
|
| 1191 |
This is a list of people that can be contacted for questions |
| 1192 |
regarding the official git repositories, PyPI packages |
| 1193 |
Read the Docs pages. |
| 1194 |
|
| 1195 |
If the issue isn't an emergency then it's better |
| 1196 |
to :ref:`report an issue <reporting-bugs>`. |
| 1197 |
|
| 1198 |
|
| 1199 |
Committers |
| 1200 |
---------- |
| 1201 |
|
| 1202 |
Ask Solem |
| 1203 |
~~~~~~~~~ |
| 1204 |
|
| 1205 |
:github: https://github.com/ask |
| 1206 |
:twitter: https://twitter.com/#!/asksol |
| 1207 |
|
| 1208 |
Asif Saif Uddin |
| 1209 |
~~~~~~~~~~~~~~~ |
| 1210 |
|
| 1211 |
:github: https://github.com/auvipy |
| 1212 |
:twitter: https://twitter.com/#!/auvipy |
| 1213 |
|
| 1214 |
Dmitry Malinovsky |
| 1215 |
~~~~~~~~~~~~~~~~~ |
| 1216 |
|
| 1217 |
:github: https://github.com/malinoff |
| 1218 |
:twitter: https://twitter.com/__malinoff__ |
| 1219 |
|
| 1220 |
Ionel Cristian Mărieș |
| 1221 |
~~~~~~~~~~~~~~~~~~~~~ |
| 1222 |
|
| 1223 |
:github: https://github.com/ionelmc |
| 1224 |
:twitter: https://twitter.com/ionelmc |
| 1225 |
|
| 1226 |
Mher Movsisyan |
| 1227 |
~~~~~~~~~~~~~~ |
| 1228 |
|
| 1229 |
:github: https://github.com/mher |
| 1230 |
:twitter: https://twitter.com/#!/movsm |
| 1231 |
|
| 1232 |
Omer Katz |
| 1233 |
~~~~~~~~~ |
| 1234 |
:github: https://github.com/thedrow |
| 1235 |
:twitter: https://twitter.com/the_drow |
| 1236 |
|
| 1237 |
Steeve Morin |
| 1238 |
~~~~~~~~~~~~ |
| 1239 |
|
| 1240 |
:github: https://github.com/steeve |
| 1241 |
:twitter: https://twitter.com/#!/steeve |
| 1242 |
|
| 1243 |
Josue Balandrano Coronel |
| 1244 |
~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 1245 |
|
| 1246 |
:github: https://github.com/xirdneh |
| 1247 |
:twitter: https://twitter.com/eusoj_xirdneh |
| 1248 |
|
| 1249 |
Tomer Nosrati |
| 1250 |
~~~~~~~~~~~~~ |
| 1251 |
:github: https://github.com/Nusnus |
| 1252 |
:twitter: https://x.com/tomer_nosrati |
| 1253 |
|
| 1254 |
Website |
| 1255 |
------- |
| 1256 |
|
| 1257 |
The Celery Project website is run and maintained by |
| 1258 |
|
| 1259 |
Mauro Rocco |
| 1260 |
~~~~~~~~~~~ |
| 1261 |
|
| 1262 |
:github: https://github.com/fireantology |
| 1263 |
:twitter: https://twitter.com/#!/fireantology |
| 1264 |
|
| 1265 |
with design by: |
| 1266 |
|
| 1267 |
Jan Henrik Helmers |
| 1268 |
~~~~~~~~~~~~~~~~~~ |
| 1269 |
|
| 1270 |
:web: http://www.helmersworks.com |
| 1271 |
:twitter: https://twitter.com/#!/helmers |
| 1272 |
|
| 1273 |
|
| 1274 |
.. _packages: |
| 1275 |
|
| 1276 |
Packages |
| 1277 |
======== |
| 1278 |
|
| 1279 |
``celery`` |
| 1280 |
---------- |
| 1281 |
|
| 1282 |
:git: https://github.com/celery/celery |
| 1283 |
:CI: https://travis-ci.org/#!/celery/celery |
| 1284 |
:Windows-CI: https://ci.appveyor.com/project/ask/celery |
| 1285 |
:PyPI: :pypi:`celery` |
| 1286 |
:docs: https://docs.celeryq.dev |
| 1287 |
|
| 1288 |
``kombu`` |
| 1289 |
--------- |
| 1290 |
|
| 1291 |
Messaging library. |
| 1292 |
|
| 1293 |
:git: https://github.com/celery/kombu |
| 1294 |
:CI: https://travis-ci.org/#!/celery/kombu |
| 1295 |
:Windows-CI: https://ci.appveyor.com/project/ask/kombu |
| 1296 |
:PyPI: :pypi:`kombu` |
| 1297 |
:docs: https://kombu.readthedocs.io |
| 1298 |
|
| 1299 |
``amqp`` |
| 1300 |
-------- |
| 1301 |
|
| 1302 |
Python AMQP 0.9.1 client. |
| 1303 |
|
| 1304 |
:git: https://github.com/celery/py-amqp |
| 1305 |
:CI: https://travis-ci.org/#!/celery/py-amqp |
| 1306 |
:Windows-CI: https://ci.appveyor.com/project/ask/py-amqp |
| 1307 |
:PyPI: :pypi:`amqp` |
| 1308 |
:docs: https://amqp.readthedocs.io |
| 1309 |
|
| 1310 |
``vine`` |
| 1311 |
-------- |
| 1312 |
|
| 1313 |
Promise/deferred implementation. |
| 1314 |
|
| 1315 |
:git: https://github.com/celery/vine/ |
| 1316 |
:CI: https://travis-ci.org/#!/celery/vine/ |
| 1317 |
:Windows-CI: https://ci.appveyor.com/project/ask/vine |
| 1318 |
:PyPI: :pypi:`vine` |
| 1319 |
:docs: https://vine.readthedocs.io |
| 1320 |
|
| 1321 |
``pytest-celery`` |
| 1322 |
----------------- |
| 1323 |
|
| 1324 |
Pytest plugin for Celery. |
| 1325 |
|
| 1326 |
:git: https://github.com/celery/pytest-celery |
| 1327 |
:PyPI: :pypi:`pytest-celery` |
| 1328 |
:docs: https://pytest-celery.readthedocs.io |
| 1329 |
|
| 1330 |
``billiard`` |
| 1331 |
------------ |
| 1332 |
|
| 1333 |
Fork of multiprocessing containing improvements |
| 1334 |
that'll eventually be merged into the Python stdlib. |
| 1335 |
|
| 1336 |
:git: https://github.com/celery/billiard |
| 1337 |
:CI: https://travis-ci.org/#!/celery/billiard/ |
| 1338 |
:Windows-CI: https://ci.appveyor.com/project/ask/billiard |
| 1339 |
:PyPI: :pypi:`billiard` |
| 1340 |
|
| 1341 |
``django-celery-beat`` |
| 1342 |
---------------------- |
| 1343 |
|
| 1344 |
Database-backed Periodic Tasks with admin interface using the Django ORM. |
| 1345 |
|
| 1346 |
:git: https://github.com/celery/django-celery-beat |
| 1347 |
:CI: https://travis-ci.org/#!/celery/django-celery-beat |
| 1348 |
:Windows-CI: https://ci.appveyor.com/project/ask/django-celery-beat |
| 1349 |
:PyPI: :pypi:`django-celery-beat` |
| 1350 |
|
| 1351 |
``django-celery-results`` |
| 1352 |
------------------------- |
| 1353 |
|
| 1354 |
Store task results in the Django ORM, or using the Django Cache Framework. |
| 1355 |
|
| 1356 |
:git: https://github.com/celery/django-celery-results |
| 1357 |
:CI: https://travis-ci.org/#!/celery/django-celery-results |
| 1358 |
:Windows-CI: https://ci.appveyor.com/project/ask/django-celery-results |
| 1359 |
:PyPI: :pypi:`django-celery-results` |
| 1360 |
|
| 1361 |
``librabbitmq`` |
| 1362 |
--------------- |
| 1363 |
|
| 1364 |
Very fast Python AMQP client written in C. |
| 1365 |
|
| 1366 |
:git: https://github.com/celery/librabbitmq |
| 1367 |
:PyPI: :pypi:`librabbitmq` |
| 1368 |
|
| 1369 |
``cell`` |
| 1370 |
-------- |
| 1371 |
|
| 1372 |
Actor library. |
| 1373 |
|
| 1374 |
:git: https://github.com/celery/cell |
| 1375 |
:PyPI: :pypi:`cell` |
| 1376 |
|
| 1377 |
``cyme`` |
| 1378 |
-------- |
| 1379 |
|
| 1380 |
Distributed Celery Instance manager. |
| 1381 |
|
| 1382 |
:git: https://github.com/celery/cyme |
| 1383 |
:PyPI: :pypi:`cyme` |
| 1384 |
:docs: https://cyme.readthedocs.io/ |
| 1385 |
|
| 1386 |
|
| 1387 |
Deprecated |
| 1388 |
---------- |
| 1389 |
|
| 1390 |
- ``django-celery`` |
| 1391 |
|
| 1392 |
:git: https://github.com/celery/django-celery |
| 1393 |
:PyPI: :pypi:`django-celery` |
| 1394 |
:docs: https://docs.celeryq.dev/en/latest/django |
| 1395 |
|
| 1396 |
- ``Flask-Celery`` |
| 1397 |
|
| 1398 |
:git: https://github.com/ask/Flask-Celery |
| 1399 |
:PyPI: :pypi:`Flask-Celery` |
| 1400 |
|
| 1401 |
- ``celerymon`` |
| 1402 |
|
| 1403 |
:git: https://github.com/celery/celerymon |
| 1404 |
:PyPI: :pypi:`celerymon` |
| 1405 |
|
| 1406 |
- ``carrot`` |
| 1407 |
|
| 1408 |
:git: https://github.com/ask/carrot |
| 1409 |
:PyPI: :pypi:`carrot` |
| 1410 |
|
| 1411 |
- ``ghettoq`` |
| 1412 |
|
| 1413 |
:git: https://github.com/ask/ghettoq |
| 1414 |
:PyPI: :pypi:`ghettoq` |
| 1415 |
|
| 1416 |
- ``kombu-sqlalchemy`` |
| 1417 |
|
| 1418 |
:git: https://github.com/ask/kombu-sqlalchemy |
| 1419 |
:PyPI: :pypi:`kombu-sqlalchemy` |
| 1420 |
|
| 1421 |
- ``django-kombu`` |
| 1422 |
|
| 1423 |
:git: https://github.com/ask/django-kombu |
| 1424 |
:PyPI: :pypi:`django-kombu` |
| 1425 |
|
| 1426 |
- ``pylibrabbitmq`` |
| 1427 |
|
| 1428 |
Old name for :pypi:`librabbitmq`. |
| 1429 |
|
| 1430 |
:git: :const:`None` |
| 1431 |
:PyPI: :pypi:`pylibrabbitmq` |
| 1432 |
|
| 1433 |
.. _release-procedure: |
| 1434 |
|
| 1435 |
|
| 1436 |
Release Procedure |
| 1437 |
================= |
| 1438 |
|
| 1439 |
Updating the version number |
| 1440 |
--------------------------- |
| 1441 |
|
| 1442 |
The version number must be updated in three places: |
| 1443 |
|
| 1444 |
* :file:`celery/__init__.py` |
| 1445 |
* :file:`docs/include/introduction.txt` |
| 1446 |
* :file:`README.rst` |
| 1447 |
|
| 1448 |
The changes to the previous files can be handled with the [`bumpversion` command line tool] |
| 1449 |
(https://pypi.org/project/bumpversion/). The corresponding configuration lives in |
| 1450 |
:file:`.bumpversion.cfg`. To do the necessary changes, run: |
| 1451 |
|
| 1452 |
.. code-block:: console |
| 1453 |
|
| 1454 |
$ bumpversion |
| 1455 |
|
| 1456 |
After you have changed these files, you must render |
| 1457 |
the :file:`README` files. There's a script to convert sphinx syntax |
| 1458 |
to generic reStructured Text syntax, and the make target `readme` |
| 1459 |
does this for you: |
| 1460 |
|
| 1461 |
.. code-block:: console |
| 1462 |
|
| 1463 |
$ make readme |
| 1464 |
|
| 1465 |
Now commit the changes: |
| 1466 |
|
| 1467 |
.. code-block:: console |
| 1468 |
|
| 1469 |
$ git commit -a -m "Bumps version to X.Y.Z" |
| 1470 |
|
| 1471 |
and make a new version tag: |
| 1472 |
|
| 1473 |
.. code-block:: console |
| 1474 |
|
| 1475 |
$ git tag vX.Y.Z |
| 1476 |
$ git push --tags |
| 1477 |
|
| 1478 |
Releasing |
| 1479 |
--------- |
| 1480 |
|
| 1481 |
Commands to make a new public stable release: |
| 1482 |
|
| 1483 |
.. code-block:: console |
| 1484 |
|
| 1485 |
$ make distcheck # checks pep8, autodoc index, runs tests and more |
| 1486 |
$ make dist # NOTE: Runs git clean -xdf and removes files not in the repo. |
| 1487 |
$ python setup.py sdist upload --sign --identity='Celery Security Team' |
| 1488 |
$ python setup.py bdist_wheel upload --sign --identity='Celery Security Team' |
| 1489 |
|
| 1490 |
If this is a new release series then you also need to do the |
| 1491 |
following: |
| 1492 |
|
| 1493 |
* Go to the Read The Docs management interface at: |
| 1494 |
https://readthedocs.org/projects/celery/?fromdocs=celery |
| 1495 |
|
| 1496 |
* Enter "Edit project" |
| 1497 |
|
| 1498 |
Change default branch to the branch of this series, for example, use |
| 1499 |
the ``2.4`` branch for the 2.4 series. |
| 1500 |
|
| 1501 |
* Also add the previous version under the "versions" tab. |
| 1502 |
|
| 1503 |
.. _`mailing-list`: https://groups.google.com/group/celery-users |
| 1504 |
|
| 1505 |
.. _`irc-channel`: https://docs.celeryq.dev/en/latest/getting-started/resources.html#irc |
| 1506 |
|
| 1507 |
.. _`internals-guide`: https://docs.celeryq.dev/en/latest/internals/guide.html |
| 1508 |
|
| 1509 |
.. _`bundles`: https://docs.celeryq.dev/en/latest/getting-started/introduction.html#bundles |
| 1510 |
|
| 1511 |
.. _`report an issue`: https://docs.celeryq.dev/en/latest/contributing.html#reporting-bugs |