Breakdown API

BreakdownManager

class tk_multi_breakdown2.api.BreakdownManager(bundle)[source]

Bases: object

This class is used for managing and executing file updates.

Initialize the manager.

get_scene_objects(execute_in_main_thread=True)[source]

Get the current scene objects by executing the scan_scene hook method.

A list of dictionaries representing the scene references will be returned. The return dict value has the following key-values:

node (str)

The name of the node which holds the reference.

type (str)

The node type.

path (str)

The reference file path.

extra_data (dict)

Extra data for the reference (optional).

Parameters:

execute_in_main_thread (bool) – True will ensure the hook method is executed in the main thread, else False will execute in the current thread. Default is True, since the scan_scene function will need to execute DCC functionality that likely needs to execute in the main thread (e.g. GUI events).

Returns:

A list of scene references.

Return type:

List[dict]

scan_scene(extra_fields=None, execute_in_main_thread=True)[source]

Scan the current scene to return a list of scene references.

A list of FileItem objects representing the scene references will be returned.

Parameters:

execute_in_main_thread (bool) – True will ensure the hook method is executed in the main thread, else False will execute in the current thread. Default is True, since the scan_scene function will need to execute DCC functionality that likely needs to execute in the main thread (e.g. GUI events).

Returns:

A list of scene references.

Return type:

List[FileItem]

get_published_files_from_file_paths(file_paths, extra_fields=None, bg_task_manager=None)[source]

Query the Flow Production Tracking API to get the published files for the given file paths.

Parameters:
  • file_paths (List[str]) – A list of file paths to get the published files from.

  • extra_fields (List[str]) – A list of Flow Production Tracking fields to append to the Flow Production Tracking query when retreiving the published files.

  • bg_task_manager – (optional) A background task manager to execute the request async. If not provided, the request will be executed synchronously.

Type:

BackgroundTaskManager

Returns:

The task id for the request is returned if executed async, else the published files data is returned if executed synchronosly.

Return type:

int | dict

get_file_items(scene_objects, published_files)[source]

Get the file item objects for the given scene objects.

Scene objects that do not have a corresponding Flow Production Tracking Published File will be omitted from the result (a FileItem will not be created for it).

The scene_objects dict param expects the key-values:

node (str)

The name of the node which holds the reference.

type (str)

The node type.

path (str)

The reference file path.

extra_data (dict)

Extra data for the reference (optional).

Parameters:
  • scene_objects (dict) – Objects from the DCC. This value can be the result returned by the scan_scene method.

  • published_files – The list of published files corresponding to the scene_objects. Any scene objects that do not have a matching published will be omitted from the result (there will not be a FileItem object created for it). This can be the result returned by the sgtk.util.find_publish method.

Returns:

A list of FileItem objects representing the scene objects.

Return type:

List[FileItem]

get_published_file_fields()[source]

Get the fields to pass to the query to retrieve the published files when scanning the scene.

Returns:

The published file fields.

Return type:

list<str>

get_published_file_filters()[source]

Get additional filters to pass to the query to retrieve the published files when scanning the scene.

Returns:

The published file filters.

Return type:

List[List[dict]]

get_history_published_file_filters()[source]

Get additional filters to pass to the query to retrieve the history published files for a given file item.

Parameters:

item (FileItem) – The file item to get the history published file filters for.

Returns:

The history published file filters.

Return type:

List[List[dict]]

get_latest_published_file(item, data_retriever=None, extra_fields=None)[source]

Get the latest available published file according to the current item context.

Parameters:
  • item (FileItem) – :class`FileItem` object we want to get the latest published file

  • data_retreiver – If provided, the api request will be async. The default value will execute the api request synchronously.

Returns:

The latest published file as a Flow Production Tracking entity dictionary if the request was synchronous, else the request background task id if the request was async.

get_published_files_for_items(items, data_retriever=None, extra_fields=None)[source]

Get all published files (history) for the given items.

Parameters:
  • items (List[FileItem]) – the list of :class`FileItem` we want to get published files for.

  • data_retreiver – If provided, the api request will be async. The default value will execute the api request synchronously.

Returns:

If the request is async, then the request task id is returned, else the published file data result from the api request.

Return type:

str | dict

get_published_file_history(item, extra_fields=None, data_retriever=None)[source]

Get the published history for the selected item. It will gather all the published files with the same context than the current item (project, name, task, …)

Parameters:
  • item (FileItem) – :class`FileItem` object we want to get the published file history

  • extra_fields (List[str]) – A list of Flow Production Tracking fields to append to the Flow Production Tracking query fields.

  • data_retreiver – If provided, the api request will be async. The default value will execute the api request synchronously.

Returns:

If the request is async, then the request task id is returned, else the published file history.

Return type:

str | dict

update_to_latest_version(items)[source]

Update the item to its latest version.

Parameters:

items (FileItem | List[FileItem]) – The item or items to update.

Returns:

The list of file item objects that were updated to the latest version.

Return type:

List[FileItem]

update_items_to_latest_version(items)[source]

Update the list of items to their respective latest version.

Parameters:

items (FileItem | List[FileItem]) – The item or items to update.

Returns:

The list of file item objectggs that were updated to the latest version.

Return type:

List[FileItem]

update_to_specific_version(item, sg_data)[source]

Update the item to a specific version.

Parameters:
  • item (FileItem) – Item to update

  • sg_data (dict) – Dictionary of Flow Production Tracking data representing the published file we want to update the item to

Returns:

True if the item requires the data model to update, else False will not trigger a model update.

Return type:

bool

FileItem

class tk_multi_breakdown2.api.FileItem(node_name, node_type, path, sg_data=None, extra_data=None, locked=False, loaded=True)[source]

Bases: object

Encapsulate details about a single version of a file. Each instance represents a single “version” but will contain details about the latest available version of the file.

Class constructor.

Parameters:
  • node_name – Name of the file node

  • node_type – Type of the file node

  • path – Path on disk of this file

  • sg_data – Dictionary of Flow Production Tracking data representing this file in the database

  • extra_data – Dictionary containing additional information about this file

  • locked – True if the file item is locked, else False.

  • loaded – True if the file item is loaded, else False.

property highest_version_number

Get highest version number available in the Flow Production Tracking database for this file.

property node_name

Get the name of the file node.

property node_type

Get the type of the file node.

property path

Get the path on disk for this file item.

property locked

Get whether or not this file item is locked.

property loaded

Get whether or not this file item is loaded.

property latest_published_file

Get the latest published file for this file item.

property extra_data

Get or set the extra data associated with this item.

property sg_data

Get or set the Flow Production Tracking data associated with this item.

property thumbnail_path

Get or set the thumbnail path for this item.

to_dict()[source]

Return the FileItem as a dictionary. Only include the properties needed by the scene operation hook update method.

Returns:

The item properties as a dictionary