Adding Component Error
2 2

6 posts in this topic

Hi

I am trying to register a component, and I am getting the following error:

Failed to register components with location <Location("ftrack.server", 3a372bde-05bc-11e4-8908-20c9d081909b)> due to error:
    Server reported error: IntegrityError((IntegrityError) (1062, "Duplicate entry 'ee47fa1c-13d3-11e3-93e0-f23c91dfaa16-scene_01_025_Compositing-03' for key 'asset_Asset.typeid_key'") 'INSERT INTO asset (id, name, context_id, taskid, type_id) VALUES (%s, %s, %s, %s, %s)' (u'fac36b79-29c7-42e4-8933-afa820bf0754', 'scene_01_025_Compositing', '0311ec39-7af3-48e1-8509-c8b3b0916c86', None, 'ee47fa1c-13d3-11e3-93e0-f23c91dfaa16'))
    Transferred component data that may require cleanup: [(<dynamic ftrack FileComponent object 1850849152>, 'f6ecce05-3213-4f40-b1f1-e9b31b3b10c9')]

 

The trouble is I'm not quite sure what exactly, the error is telling me.

It seems that there is a duplication of data, where that is not allowed.

The entry seems to be the combination of the component name and its potential ID, being added to the key asset_Asset.typeid_key,  which confuses me, because I thought components were added to the AssetVersion and not the asset directly.

Can somebody help explain what this error is telling me.

thanks

Phil

Share this post


Link to post
Share on other sites

After running tests.

I think I have my answer. I don't think it has anything to do with the components at all.

I think whats happening is that I'm creating an asset called say "renders" and I'm then attaching an assetVersion (called "task1AssetVersion") to that in task 1.

Then when publishing to task 2 I'm publishing to the same "renders" asset but I have named the assetVersion differently (called "task2AssetVersion"), however if its the same version as the assetversion "task1AssetVersion" then it treats it as an duplicate entry.

So it seems the name on an assetversion is irrelevant, in making it unique, and you should have only one set of assetVersions per asset. My mistake is reusing the same asset in task2 if I want to start the versioning from 1 again.

Which I guess leads me to a more designed base problem\decision. Should I share the same asset across all my tasks on the shot, and accept my version numbers go up across tasks not per task, or do I produce an asset per task. The down side with the last one is that I suppose each tasks assets are unrelated to the previous tasks, and Its up to me to make the connection. It also seems by design in ftrack, that the assets are designed to be shared across tasks, and that's the way it should be done.

Does this seem right?

Thanks

Phil

Share this post


Link to post
Share on other sites

Hi Philip,

When you create a component with e.g. session.create_component there is an automatic commit issues on the session. What I read on your text looks more like the asset (name + type + parent) uniqueness restriction. I.e. you can only have one asset on a e.g. Shot with a name + type combination. 

To solve your issue I would try and query for that asset before creating it.

Share this post


Link to post
Share on other sites
4 minutes ago, Philip said:

Which I guess leads me to a more designed base problem\decision. Should I share the same asset across all my tasks on the shot, and accept my version numbers go up across tasks not per task, or do I produce an asset per task. The down side with the last one is that I suppose each tasks assets are unrelated to the previous tasks, and Its up to me to make the connection. It also seems by design in ftrack, that the assets are designed to be shared across tasks, and that's the way it should be done.

I would recommend creating an asset for each task if they yield different outputs. The idea being that when I use the Asset manager in one of our integrations you should be able to just update to the latest version of an asset, and get the an improved version of the same "content".

Share this post


Link to post
Share on other sites

Hi Mattias

task = session.get("Task","14fc7f1d-8927-44aa-9e30-526d83956fb1")
assetType = session.query('AssetType where short is "comp"').first()
assetName = "renders"
publishFile = r"c:\\apath\\01_025_Compositing_v003.nk"
location = session.query('Location where name is "ftrack.unmanaged"').first()

asset = session.query('select versions from Asset where name is "{0}"'.format(assetName)).first()
if asset is None:
    data = {
        'parent': task['parent'],
        'name': assetName,
        'type': assetType,
    }
    asset = session.create("Asset", data)

data = {
    "task": task,
    "asset": asset,
    "name": assetName + task['name'],
    "version": 4,
    "comment": "Testing API",
}
assetVersion = session.create("AssetVersion", data)

assetVersion.create_component(publishFile,
                              data={'name':assetName},
                              location=location)
session.commit()

There is my code, I do check for the existence of the asset before publish. But I do see a mistake in my query, as I'm checking across the whole of ftrack and not specific to my shot.

Quote

I would recommend creating an asset for each task if they yield different outputs.

Thank you, I will make the asset unique to the task

Share this post


Link to post
Share on other sites

Thank you, I think that's helped clear up things in my mind about how assets and asset version should be treated.

I think one of the problems I had was understanding the rules of what should be unique. I didn't expect the name, type, parent to be unique fields on an asset, which is fine and makes sense, but it felt like trial and error and then trying to understand the response to find out what the rules were.

For an entity seeing what fields must be unique?

Share this post


Link to post
Share on other sites

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
2 2