Find latest version for a given pipeline step

Hi all,

I am using this python snippet to get the latest version for a given shot id:

    filters = [['entity', 'is', {'type':'Shot', 'id':shotID}]]
    columns = ['code', 'sg_path_to_frames', 'sg_path_to_frames_assembly', 'sg_first_frame', 'sg_last_frame', 'sg_task']
    order = [{'field_name':'created_at','direction':'desc'}]
    version = self.CONNECT.find_one('Version', filters, columns, order)

I’d like to add a filter, e.g. to only return the latest comp version, i.e. a version linked to a comp task of the pipeline step “comp”.
I tried this filter as a test:

filters = [['entity', 'is', {'type':'Shot', 'id':shotID}], ['sg_task.Task.step.name', 'is', 'Comp']]

but the step.name causes this error:

shotgun_api3.shotgun.Fault: API read() Task.step expected [Hash,
HashWithIndifferentAccess,
ActionController::ParamsHashWithIndifferentAccess,
NilClass] data type(s) but got String:
"Comp"

I’m not sure why the data type for a pipeline step name is not a string, what am I missing?

Cheers,
frank

1 Like

Looks like this is the ticket:

filters = [['entity', 'is', {'type':'Shot', 'id':shotID}], ['sg_task.Task.step', 'name_contains', 'Comp']]
4 Likes

Hi @frank,

There is another way to filter.

filters = [['entity', 'is', {'type':'Shot', 'id':shotID}], ['sg_task.Task.step.Step.code', 'is', 'Comp']]

Cheers

Loney

4 Likes

Ah, great, that was what I was aiming for originally. Looks like I just forgot the “Step” entity in the deep query.
Thanks @jing.liu, I will use your solution as it seems more straight forward to me.

Cheers,
frank

3 Likes

How does one know how deep this is
sg_task.Task.step.Step.code.

Like code within Step within step within Task in sg_task ?