Jump to content

Asset with parent set to a Task


kristin

Recommended Posts

Hi there,

I see that on Task objects, there's an 'assets' attribute: Task['assets'], however when I try to set a Task as an Asset's parent, I get: 

ServerError: Server reported error: IntegrityError(Invalid parent_type <ObjectType('%s')> for Asset)

We want to have Asset-AssetVersion collections associated with a Task. The AssetVersion being linked to the Task isn't enough as we need to upversion based on the Task association. As is, this will cause an error on the version number uniqueness:

# Shorthand example
>>> asset
<dynamic ftrack Asset object 140628273802064>
>>> print([(version['task']['name'], version['version']) for version in asset['versions']])
[('light', 1001)]
# Create another version 1001 attached to a different task
>>> task = session.query('Task where name = "otherLightTask"').one()
>>> version = session.create('AssetVersion', {'asset': asset, 'version': 1001, 'task': task})
>>> session.commit()
ServerError: Server reported error: IntegrityError((_mysql_exceptions.IntegrityError) (1062, "Duplicate entry '811b6f19-96f5-4620-9b00-164f77875ca9-1001' for key 'asset_version_assetid_key'"))

We've gotten around this by incorporating the Task name in to the Asset name, but it has it's downsides - needing to update the Asset name if the Task is renamed for one. The ability to have a Task be the Asset's parent would provide the association we need.

Is the Task's 'assets' attribute supposed to be able to contain child Assets? If not currently, is that planned for the future?

Link to comment
Share on other sites

Searched through the help docs and release notes and found the below.

But still wanting clarification on the attribute 'assets' that exists on Tasks - does that have a use?

 

Quote

https://help.ftrack.com/en/articles/1040441-publishing

The asset entity should be attached to a context. A context is either a project or an object such as a shot, asset build or a folder.

If a task is representing the work that should be published, the task cannot be used as the parent of the asset. Instead the parent of the task should be used as the parent of the asset. The task itself should be associated directly with the version.

 

Quote

 

3.5.2

12 May 2017

  • CHANGED API, Validation Creating an asset under leaf context nodes such as milestones or a tasks now fail as expected.
    See also Asset parent valdiation.

Link to comment
Share on other sites

  • 2 weeks later...

I'm going to start by responding to everything in order, then circle back to ask some questions about your workflow.

On 5/28/2021 at 10:10 AM, kristin said:

ServerError: Server reported error: IntegrityError(Invalid parent_type <ObjectType('%s')> for Asset)

 

Formatting issues aside (it should probably say "Task" somewhere in there), what that's communicating is that Asset parents are always a non-Task Context object. The design is that Tasks (or TypedContexts) which are siblings can or do represent different sorts of work on the same group of Assets.

As you found, an Asset cannot have multiple AssetVersions with the same version numbers. Asset uniqueness is determined by context_id, name and type_id, so you can effectively have an Asset per-Task, as long as you have different types for each one. Now, certain tools (may) interpret Asset types as meaningful, so be prepared to run into issues if you choose to go down that road.

On 5/28/2021 at 10:10 AM, kristin said:

Is the Task's 'assets' attribute supposed to be able to contain child Assets? If not currently, is that planned for the future?

We're making use of https://docs.sqlalchemy.org/en/14/orm/backref.html to populate the "assets" attribute. It's keyed off of the Asset's context(_id) attr, so in the current implementation, Tasks will never have that attribute populated, but any other Context may. The idiomatic ftrack way of accessing roughly the same thing would be task['parent']['assets'] or querying for AssetVersions which have the task attribute set to the Task in question.

 

Back to workflow questions: why the need to organize and version in this way? If the tasks aren't sharing Assets, could they then be put under different parents (e.g. Folders)?

Link to comment
Share on other sites

  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...