Get published version path from version data

Hi how do i get the published version path, i have the version data which i get using the get_version_by_id.
this is the version data i get from the id.

{
    'attrib': {
        'description': None, 
        'frameEnd': 1020, 
        'families': ['review', 'slack'], 
        'resolutionHeight': 1080, 
        'machine': 'chntech16', 
        'pixelAspect': 1.0, 
        'comment': '', 
        'resolutionWidth': 1920, 
        'site': None, 
        'frameStart': 1001, 
        'handleStart': 0, 
        'clipOut': 1, 
        'source': '{root[work]}/PRPT/PROP/BALL/work/MOD/prpt_BALL_MOD_v023.ma', 
        'clipIn': 1, 
        'intent': None, 
        'handleEnd': 0, 
        'colorSpace': None, 
        'fps': 25.0
    }, 
    'data': {
        'author': 'pavithraj', 
        'step': 1.0, 
        'time': '20250311T114804Z'
    }, 
    'version': 2, 
    'productId': '4a62a2d6c69911efbf26d8bbc1da57df', 
    'updatedAt': '2025-03-11T06:23:53.556896+00:00', 
    'id': '9bb81554fe4011efa2c3d8bbc1da57df', 
    'taskId': 'da16c132b30d11ef8c017a3a96401200', 
    'name': 'v002', 
    'tags': [], 
    'thumbnailId': '677539fefe4111efb8250242ac120003', 
    'status': 'Active', 
    'createdAt': '2025-03-11T06:23:53.189506+00:00', 
    'active': True, 
    'author': 'pavithraj'
}

By the published version path, you mean getting the file path of a particular version of a product?

For reference, product info are structed in this manner:

project
  └── folder path
         └── product
                └── version
                       └── representation
                              └── files

Here’s an example ayon-recipes/get_product_info_from_ayon.py at 3164d335597fd65b339ab09d97ab1b524eb1e0e6 Β· MustafaJafar/ayon-recipes Β· GitHub

Yes this is exactly what i was looking for, the published files, i am bit curious when returning the file path why is it not resolving the root[work] location, is there any way to resolve that also when getting the file?

You’d need to get template data and resolve the paths when necessary.
Here’s an example ayon-recipes/resolve_paths_using_template_data.py at 3164d335597fd65b339ab09d97ab1b524eb1e0e6 Β· MustafaJafar/ayon-recipes Β· GitHub

ah … ok is it possible to get it just with using the ayon_api? i am planning to run this on a system without all the ayon env setup? or is it only possible to run this inside of ayon env?

It uses some functions from ayon-core.

I’m not sure how to/if it possible to run standalone python scripts that can imports ayon_api and ayon_core.

This topic came before here Turning VS Code into an Ayon script editor

Thanks @mustafa_jafar will have a look at all this thanks for the info,
would like to add i was able to get those from the ayon project entity,

1 Like

Getting published files through ayon_core is much easier, no need to manage the template data yourself. Just call ayon_core.pipeline.get_representation_path(representation_entity: dict)

There are some others like get_representation_path_from_context and get_representation_path_with_anatomy that may be better suited if trying to access it from outside a project context etc.

get_representation_path_from_context is essentially what all the Loader plug-ins for example are using through self.filepath_from_context

2 Likes