From 11d881b33488c9c96a10dc454f52de4bc2b10b91 Mon Sep 17 00:00:00 2001 From: Vladimir Gusarov Date: Wed, 17 Jun 2020 15:29:31 -0400 Subject: [PATCH 1/2] SG-17710: update task dependencies section --- docs/cookbook/tasks/task_dependencies.rst | 40 +++++++++++++++++++++-- 1 file changed, 37 insertions(+), 3 deletions(-) diff --git a/docs/cookbook/tasks/task_dependencies.rst b/docs/cookbook/tasks/task_dependencies.rst index fde003783..d26ce2075 100644 --- a/docs/cookbook/tasks/task_dependencies.rst +++ b/docs/cookbook/tasks/task_dependencies.rst @@ -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 provided the default ``finish-to-start-next-day`` would 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:: @@ -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 dependency type for the existing dependencies, +update a ``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 ********************************** From 0d9d13c601bacd598917d2f8b39f7c7e9487e541 Mon Sep 17 00:00:00 2001 From: Vladimir Gusarov Date: Thu, 25 Jun 2020 10:28:41 -0400 Subject: [PATCH 2/2] SG-17710: fixes based on review comments --- docs/cookbook/tasks/task_dependencies.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/cookbook/tasks/task_dependencies.rst b/docs/cookbook/tasks/task_dependencies.rst index d26ce2075..0b63d3255 100644 --- a/docs/cookbook/tasks/task_dependencies.rst +++ b/docs/cookbook/tasks/task_dependencies.rst @@ -67,7 +67,7 @@ Tasks each have an ``upstream_tasks`` field and a ``downstream_tasks`` field. Ea list ``[]`` type and can contain zero, one, or multiple Task entity dictionaries representing the 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 provided the default ``finish-to-start-next-day`` would be used. +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' an upstream Task to 'Anm'. (aka, make 'Anm' dependent on 'Layout') with finish-to-start-next-day dependency type @@ -103,8 +103,8 @@ Returns:: Updating the Dependency type **************************** -When updating dependency type for the existing dependencies, -update a ``dependency_type`` field of the TaskDependency directly:: +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'})