...
In the example below, in order to resolve a path pattern like <custom.dependecy>
you need to add some value for the custom data. If that is not provided the resolve would otherwise fail if you re-render the proxies and there is no main task to provide the dependency which we normally would get from the post render hook after sending the task to the render farm.
Code Block |
---|
#""" Example file if you use some custom dependency in your submission scripts.__ # To resolve a path pattern like <custom.dependecy> you need to add some value for the custom data. #__ If that is not provided the resolve would otherwise fail if you re-render the proxies and there is no main task to provide the depdency. __ import sys def main(*args): ____/ /___ ______ data = args[0] ___ / /__ # make sure to set some value for the dependency.____ ___ ___ ____ / /_ #/ otherwise__ it will/ failed__ when resolving the path pattern '<custom.dependency>' if not data['template_values'].get('custom'): `/ ___/ / _ \/ / _ \/ __ `__ \/ _ \/ __ \/ __/ / data['template_values']['custom'] = {'dependency': ''} return data if __name__ == '__main__': main(sys.argv[1:]) |
Post Render Hook
The input is the output of the process called by the custom command task.
You will have to return a Dictionary which will be added as custom
to the resolver data and can later be accessed in the Path Builder. return {'dependency': job_id}
can later be resolved with <custom.dependency>
Code Block | ||
---|---|---|
| ||
# Example Python script for post render hook (post_render.py): import sys import re def main(*args): # args[0] is the output from the process calling the 'exec' and 'params' job_output = args[0] job_id = '' if job_output: match = re.search(r'JobID=([a-zA-Z0-9]*)', job_output) if match: job_id = match.group(1) print('Job ID: {}'.format(job_id)) # returns data that can later be access as "custom" # in this example: <custom.dependency> return {'dependency': job_id}/_/ / /_/ (__ ) / __/ / __/ / / / / / __/ / / / /_ \__,_/\__,_/____/ \___/_/\___/_/ /_/ /_/\___/_/ /_/\__/ Example file if you use some custom dependency in your submission scripts. To resolve a path pattern like <custom.dependecy> you need to add some value for the custom data. If that is not provided the resolve would otherwise fail if you re-render the proxies and there is no main task to provide the depdency. """ import sys def main(*args): data = args[0] # make sure to set some value for the dependency. # otherwise it will fail when resolving the path pattern '<custom.dependency>' if not data.get('template_values', {}).get('custom'): data['template_values']['custom'] = {'dependency': ''} return data if __name__ == '__main__': main(sys.argv[1:]) |
Pre Ingest Load
...
|
Post Render Hook
The input is the output of the process called by the custom command task.
You will have to return a Dictionary which will be added as custom
to the resolver data and can later be accessed in the Path Builder. return {'dependency': job_id}
can later be resolved with <custom.dependency>
Code Block | ||
---|---|---|
| ||
#""" Example Python script for pre ingest load hook (pre _ingest_load.py): import sys import re TAGS = ['assets', 'environments', 'hdri', 'photogrammetry', 'texture'] def main(*args): __ # args will be a List of Dicts: # [{'path': '/path/to/some/file.mov', 'category': '', 'tags': []}] items = args[0] __ result = [] ____/ /___ ______ ___ for item/ /__ in items: print(item) ____ ___ ___ ____ / /_ / __ / path__items = item.get('path', '').split('/') for path_item in path_items: `/ ___/ / _ \/ / _ \/ __ `__ \/ _ \/ __ \/ __/ / /_/ / # search for keywords in file path if path_item in TAGS: item.get('tags', []).append(path_item) # example regular expression to search for a pattern in the file path regex_asset = r'(prp|env|veh_\w*)' match = re.search(regex_asset, path_item) if match: /_/ (__ ) / __/ / __/ / / / / / __/ / / / /_ \__,_/\__,_/____/ \___/_/\___/_/ /_/ /_/\___/_/ /_/\__/ Example Python script for post render hook (post_render.py) This script will crawl the output for the Job Submission ID and pass it on to the proxy tasks. """ import sys import re def main(*args): # args[0] is a list of all outputs from all the transcoding step items job_outputs = args[0] job_ids = [] for job_output in job_outputs: if not job_output: item.get('tags', []).append(path_item) continue if item.get('tags'): match = re.search(r'JobID=([a-zA-Z0-9]*)', job_output) if match: # set last tag as the category job_id = match.group(1) item['category'] = item['tags'][-1] job_ids.append(job_id) # remove duplicated tags print('Job ID: {}'.format(job_id)) item['tags'] = list(set(item['tags'])) # returns data that can later be access as "custom" # in this example: result.append(item)<custom.dependency> return result {'dependency': ','.join(job_ids)} if __name__ == '__main__': main(sys.argv[1:]) |
Pre
...
Ingest Load
This hook can be used to edit, reformat or add additional values to the export from the library elements.
Info |
---|
Tip: use this hook to create a CSV file that you can import into Shotgrid |
The input is a List of Dictionaries and the same has to be returned from the function.
...
language | py |
---|
...
parse the file paths to set tags and the category from the file path before the items are loaded into the ingest list. These tags and the category will automatically populate the ingest list items.
The input is a List of Dictionaries and the same has to be returned from the function.
Code Block | ||
---|---|---|
| ||
"""
__ __ __
____/ /___ ______ ___ / /__ ____ ___ ___ ____ / /_
/ __ / __ `/ ___/ / _ \/ / _ \/ __ `__ \/ _ \/ __ \/ __/
/ /_/ / /_/ (__ ) / __/ / __/ / / / / / __/ / / / /_
\__,_/\__,_/____/ \___/_/\___/_/ /_/ /_/\___/_/ /_/\__/
Example Python script for pre ingest load hook (pre_ingest_load.py)
This scripts will automatically create tags based on keywords in the file paths.
It will also try to find asset folder name with a certain naming pattern like:
env_intHouse
veh_awesomeCar
The last found tag will be set as the category.
"""
import sys
import re
# search for these tags in the file paths and create them as tags
TAGS = ['assets', 'environments', 'hdri', 'photogrammetry', 'texture', 'compositors_toolkit']
def main(*args):
# args will be a List of Dicts:
# [{'path': '/path/to/some/file.mov', 'category': '', 'tags': []}]
items = args[0]
result = []
for item in items:
path_items = item.get('path', '').split('/')
for path_item in path_items:
# search for keywords in file path
if path_item in TAGS:
item.get('tags', []).append(path_item)
# example regular expression to search for a pattern in the file path
regex_asset = r'(prp|env|veh_\w*)'
match = re.search(regex_asset, path_item)
if match:
item.get('tags', []).append(path_item)
if item.get('tags'):
# set last tag as the category
item['category'] = item['tags'][-1]
result.append(item)
return result
if __name__ == '__main__':
main(sys.argv[1:])
|
Pre Export
This hook can be used to edit, reformat or add additional values to the export from the library elements.
Info |
---|
Tip: use this hook to create a CSV file that you can import into Shotgrid |
The input is a List of Dictionaries and the same has to be returned from the function.
Code Block | ||
---|---|---|
| ||
""" __ __ __ ____/ /___ ______ ___ / /__ ____ ___ ___ ____ / /_ / __ / __ `/ ___/ / _ \/ / _ \/ __ `__ \/ _ \/ __ \/ __/ / /_/ / /_/ (__ ) / __/ / __/ / / / / / __/ / / / /_ \__,_/\__,_/____/ \___/_/\___/_/ /_/ /_/\___/_/ /_/\__/ Example Python script for pre ingest load hook (pre_export.py): import sys import re ''' This scripts converts the data so you can import a CSV file into Autodesk Shotgrid Example output from das element: [{ 'name': 'awesome_element_00044', 'category': 'fire', 'category_id': 'Q3196', 'channel': 3, 'height': 1080, 'width': 192, 'pixel_aspect': '1', 'frame_first': 1001, 'frame_last': 1049, 'frame_count': 50, 'frame_rate': '25', 'created_at': '2021-10-01 09:26', 'media_type': 'movie', 'number': '00044', 'colorspace': 'sRGB', 'colorspace_source': 'sRGB', 'popularity': 23, 'tags': 'fire, flame, some other tag', 'path': '/path/to/server/awesome_element_0044/main_1920x1080_srgb/awesome_element_0044.mov', 'path_thumbnail': '/path/to/server/awesome_element_0044/thumb_960x540/awesome_element_0044.jpg', 'path_proxy': '/path/to/server/awesome_element_0044/proxy_1920x1080/awesome_element_0044.mov', 'path_filmstrip': '/path/to/server/awesome_element_0044/filmstrip_11520x270/awesome_element_0044.jpg' 'path_source': '/server/path/to/source_file.mov', }] Example output format for Shotgrid: "Version Name","Frame Range","Frame Count","First Frame","Frame Rate","Last Frame","Path to Frames","Tags" "awesome_element_0044","1001-1049","50","1001","25","1049","/path/to/server/awesome_element_0044/main_1920x1080_srgb/awesome_element_0044.mov","fire, flame, some other tag" """ '''import sys def main(*args): # args will be a List of Dicts: items = args[0] result = [] for item in items: frame_range = '{}-{}'.format(item['frame_first'], item['frame_last']) sg_item = { "Version Name": item['name'], "Frame Count": item['frame_count'], "First Frame": item['frame_first'], "Last Frame": item['frame_last'], "Frame Rate": item['frame_rate'], "Frame Range": frame_range, "Path to Frames": item['path'], "Tags": item['tags'].replace(',', ', '), } result.append(sg_item) return result if __name__ == '__main__': main(sys.argv[1:]) |