Getting base paths for shows, shots and assets

The HTTP & Python API
Post Reply
User avatar
pablo
Posts: 10
Joined: September 3rd, 2020, 7:14 pm

Getting base paths for shows, shots and assets

Post by pablo »

Hello.
Im trying to use get_bases() to retrieve the base path for a show, a shot or an asset.
Im getting the next error:

Code: Select all

UnboundLocalError: local variable 'basenameDict' referenced before assignment
Then looking at the code of the function seems that you hav to provide a task name or ID to retrieve a path.
Im calling to the function with this:

Code: Select all

showbasepaths = nimAPI.get_bases( showID=showid )
Im probably dont undestanding the porpouse of this function but doesnt make too much sense to force to provide a task when what I need, for instance, is the base path for a shot.
I have modified the function in the nim api to just make this call:

Code: Select all

basenameDict=get( {'q': 'getBasenames', 'ID': str(ID), 'class': _type} )
But I got an empty list, so yes it seems it needs a task to return a path.
If I'm not using the correct fucntion in the API, what is the correct way to retrieve the path to a shot/asset?

Thanks!

User avatar
andrew
Site Admin
Posts: 308
Joined: June 24th, 2014, 8:10 am

Re: Getting base paths for shows, shots and assets

Post by andrew »

Hi Pablo,

The function for get_bases() is actually used to return all file basenames for a given task type. This function does not return paths.

To return the paths for a given job use the get_paths() function:
https://nim-labs.com/docs/NIM/html/api_ ... #get-paths

The return value for a shot will look similar to the following:

Code: Select all

{"root":"18080_DEMO\/ESCAPE\/SHOTS\/ESC_010","plates":"18080_DEMO\/ESCAPE\/PLATES\/ESC_010","comps":"18080_DEMO\/ESCAPE\/IMG\/ESC_010\/COMP","renders":"18080_DEMO\/ESCAPE\/IMG\/ESC_010\/RENDER"}
This result appended with the appropriate server prefix from get_jobServers() will provide the full path.
https://nim-labs.com/docs/NIM/html/api_ ... ob-servers


On a side note, to use get bases, you would pass along a shotID or assetID and a task type name or task type ID, for example:

Code: Select all

shotBasenames = nimAPI.get_bases( shotID=1234, task="comp" )
I will say that I did find an issue with passing the task type name where it was not grouping properly. We changed the way task names were stored directly on files to allow for changing task type names and moved to directly using IDs. So while we updated our code to use task type IDs, the legacy variables in this function did not get properly updated. We also need to update the naming of these variables for clarity that these are not asking for specific tasks, but actual task type names. We will fix this today.

The results you would see from the above code would look something like this:

Code: Select all

[{"basename":"ESC_010_COMP_blurry"},{"basename":"ESC_010_COMP_bright"},{"basename":"ESC_010_COMP_cc"},{"basename":"ESC_010_COMP_flare"},{"basename":"ESC_010_COMP_test"}]

Cheers,
Andrew

User avatar
pablo
Posts: 10
Joined: September 3rd, 2020, 7:14 pm

Re: Getting base paths for shows, shots and assets

Post by pablo »

Thanks andrew.
Got get_paths() working.
One ting I have to say is that in windows it return forward slaches in wondows paths, so you get something like:
/jobnumber/show/shots/shot
Which I understand, it is probably to follow some sort of standar, but in get_jobServers() even the winPath has forward slaches, nothing important, just need a quick fix.
Im still not on the publishing thing, so I suppose I would need to go back to get_bases() in the future.

Cheers

P

User avatar
andrew
Site Admin
Posts: 308
Joined: June 24th, 2014, 8:10 am

Re: Getting base paths for shows, shots and assets

Post by andrew »

Hi Pablo,

Yea, the paths below the server are all standardized to forward slashes since they will be appended to the server based on the OS on demand. We resolve the slashes then. I'll take a look at the server slashes and see how those are being stored because those should be OS specific.

Cheers,
Andrew

Post Reply