Skip to content

SG-17710: update task dependencies section #232

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

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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