ID 309808 - AssetAPI: Discrepancies between C++ and Python function signatures of asset plug-in base class and example plug-ins

Follow

Problem summary:

There appear to be several inconsistencies in signatures of functions of asset plug-ins between C++ and Python implementations, which can lead to confusion for developers of asset plug-ins, and to unexpected exceptions.

A header file that defines the class that is used to access the currently set asset management system plug-in is available in the plugin_apis directory of a Katana installation:

  • 
    plugin_apis/include/FnAsset/FnDefaultAssetPlugin.h

A base class for Python-based asset plug-ins is available in compiled form in the bin directory of a Katana installation:

  • 
    bin/python/AssetAPI/BaseAssetPlugin.pyc
    

An example implementation of a Python-based asset plug-ins is available in the plugins directory a Katana installation:

  • 
    plugins/Src/Resources/Examples/AssetPlugins/MockAsset.py

Examples of inconsistencies are:

  • getAssetFields():
    • Defined without a default value for its includeDefaults parameter in the AssetAPI.
    • Implemented with a default value for its includeDefaults parameter in MockAsset and PyMockAsset.
  • resolveAssetVersion():
    • Defined with a versionTag parameter with a default value in FnDefaultAssetPlugin.h.
    • Defined with a versionStr parameter with a default value in PyAsset.cpp, but documented without a default value.
    • Defined with a versionStr parameter without a default value in BaseAssetPlugin.py.

Steps to reproduce:

  1. Execute the following shell command in a terminal application with the Katana installation directory being the current working directory:
    • 
      cat ./plugins/Src/Resources/Examples/AssetPlugins/MockAsset.py | grep "def getAssetFields"
  2. Inspect the output of the above shell command, and note whether a default value for the includeDefaults parameter is defined. The command should output something like this:
    • 
          def getAssetFields(self, assetId, includeDefaults = False):
  3. Execute the following line of code from the Python tab, assuming that the includeDefaults parameter is optional, as hinted at in the implementation in MockAsset.py:
    • 
      AssetAPI.GetDefaultAssetPlugin().getAssetFields('some asset ID')

Expected behaviour:

The function runs and returns a dictionary of asset fields for the given asset ID, e.g.

  • 
    {'path': 'some asset ID', 'name': 'some asset ID'}

Actual behaviour:

An exception is raised, and the following error message is shown:

  • 
    TypeError: Required argument 'includeDefaults' (pos 2) not found

Workaround:

Call getAssetFields() with a boolean argument for the includeDefaults parameter:


AssetAPI.GetDefaultAssetPlugin().getAssetFields('some asset ID', False)

Reproduced versions/platforms:

  • Katana 3.0v1.000974a / Linux

    We're sorry to hear that

    Please tell us why