Sg.create() ...path?

Hi guys,
I am trying to use sg.create() instead of sgtk.util.register_publish().
I have a small problem with a path. I am not sure how to add it to the dictionary for sg.create().

an example:

path = '/a/b/c.ma'
sg.create(
  {"path":{"local_path_windows": path}
  ...etc...}
)

Does anyone know what should be there?

Thanks

4 Likes

Hi @lukasb,

Here is the Python API documentation for the create method.

First off, I’m noticing that you’re missing the entity type in your create() call. The entity type is the first argument to the method.

Given that you’re trying to set the path value and that you mentioned register_publish(), I’ll go ahead and assume that you want to create a PublishedFile record. To do this, you’d need a call that looks like this:

data = {
  'code': 'someFile',
  'path': {
    'link_type': 'local',
    'local_path': '/a/b/c.ma'
  },
  'project': {'type':'Project', 'id':project_id}
}
sg.create('PublishedFile', data)

Let me know if this sets you down the right path.

5 Likes