Skip to content

🏛️Product base types: Creation and creator plugins #1297

@antirotor

Description

@antirotor

Intro

Product base type is solving the problem with product type being too tightly bound to the code and workflow logic but also used as a categorizing element in UIs. Having product type image is fine until I also want to differentiate between reference image and concept image but without changing any code whatsoever.
In this case, you would have to duplicate the creator plugin (best case scenario) or even tweak publishing plugins and loaders to support this.

We think that pipeline should define some core, basic types for workflows and studios can customize the naming as they want without affecting any logic and code - well except sorting and filtering. For that, we decided to introduce new property of every Product - product base type. It holds the information that the product is image no matter how we call it. With that, existing product type purpose switches to the customizable part - you can name it as you like and it will still behave as product base type defines.

Changes

This poses some challenges because product type is currently mandatory and used on so many places.

Server Support

We need to store new product base type on the server somehow. This is handled by ynput/ayon-backend#575 - it is adding necessary fields and graphql support. Product base type can be NULL - this is intentional to easily identify all products created by legacy code without product base type support. As long as product type is there (and it must be as it is not optional) existing features should work without change. For example REST API endpoint for product creation POST /api/projects/{project_name}/products still needs productType but it doesn't require productBaseType.

AYON Python API support

Is introduced by ynput/ayon-python-api#255 - allows you to get product base types, it allows you to query them using GraphQL and you can add them to new product entities. Affected functions are:

  • new_product_entity()
  • create_product()
  • update_product()
  • get_product_base_types()
  • get_project_product_base_types()
  • get_product_base_type_names()

AYON Core support

Multiple changes are made in ayon-core:

In Loader plugins you can use product_base_types to limit the loader plugin to specific product base types the same way you can do it now for product types, representations, etc. like:

class SomeLoader(Loader):
    product_base_types = {"image", "icon"}

This is something that needs to be refactored in existing Loader plugins across the pipeline, to unify and transition them from using product types as they will become too dynamic.

This part is adding product_base_type attribute to BaseCreator and to CreatedInstance and is also changing get_product_name() method to make use of product base types there. This is unfortunately the most backwards incompatible piece because the way CreatedInstance is executed in every creator might differ: product base type is either passed when CreatedInstance is invoked or it is taken from the passed Creator object, so the Creator must be changed to provide it.

{product[baseType]} can be used in Anatomy and Product name profiles as long as it can be resolved from the creators.

Testing instructions

Server needs to be built with the product base type support - ynput/ayon-backend#575 . AYON Launcher needs to use ayon-python-api from ynput/ayon-python-api#255 - the easiest way is to put it to pyproject.toml - change the current ayon-python-api definition to:

ayon-python-api = {  git = "https://github.com/ynput/ayon-python-api.git", branch = "enhancement/254-product-base-types-add-support" }
  • Save and run poetry update - that should install that version to your local environment. When you run AYON from sources, it should use that version of API.

  • Next thing is to merge all the ayon-core PR into one local branch. Make sure is_supporting_product_base_type() in ayon_core.pipeline.compatiblity returns True.

Warning

Since it is changing database and there are no migration scripts yet, I recommend creating new testing project as the older project will be missing correct tables and columns.

  • Create new products using REST API or try to publish them - support for integration is added here 🏛️Product base types: Support in the integrator #1315. Once the product is in AYON, you should be able to see product base type column in the loader.

  • You can test Creators by adding product_base_type there and also adding {product[baseType]} into your Product name profiles (ayon+settings://core/tools/creator/product_name_profiles). You should see correct product name when creating new instance with host using Publisher.

Testing notes:

During the testing, you might get weird issues from hosts, like in Maya this will trigger this error TypeError: Unsupported type: <class 'NoneType'> that could be solved by this PR ynput/ayon-maya#282

Metadata

Metadata

Assignees

Labels

sponsoredThis is directly sponsored by a client or community member

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions