Skip to content

🏛️Product base types: add support for product base types in API #255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

antirotor
Copy link
Member

Changelog Description

Adding support for product base types.

Additional review information

Once the product base types are established, they should be marked mandatory in function arguments and product_type optional.

Testing notes:

This shouldn't affect "normal" functionality. If product base type is provided, it should be successfully queried or written to/from server.

Note

Closes: #254
Requires: ynput/ayon-backend#615

@antirotor antirotor requested review from iLLiCiTiT and Copilot May 30, 2025 12:49
@antirotor antirotor self-assigned this May 30, 2025
@antirotor antirotor added the type: enhancement New feature or request label May 30, 2025
@antirotor antirotor linked an issue May 30, 2025 that may be closed by this pull request
1 task
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for product base types across the API, including new type definitions, query filters, and API operations.

  • Introduces ProductBaseTypeDict and default fields for product base types.
  • Updates API functions to support filtering, querying, and creating/updating products with the new product base type.
  • Extends GraphQL queries and entity hub operations to incorporate product base types.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
ayon_api/typing.py Added a new TypedDict for product base types.
ayon_api/server_api.py Extended product-related functions to support product base types.
ayon_api/operations.py Updated product entity creation and update operations to include base type; noted a naming typo.
ayon_api/graphql_queries.py Added GraphQL queries for product base types.
ayon_api/entity_hub.py Modified product entity handling to incorporate product base type with a documentation update.
ayon_api/constants.py Added default fields for product base types.
ayon_api/_api.py Updated API functions to include product base type filters.
ayon_api/init.py Re-exported new functions related to product base types.
Comments suppressed due to low confidence (2)

ayon_api/operations.py:117

  • Correct the misspelled parameter name from 'produc_base_type' to 'product_base_type' to ensure consistency with the documentation and usage.
produc_base_type: str,

ayon_api/entity_hub.py:447

  • Update the docstring to reflect that the function creates a product entity rather than a task object for clarity.
'''Create a task object and add it to the entity hub.

@github-project-automation github-project-automation bot moved this to Pending Review in PR reviewing May 30, 2025
@antirotor antirotor marked this pull request as ready for review June 10, 2025 11:20

return parsed_data.get("productBaseTypes", [])


Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

return parsed_data.get("project", {}).get("productBaseTypes", [])


def get_product_base_type_names(
Copy link
Member

@iLLiCiTiT iLLiCiTiT Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function probably does not have to be implemented in server api.

It does 2 different things, either returns what get_project_product_base_types does or what get_products does. Looks like a helper functions somewhere in pipeline, but even there I can't imagine the usecase. I would not include it here.

name: str
color: Optional[str]
icon: Optional[str]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change

@@ -3475,6 +3501,7 @@ def from_entity_data(cls, product, entity_hub):
return cls(
name=product["name"],
product_type=product["productType"],
product_base_type=product["productBaseType"],
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
product_base_type=product["productBaseType"],
product_base_type=product.get("productBaseType"),

@@ -3492,6 +3519,7 @@ def to_create_body_data(self):
output = {
"name": self.name,
"productType": self.product_type,
"productBaseType": self.product_base_type,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This key should be added only if product base type is supported on server.

@@ -143,6 +165,30 @@ def project_product_types_query(fields):
return query


def project_product_base_types_query(fields):
Copy link
Member

@iLLiCiTiT iLLiCiTiT Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really don't think this should have separate query, it should be added to project query and it does not need special method (meaning get_project_product_base_types).

product under folder.
name (str): Is considered as a unique identifier of
the product under the folder.
product_base_type (str): Base type of the product, e.g. "render",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong position of argument


Args:
project_name (str): Project name.
name (str): Product name.
product_type (str): Product type.
product_base_type (str): Base type of the product, e.g. "render",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong position of argument.

if value is not None:
update_data[key] = value

update_data = {
Copy link
Member

@iLLiCiTiT iLLiCiTiT Jun 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should check if product type is supported and raise an error if is passed and is not supported?

@@ -443,10 +444,11 @@ def add_new_product(
entity_id: Optional[str] = None,
created: Optional[bool] = True,
):
"""Create task object and add it to entity hub.
"""Create a task object and add it to the entity hub.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"""Create a task object and add it to the entity hub.
"""Create a product object and add it to the entity hub.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ServerAPI should have property to check if product base type is supported and that property should be checked if is productBaseType is used for filtering or entity create/update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement New feature or request
Projects
Status: Pending Review
Development

Successfully merging this pull request may close these issues.

🏛️Product base types: Add support
2 participants