Parcourir la source

Removes igroup/ichord, use group(.si()) instead.

Ask Solem il y a 12 ans
Parent
commit
cac77d6e8b
6 fichiers modifiés avec 33 ajouts et 21 suppressions
  1. 2 2
      celery/__init__.py
  2. 2 4
      celery/bin/celery.py
  3. 0 3
      celery/canvas.py
  4. 4 4
      celery/result.py
  5. 0 8
      docs/reference/celery.rst
  6. 25 0
      docs/userguide/canvas.rst

+ 2 - 2
celery/__init__.py

@@ -26,8 +26,8 @@ old_module, new_module = recreate_module(__name__,  # pragma: no cover
         'celery.app':      ['Celery', 'bugreport', 'shared_task'],
         'celery.app.task': ['Task'],
         'celery._state':   ['current_app', 'current_task'],
-        'celery.canvas':   ['chain', 'chord', 'ichord', 'chunks', 'group',
-                            'igroup', 'subtask', 'xmap', 'xstarmap'],
+        'celery.canvas':   ['chain', 'chord', 'chunks', 'group',
+                            'subtask', 'xmap', 'xstarmap'],
         'celery.utils':    ['uuid'],
     },
     direct={'task': 'celery.task'},

+ 2 - 4
celery/bin/celery.py

@@ -684,8 +684,8 @@ class shell(Command):  # pragma: no cover
     The following symbols will be added to the main globals:
 
         - celery:  the current application.
-        - chord, ichord, group, igroup, chain,
-          chunks, xmap, xstarmap subtask, Task
+        - chord, group, chain, chunks,
+          xmap, xstarmap subtask, Task
         - all registered tasks.
 
     Example Session::
@@ -729,9 +729,7 @@ class shell(Command):  # pragma: no cover
         self.locals = {'celery': self.app,
                        'Task': celery.Task,
                        'chord': celery.chord,
-                       'ichord': celery.ichord,
                        'group': celery.group,
-                       'igroup': celery.igroup,
                        'chain': celery.chain,
                        'chunks': celery.chunks,
                        'xmap': celery.xmap,

+ 0 - 3
celery/canvas.py

@@ -11,7 +11,6 @@
 """
 from __future__ import absolute_import
 
-from functools import partial
 from operator import itemgetter
 from itertools import chain as _chain
 
@@ -326,7 +325,6 @@ class group(Signature):
     def __repr__(self):
         return repr(self.tasks)
 Signature.register_type(group)
-igroup = partial(group, immutable=True)
 
 
 class chord(Signature):
@@ -383,7 +381,6 @@ class chord(Signature):
     def body(self):
         return self.kwargs.get('body')
 Signature.register_type(chord)
-ichord = partial(chord, immutable=True)
 
 
 def subtask(varies, *args, **kwargs):

+ 4 - 4
celery/result.py

@@ -535,8 +535,8 @@ class ResultSet(ResultBase):
         return NotImplemented
 
     def __repr__(self):
-        return '<%s: %r>' % (self.__class__.__name__,
-                             [r.id for r in self.results])
+        return '<%s: [%s]>' % (self.__class__.__name__,
+                               ', '.join(r.id for r in self.results))
 
     @property
     def subtasks(self):
@@ -599,8 +599,8 @@ class GroupResult(ResultSet):
         return NotImplemented
 
     def __repr__(self):
-        return '<%s: %s %r>' % (self.__class__.__name__, self.id,
-                                [r.id for r in self.results])
+        return '<%s: %s [%s]>' % (self.__class__.__name__, self.id,
+                                  ', '.join(r.id for r in self.results))
 
     def serializable(self):
         return self.id, [r.serializable() for r in self.results]

+ 0 - 8
docs/reference/celery.rst

@@ -259,10 +259,6 @@ Grouping Tasks
 
     The ``apply_async`` method returns :class:`~@GroupResult`.
 
-.. class:: igroup(task1[, task2[, task3[,... taskN]]])
-
-    Immutable :class:`group` (i.e. will not modify arguments).
-
 .. class:: chain(task1[, task2[, task3[,... taskN]]])
 
     Chains tasks together, so that each tasks follows each other
@@ -304,10 +300,6 @@ Grouping Tasks
     The body is applied with the return values of all the header
     tasks as a list.
 
-.. class:: ichord(header[, body])
-
-    Immutable :class:`chord` (i.e. will not modify arguments).
-
 .. class:: subtask(task=None, args=(), kwargs={}, options={})
 
     Describes the arguments and execution options for a single task invocation.

+ 25 - 0
docs/userguide/canvas.rst

@@ -241,6 +241,8 @@ Here's some examples::
 
     .. code-block:: python
 
+        >>> from celery import chain
+
         # 2 + 2 + 4 + 8
         >>> res = chain(add.s(2, 2), add.s(4), add.s(8))()
         >>> res.get()
@@ -282,6 +284,7 @@ Here's some examples::
 
     We can easily create a group of tasks to execute in parallel::
 
+        >>> from celery import group
         >>> res = group(add.s(i, i) for i in xrange(10))()
         >>> res.get(timeout=1)
         [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
@@ -313,6 +316,7 @@ Here's some examples::
     all of the tasks in a group has finished executing, which is often
     required for algorithms that aren't embarrassingly parallel::
 
+        >>> from celery import chord
         >>> res = chord((add.s(i, i) for i in xrange(10)), xsum.s())()
         >>> res.get()
         90
@@ -370,6 +374,27 @@ Here's some examples::
         ...                         email='art@vandelay.com')
 
 
+    If you don't want to forward arguments to the group then
+    you can make the subtasks in the group immutable::
+
+        >>> res = (add.s(4, 4) | group(add.si(i, i) for i in xrange(10)))()
+        >>> res.get()
+        <GroupResult: de44df8c-821d-4c84-9a6a-44769c738f98 [
+            bc01831b-9486-4e51-b046-480d7c9b78de,
+            2650a1b8-32bf-4771-a645-b0a35dcc791b,
+            dcbee2a5-e92d-4b03-b6eb-7aec60fd30cf,
+            59f92e0a-23ea-41ce-9fad-8645a0e7759c,
+            26e1e707-eccf-4bf4-bbd8-1e1729c3cce3,
+            2d10a5f4-37f0-41b2-96ac-a973b1df024d,
+            e13d3bdb-7ae3-4101-81a4-6f17ee21df2d,
+            104b2be0-7b75-44eb-ac8e-f9220bdfa140,
+            c5c551a5-0386-4973-aa37-b65cbeb2624b,
+            83f72d71-4b71-428e-b604-6f16599a9f37]>
+
+        >>> res.parent.get()
+        8
+
+
 .. _canvas-chain:
 
 Chains