Skip to content

Commit

Permalink
SG-17710: update task dependencies section (#232)
Browse files Browse the repository at this point in the history
* SG-17710: update task dependencies section

* SG-17710: fixes based on review comments

Co-authored-by: Vladimir Gusarov <[email protected]>
  • Loading branch information
vovagusarov and vovagusarov authored Jul 7, 2020
1 parent 0e15d8b commit b3034c1
Showing 1 changed file with 37 additions and 3 deletions.
40 changes: 37 additions & 3 deletions docs/cookbook/tasks/task_dependencies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,16 @@ Create A Dependency

Tasks each have an ``upstream_tasks`` field and a ``downstream_tasks`` field. Each field is a
list ``[]`` type and can contain zero, one, or multiple Task entity dictionaries representing the
dependent Tasks. Here is how to create a dependency between our "Layout" and "Anim" Tasks::
dependent Tasks.
There are four dependency types from which you can choose: ``finish-to-start-next-day``, ``start-to-finish-next-day``, ``start-to-start``, ``finish-to-finish``.
If no dependency type is provided the default ``finish-to-start-next-day`` will be used.
Here is how to create a dependency between our "Layout" and "Anm" Tasks::

# make 'Layout' and upstream Task to 'Anm'. (aka, make 'Anm' dependent on 'Layout')
result = sg.update('Task', 557, {'upstream_tasks':[{'type':'Task','id':556}]})
# make 'Layout' an upstream Task to 'Anm'. (aka, make 'Anm' dependent on 'Layout') with finish-to-start-next-day dependency type
data = {
'upstream_tasks':[{'type':'Task','id':556, 'dependency_type': 'finish-to-start-next-day'}]
}
result = sg.update('Task', 557, data)

Returns::

Expand All @@ -78,6 +84,34 @@ Returns::

This will also automatically update the `downstream_tasks` field on 'Layout' to include the 'Anm' Task.

***********************
Query Task Dependencies
***********************

Task Dependencies each have a ``dependent_task_id`` and a ``task_id`` fields.
They correspond to ``upstream_task`` and ``downstream_task`` ids of the dependency accordingly.
Here is how to get a TaskDependency using a ``dependent_task_id`` and a ``task_id`` fields::

filters = [["dependent_task_id", "is", 72], ["task_id", "is", 75]]
result = sg.find_one('TaskDependency', filters)

Returns::

{'type': 'TaskDependency', 'id': 128}

****************************
Updating the Dependency type
****************************

When updating the dependency type for the existing dependencies,
update the ``dependency_type`` field of the TaskDependency directly::

result = sg.update('TaskDependency', 128, {'dependency_type': 'start-to-start'})

Returns::

{'dependency_type': 'start-to-start', 'type': 'TaskDependency', 'id': 128}

**********************************
Query Tasks with Dependency Fields
**********************************
Expand Down

0 comments on commit b3034c1

Please sign in to comment.