Skip to content

Commit b3034c1

Browse files
authored
SG-17710: update task dependencies section (#232)
* SG-17710: update task dependencies section * SG-17710: fixes based on review comments Co-authored-by: Vladimir Gusarov <vladimir.gusarov@autodesk.com>
1 parent 0e15d8b commit b3034c1

File tree

1 file changed

+37
-3
lines changed

1 file changed

+37
-3
lines changed

docs/cookbook/tasks/task_dependencies.rst

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,16 @@ Create A Dependency
6565

6666
Tasks each have an ``upstream_tasks`` field and a ``downstream_tasks`` field. Each field is a
6767
list ``[]`` type and can contain zero, one, or multiple Task entity dictionaries representing the
68-
dependent Tasks. Here is how to create a dependency between our "Layout" and "Anim" Tasks::
68+
dependent Tasks.
69+
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``.
70+
If no dependency type is provided the default ``finish-to-start-next-day`` will be used.
71+
Here is how to create a dependency between our "Layout" and "Anm" Tasks::
6972

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

7379
Returns::
7480

@@ -78,6 +84,34 @@ Returns::
7884

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

87+
***********************
88+
Query Task Dependencies
89+
***********************
90+
91+
Task Dependencies each have a ``dependent_task_id`` and a ``task_id`` fields.
92+
They correspond to ``upstream_task`` and ``downstream_task`` ids of the dependency accordingly.
93+
Here is how to get a TaskDependency using a ``dependent_task_id`` and a ``task_id`` fields::
94+
95+
filters = [["dependent_task_id", "is", 72], ["task_id", "is", 75]]
96+
result = sg.find_one('TaskDependency', filters)
97+
98+
Returns::
99+
100+
{'type': 'TaskDependency', 'id': 128}
101+
102+
****************************
103+
Updating the Dependency type
104+
****************************
105+
106+
When updating the dependency type for the existing dependencies,
107+
update the ``dependency_type`` field of the TaskDependency directly::
108+
109+
result = sg.update('TaskDependency', 128, {'dependency_type': 'start-to-start'})
110+
111+
Returns::
112+
113+
{'dependency_type': 'start-to-start', 'type': 'TaskDependency', 'id': 128}
114+
81115
**********************************
82116
Query Tasks with Dependency Fields
83117
**********************************

0 commit comments

Comments
 (0)