How can I offset dependencies on the gantt without having to pin the task?

Gantt Alt drag

Tasks, Task Dependencies, and the Gantt are great tools for visualizing and organizing a schedule within Shotgun. Sometimes it’s useful to set up offsets between dependencies, as maybe the dependent Task doesn’t need to start exactly the day after the upstream Task is finished. Just clicking and dragging a dependent Task in the Gantt will cause it to become pinned. Using our Alt key, we can move Tasks further down the timeline and still have dependencies automatically adjust all other tasks in the chain, without pinning the Task in place on the Gantt.

03_gantt

4 Likes

It’d be great if this Offset value was a visible field on Task to view/set

5 Likes

@schicky, thanks for joining the conversation!

The offset field is actually on the TaskDependency entity (instead of Task) which isn’t visible in Shotgun since it’s buried a little deeper. However, it is possible to populate an offset via the API. I’ll pass along your feedback to our product team, thanks for sharing :slightly_smiling_face:

Hi @shaynad,

Using our Alt key, we can move Tasks further down the timeline and still have dependencies automatically adjust all other tasks in the chain, without pinning the Task in place on the Gantt.

We use this but It is buggy, sometimes it takes you several attempts in order to get it right, because when you release the mouse button, sometimes the Task doesn’t stay where you left it and shifts to another date, really frustrating.

However, it is possible to populate an offset via the API.

Cool, where can we find the Docs for doing the previous?

2 Likes

Hey @doc :wave: !
Sorry you’re getting some buggy behavior. I haven’t seen any bugs related to this yet. When you experience this, is your browser at 100% zoom? We’ve often seen reports on issues with gantt functionality when the browser isn’t at 100%, so that would be the first thing to check. Then, if you need to adjust the zoom, just do that with the provided scaler on the gantt (upper right)21%20AM . You’ll also want to make sure you are using a recommended browser. Can you see if that may have caused that issue?

I’ll keep you posted about the API docs!

1 Like

Hey @doc ,

Here’s a quick Python API snippet that show how you can change offset values in task dependencies. How you get the tasks is obviously up to you but you should get the gist. There’s an extra schema call in there just for demo purposes.

>>> t1 = sg.find_one('Task', [['id', 'is', 5785]])
>>> t2 = sg.find_one('Task', [['id', 'is', 5786]])
>>> sg.schema_field_read('TaskDependency').keys()
['task', 'task_id', 'dependent_task', 'offset_days', 'cached_display_name', 'dependent_task_id', 'id']
>>> dep = sg.find_one('TaskDependency', [['dependent_task', 'is', t1], ['task', 'is', t2]])
>>> sg.update('TaskDependency', dep['id'], {'offset_days':2})
{'type': 'TaskDependency', 'id': 70, 'offset_days': 2}

This will create an offset of two days between your tasks. This offset will render in the gantt and when you move the first task, the second one will follow with the specified offset.

You can also specify a negative offset in order for the second task to start before the first is finished.

6 Likes

Thanks @shaynad,
Yes, I’ve also noticed that SG doesn’t behave well when the browser is not at 100% zoom, but even taking care of that, sometimes offsetting the Tasks does not behave as expected.
We’ll take a look at the recommended browsers matrix, perhaps the version of Google Chrome we’re using on CentOS 7 is not helping.

Cheers,
Doc

3 Likes

Woohoo, great to know @bouchep, big thanks

4 Likes

Hi @bouchep, is there a way of accessing this Task Dependency field via the REST API
(both to read and write)?

Thanks

1 Like

I second this. It would definitely be very helpful to have this value exposed directly in the web interface.

2 Likes

Hi @adiego1, welcome to the community!

The REST API and the Python API are functionally equivalent so everything described here should be possible.

The REST API has a schema endpoint which allows you to see which entities are accessible via REST. TaskDependency is definitely one of those accessible entities.

To read a TaskDependency you could do:

r = requests.get(SITE_URL + '/api/v1/entity/task_dependencies/70', headers=auth_header)

Here are the docs to read a single record. Otherwise, you could find your tasks and then search for the task dependency linking them.

And then, to update, you could do:

params = {
    'offset_days': 2
}
r = requests.put(SITE_URL + '/api/v1/entity/task_dependencies/70', headers=auth_header, data=json.dumps(params))

Here are the docs to update a single record.

Obviously, this code assumes you’re using the Requests library to do your HTTP calls to the REST API.

I sure hope this helps you out!

3 Likes

Thanks @bouchep. I did find the TaskDependency in the Schema and I’m able to read and write to it. The strange thing is that I cannot seem to get Task Dependency object info when getting a Task data, even when I specifically ask for all fields (?fields=*) or explicity ask for Task Dependency field info (task_dependency.TaksDependency.id for example. Does this relationship to the Tasks entity work in a different way than usual? Thanks!

1 Like