Skip to content
Permalink
Browse files

For #46368: Customizable export UI, plus additional hook methods for …

…Shot/Cut updating. (#42)

This is implementing the idea outlined in #41 from a client. It's providing hook methods for building custom widgets for each processor we provide, plus allows for custom preset properties to be created, and those properties then being used to set/initialize the custom widget.

In addition, to meet the workflow requirements outlined by a client, additional hook methods have been added to allow for customization of if/how Shots, Cuts, and CutItems are created/updated during the export process.
  • Loading branch information...
thebeeland committed Mar 14, 2018
1 parent b369a94 commit 3b6f4429ef83908467d7014a0e82633af35e876a
Showing with 1,700 additions and 76 deletions.
  1. +2 −0 app.py
  2. +111 −0 docs/index.rst
  3. BIN docs/resources/hiero_export_custom_ui.png
  4. +24 −0 hooks/hiero_customize_export_ui.py
  5. +14 −5 hooks/hiero_get_extra_publish_data.py
  6. +11 −4 hooks/hiero_get_quicktime_settings.py
  7. +15 −7 hooks/hiero_get_shot.py
  8. +9 −3 hooks/hiero_post_version_creation.py
  9. +5 −4 hooks/hiero_pre_export.py
  10. +14 −5 hooks/hiero_resolve_custom_strings.py
  11. +18 −13 hooks/hiero_translate_template.py
  12. +93 −0 hooks/hiero_update_cuts.py
  13. +60 −0 hooks/hiero_update_shot.py
  14. +13 −3 hooks/hiero_update_version_data.py
  15. +11 −1 hooks/hiero_upload_thumbnail.py
  16. +25 −1 info.yml
  17. +22 −0 python/base_hooks/__init__.py
  18. +266 −0 python/base_hooks/hiero_customize_export_ui.py
  19. +36 −0 python/base_hooks/hiero_get_extra_publish_data.py
  20. +33 −0 python/base_hooks/hiero_get_quicktime_settings.py
  21. +52 −0 python/base_hooks/hiero_get_shot.py
  22. +46 −0 python/base_hooks/hiero_post_version_creation.py
  23. +29 −0 python/base_hooks/hiero_pre_export.py
  24. +36 −0 python/base_hooks/hiero_resolve_custom_strings.py
  25. +39 −0 python/base_hooks/hiero_translate_template.py
  26. +82 −0 python/base_hooks/hiero_update_cuts.py
  27. +79 −0 python/base_hooks/hiero_update_shot.py
  28. +34 −0 python/base_hooks/hiero_update_version_data.py
  29. +31 −0 python/base_hooks/hiero_upload_thumbnail.py
  30. +39 −1 python/tk_hiero_export/__init__.py
  31. +108 −0 python/tk_hiero_export/base.py
  32. +39 −1 python/tk_hiero_export/sg_audio_export.py
  33. +29 −2 python/tk_hiero_export/sg_nuke_shot_export.py
  34. +83 −2 python/tk_hiero_export/sg_shot_processor.py
  35. +56 −19 python/tk_hiero_export/shot_updater.py
  36. +40 −5 python/tk_hiero_export/version_creator.py
  37. +96 −0 tests/fixtures/config/hooks/hiero_customize_export_ui.py
2 app.py
@@ -50,6 +50,7 @@
ShotgunAudioExporterUI,
ShotgunHieroObjectBase,
)

sys.path.pop()

# list keywords Hiero is using in its export substitution
@@ -61,6 +62,7 @@


class HieroExport(Application):

def init_app(self):
# let the shot exporter know when the first shot is being run
self.first_shot = False
@@ -0,0 +1,111 @@
Shotgun Hiero Export API reference, |release|
#############################################

Overview
********

The ``tk-hiero-export`` app adds custom Shotgun export processors to the Hiero/Nuke Studio export framework.

By way of custom export processors, the user can create and update entities in the current Project in Shotgun.

During the export process a number things can happen:

- Status of associated Shot entities can be updated
- Nuke scripts can be written into the project's filesystem structure for each Shot that's processed
- Sequence and Shot entity data can be updated in Shotgun
- Cuts can be update to include new CutItems built from the exported sequences

Documentation from The Foundry concerning the Hiero Python API can be found `here. <https://learn.foundry.com/hiero/developers/11.0/HieroPythonDevGuide/api/index.html>`_

Hooks
*****

Hooks provided by the Hiero Export app allow for customization of various aspects of the export process and its UI.

.. py:currentmodule:: base_hooks
Updating Shot entities
----------------------

.. autoclass:: HieroUpdateShot
:members:


Updating and Creating Cut and CutItem entities
----------------------------------------------

.. autoclass:: HieroUpdateCuts
:members:


Getting Shot entities for Hiero TrackItems
------------------------------------------

.. autoclass:: HieroGetShot
:members:


Customizing Quicktime export settings
-------------------------------------

.. autoclass:: HieroGetQuicktimeSettings
:members:


Customizing PublishedFile data
------------------------------

.. autoclass:: HieroGetExtraPublishData
:members:


Executing logic after Version entity creation
---------------------------------------------

.. autoclass:: HieroPostVersionCreation
:members:


Executing logic prior to export
-------------------------------

.. autoclass:: HieroPreExport
:members:


Resolving strings into Shotgun-queried values
---------------------------------------------

.. autoclass:: HieroResolveCustomStrings
:members:


Resolving Shotgun Toolkit templates into export string representations
----------------------------------------------------------------------

.. autoclass:: HieroTranslateTemplate
:members:


Customizing Version entity data
-------------------------------

.. autoclass:: HieroUpdateVersionData
:members:


Uploading Thumbnails to Shotgun
-------------------------------

.. autoclass:: HieroUploadThumbnail
:members:


Creating custom UI elements and properties
------------------------------------------

.. autoclass:: HieroCustomizeExportUI
:members:


Binary file not shown.
@@ -0,0 +1,24 @@
# Copyright (c) 2018 Shotgun Software Inc.
#
# CONFIDENTIAL AND PROPRIETARY
#
# This work is provided "AS IS" and subject to the Shotgun Pipeline Toolkit
# Source Code License included in this distribution package. See LICENSE.
# By accessing, using, copying or modifying this work you indicate your
# agreement to the Shotgun Pipeline Toolkit Source Code License. All rights
# not expressly granted therein are reserved by Shotgun Software Inc.

import sgtk

HookBaseClass = sgtk.get_hook_baseclass()


class HieroCustomizeExportUI(HookBaseClass):
"""
This class defines methods that can be used to customize the UI of the various
Shotgun-related exporters. Each processor has its own set of create/get/set
methods, allowing for customizable UI elements for each type of export.
"""
# For detailed documentation of the methods available for this hook, see
# the documentation at http://developer.shotgunsoftware.com/tk-hiero-export/
pass
@@ -12,14 +12,23 @@


class HieroGetExtraPublishData(Hook):
""" Get a data dictionary for a PublishedFile to be updated in Shotgun. """
"""
This class defines a hook that can be used to gather additional data
and add it to the data dictionary that's used to register any new
PublishedFile entities in Shotgun during the given Task's execution.
"""
def execute(self, task, **kwargs):
"""
:param task: The Hiero Task that is currently being processed
Return the dictionary to update the data for the PublishedFile in Shotgun
or None if there is no extra information to publish.
Get a data dictionary for a PublishedFile to be updated in Shotgun.
The track item associated with this task can be accessed via task._item.
.. note:: The track item associated with this task can be accessed via
task._item.
:param task: The Hiero Task that is currently being processed.
:returns: A dictionary to update the data for the PublishedFile in
Shotgun, or None if there is no extra information to publish.
:rtype: dict
"""
# No extra data by default
return None
@@ -15,13 +15,20 @@

class HieroGetQuicktimeSettings(Hook):
"""
Return a Shotgun Shot dictionary for the given Hiero items
This class defines a hook that allows for customization of encoding
settings for any Quicktimes written by the export process.
"""
def execute(self, for_shotgun, **kwargs):
"""
Returns a tuple where the first item is the file_type of a Nuke
write node and the second item is a dictionary of knob names and
values.
Gets encoding settings for Quicktimes generated by the export process.
:param bool for_shotgun: Whether the settings are being gathered for
Quicktime output intended for use within the Shotgun web app.
:returns: A tuple, where the first item is the file_type of a Nuke
write node, and the second item is a dictionary of knob names and
values.
:rtype: tuple
"""
import nuke

@@ -13,15 +13,21 @@

class HieroGetShot(Hook):
"""
Return a Shotgun Shot dictionary for the given Hiero items
This class implements a hook that can determines which Shotgun entity
should be associated with each task and track item being exported.
"""

def execute(self, task, item, data, **kwargs):
"""
Takes a hiero.core.TrackItem as input and returns a data dictionary for
the shot to update the cut info for.
"""
:param task: The Hiero task being processed.
:param item: The hiero.core.TrackItem being processed.
:param dict data: A dictionary with cached parent data.
:returns: A Shot entity.
:rtype: dict
"""
# get the parent entity for the Shot
parent = self.get_shot_parent(item.parentSequence(), data)

@@ -72,13 +78,15 @@ def get_shot_parent(self, hiero_sequence, data, **kwargs):
Given a Hiero sequence and data cache, return the corresponding entity
in Shotgun to serve as the parent for contained Shots.
.. note:: The data dict is typically the app's `preprocess_data` which
maintains the cache across invocations of this hook.
:param hiero_sequence: A Hiero sequence object
:param data: A dictionary with cached parent data.
:param dict data: A dictionary with cached parent data.
The data dict is typically the app's `preprocess_data` which maintains
the cache across invocations of this hook.
:returns: A Shotgun entity.
:rtype: dict
"""

# stick a lookup cache on the data object.
if "parent_cache" not in data:
data["parent_cache"] = {}
@@ -14,16 +14,20 @@

class HieroPostVersionCreation(HookBaseClass):
"""
Post processing of the Version entity that was created during export.
This class implements a hook that can be used to add custom logic to
be run after a Version entity is created in Shotgun as part of the
export process.
"""
def execute(self, version_data, **kwargs):
"""
Run following the creation of the Version entity in Shotgun. The
Runs following the creation of the Version entity in Shotgun. The
provided version data is the data structure containing information
about the Version entity, including its ID in Shotgun.
Example version_data:
.. code-block:: python
{'code': 'Scene_v031_abc',
'created_by': {'id': 39, 'name': 'Jeff Beeland', 'type': 'HumanUser'},
'entity': {'id': 1166, 'name': 'ABC', 'type': 'Shot'},
@@ -32,9 +36,11 @@ def execute(self, version_data, **kwargs):
'published_files': [{'id': 108,
'name': 'scene_v031_ABC.mov',
'type': 'PublishedFile'}],
'sg_path_to_movie': 'd:\\shotgun\\projects\\devwindows\\sequences\\123\\ABC\\editorial\\2015_11_24\\plates\\scene_v031_ABC.mov',
'sg_path_to_movie': '/shotgun/projects/devwindows/sequences/123/ABC/editorial/2015_11_24/plates/scene_v031_ABC.mov',
'sg_task': {'id': 2113, 'name': 'Comp', 'type': 'Task'},
'type': 'Version',
'user': {'id': 39, 'name': 'Jeff Beeland', 'type': 'HumanUser'}}
:param dict version_data: The Version entity that was created in Shotgun.
"""
pass
@@ -13,13 +13,14 @@

class HieroPreExport(Hook):
"""
Allows clearing of caches prior to shot processing
This class implements a hook that can be used to run custom logic prior to
the start if the export process.
"""
def execute(self, processor, **kwargs):
"""
Allows clearing of caches prior to shot processing. This is called just prior to export.
Called just prior to export. One use case for would be to clear
cached data here, just before the export begins.
:param processor: Processor The is being used, in case distinguishing between
differnt exports is needed.
:param processor: The processor object that is about to be started.
"""
pass
@@ -12,17 +12,26 @@


class HieroResolveCustomStrings(Hook):
"""Translates a keyword string into its resolved value for a given task."""
# cache of shots that have already been pulled from shotgun
"""
This class implements a hook that is used to resolve custom tokens into
their concrete value when paths are being processed during the export.
"""
# Cache of shots that have already been pulled from shotgun
_sg_lookup_cache = {}

def execute(self, task, keyword, **kwargs):
"""
The default implementation of the custom resolver simply looks up
the keyword from the shotgun shot dictionary.
the keyword from the Shotgun Shot entity dictionary. For example,
to pull the shot code, you would simply specify 'code'. To pull
the sequence code you would use 'sg_sequence.Sequence.code'.
For example, to pull the shot code, you would simply specify 'code'.
To pull the sequence code you would use 'sg_sequence.Sequence.code'.
:param task: The export task being processed.
:param str keyword: The keyword token that needs to be resolved.
:returns: The resolved keyword value to be replaced into the
associated string.
:rtype: str
"""
shot_code = task._item.name()

@@ -16,22 +16,27 @@

class HieroTranslateTemplate(Hook):
"""
Translates a template object into a hiero export string.
"""

This class implements a hook that's responsible for translating a Toolkit
template object into a Hiero export string.
"""
def execute(self, template, output_type, **kwargs):
"""
Takes a sgtk template object as input and returns a string
representation which is suitable for hiero exports. The hiero export templates
contain tokens such as {shot} or {clip} which are replaced by the exporter.
This hook should convert a template object with its special custom fields into
such a string. Depending on your template setup, you may have to do different
steps here in order to fully convert your template. The path returned will be
validated to check that no leftover template fields are present and that the
returned path is fully understood by hiero.
"""
Takes a Toolkit template object as input and returns a string
representation which is suitable for Hiero exports. The Hiero export
templates contain tokens, such as {shot} or {clip}, which are replaced
by the exporter. This hook should convert a template object with its
special custom fields into such a string. Depending on your template
setup, you may have to do different steps here in order to fully
convert your template. The path returned will be validated to check
that no leftover template fields are present, and that the returned
path is fully understood by Hiero.
:param template: The Toolkit template object to be translated.
:param str output_type: The output type associated with the template.
:returns: A Hiero-compatible path.
:rtype: str
"""
# first convert basic fields
mapping = {
"{Sequence}": "{sequence}",

0 comments on commit 3b6f442

Please sign in to comment.
You can’t perform that action at this time.