Flow Production Tracking Loader API reference
Loader API
The loader API gives developers access the underlying data structures and methods used by the loader UI to manage actions. They can use this interface to build more advanced custom load workflows.
The main interface of the API is the LoaderManager class which exposes the methods that drive the Loader UI for the actions management.
The code below shows how to execute a suite of actions using this API:
# need to have an engine running in a context where the loader has been
# configured.
engine = sgtk.platform.current_engine()
# get the loader app instance from the engine's list of configured apps
loader_app = engine.apps.get("tk-multi-loader2")
# ensure we have the loader instance.
if not loader_app:
raise Exception("The loader is not configured for this context.")
# create a new loader manager instance
manager = loader_app.create_loader_manager()
# use case 1: retrieve the actions for a single publish and execute a specific action
loader_actions = manager.get_actions_for_publish(publish, manager.UI_AREA_MAIN)
for action in loader_actions:
if action["name"] == "my_action":
manager.execute_action(publish, action)
# use case 2: retrieve the common actions between many publishes and execute one of these action for all the publishes
loader_actions = manager.get_actions_for_publishes(publishes, manager.UI_AREA_MAIN)
reference_actions = loader_actions.get("my_action")
if reference_actions:
manager.execute_multiple_actions(reference_actions)
See the documentation for each of these classes below for more detail on how to use them.
LoaderManager
This class gives developers direct access to the same methods and data structures used by the Loader UI to manage actions. You can create an instance of this class directly via the configured loader app like this:
# need to have an engine running in a context where the publisher has been
# configured.
engine = sgtk.platform.current_engine()
# get the loader app instance from the engine's list of configured apps
loader_app = engine.apps.get("tk-multi-loader2")
# ensure we have the loader instance.
if not loader_app:
raise Exception("The loader is not configured for this context.")
# create a new loader manager instance
manager = loader_app.create_loader_manager()
- class tk_multi_loader.api.LoaderManager(bundle, loader_logger=None)[source]
This class is used for managing and executing loads.
Initialize the manager.
- Parameters:
bundle – The bundle (app, engine or framework) instance for the app that the calling code is associated with.
loader_logger – This is a standard python logger to use during loading. A default logger will be provided if not supplied. This can be useful when implementing a custom UI, for example, with a specialized log handler
- get_actions_for_publish(sg_data, ui_area)[source]
Returns a list of actions for a publish.
Shotgun data representing a publish is passed in and forwarded on to hooks to help them determine which actions may be applicable.
- Parameters:
sg_data – Shotgun data dictionary with all the standard publish fields.
ui_area –
Indicates which part of the UI the request is coming from. Currently one of:
tk_multi_loader.LoaderManager.UI_AREA_MAIN
tk_multi_loader.LoaderManager.UI_AREA_DETAILS
tk_multi_loader.LoaderManager.UI_AREA_HISTORY
- Returns:
List of dictionaries, each with keys name, params, caption and description
- get_actions_for_publishes(sg_data_list, ui_area)[source]
Returns common actions for a list of publishes.
Shotgun data representing a publish is passed in and forwarded on to hooks to help them determine which actions may be applicable.
- Parameters:
sg_data_list – List of Shotgun data dictionary with all the standard publish fields.
ui_area –
Indicates which part of the UI the request is coming from. Currently one of:
tk_multi_loader.LoaderManager.UI_AREA_MAIN
tk_multi_loader.LoaderManager.UI_AREA_DETAILS
tk_multi_loader.LoaderManager.UI_AREA_HISTORY
- Returns:
Dictionary where the keys are the action names and the values contain the list of available actions. One action will be defined for each publish.
- execute_action(sg_data, action)[source]
Execute the given action for the selected publish.
- Parameters:
sg_data – Shotgun data dictionary with all the standard publish fields.
action – Dictionary containing the action data has defined in the hook.
- execute_multiple_actions(actions)[source]
Execute many actions for a list of publishes.
- Parameters:
actions – List of dictionaries holding all the actions to execute. Each entry will have the following values: name: Name of the action to execute sg_publish_data: Publish information coming from Shotgun params: Parameters passed down from the generate_actions hook.