Skip to content
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

Load and manage products from a library project #1005

Draft
wants to merge 34 commits into
base: develop
Choose a base branch
from

Conversation

moonyuet
Copy link
Member

@moonyuet moonyuet commented Nov 11, 2024

Changelog Description

This PR is to support loading assets from the library project while the users can update and set versions with the containers from the loaded assets in the scene inventory tools. In the DCC hosts, you need to add the project_name as part of the container data, otherwise it will use the current project name instead(which results to the Entity N/A shown in the #983)
Resolve #983

Additional info

Make sure using the self.filepath_from_context(context) for the updating function in the loaders.

Testing notes:

  1. Load Assets from the current project and library projects
  2. Go to scene inventory to set version or update
  3. Should be working.

@ynbot ynbot added the type: enhancement Improvement of existing functionality or minor addition label Nov 11, 2024
@moonyuet moonyuet self-assigned this Nov 11, 2024
@ynbot ynbot added the size/S label Nov 11, 2024
@iLLiCiTiT
Copy link
Member

iLLiCiTiT commented Nov 11, 2024

I'm afraid you chose easy way, which does complicate things a lot.

Once we decide we want to work with different projects on containers, we have to work with that in UI and api too. I'll use one example get_version_items which did expect product ids, but now also expects representation ids, those representation ids are used to find corresponding container, to find corresponding project. That is by design bad, that method should expect project name and product ids, when you call it, you should have prepared mapping to which projects which product ids belong.

All places using that method have access to container items, so they also have access to correct project name. You should use that as advantage.

Comment on lines 155 to 157
version_items_by_product_id = self._controller.get_version_items(
product_ids
product_ids, project_names
)
Copy link
Collaborator

@BigRoy BigRoy Nov 12, 2024

Choose a reason for hiding this comment

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

I think this is the wrong approach because we'd need to know which product id belongs to which project. What @iLLiCiTiT mentioined before is to separate the query to self._controller.get_version_items() to have separate calls per project. So above, we'd get the product ids per project and then here we would do:

version_items_by_product_id = self._controller.get_version_items(project_name, product_id)

As stated before - as far as I know on the backend nothing is keeping the database from having a product entity with the same id across different projects. Is that correct @martastain ? (It's unlikely by just creating products to happen, but when cloning e.g. projects I suppose it may very well share the same ids?) As such, we should still make sure to be explicit about which project each entry belongs to.

The same goes for version_items_by_product_id dict. That should technically also be "per project" because otherwise product_id may overlap accidentally.

@iLLiCiTiT thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

Yes

Copy link
Collaborator

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

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

Aside of their being plenty of code style notes I gave this a quick test run - and it seems to work fine.

Opening the scene inventory with containers from another project showed these entities just fine. However, visually there's NO clue whatsoever in the scene inventory that these are from another project.

I wonder whether it warrants somehow highlighting them. I was thinking of adding a project_name column to the Scene Inventory UI and potentially highlighting the name AYON blue using a delegate if the project name is not the current project.

But this is looking really nice.

I tested it with this PR: ynput/ayon-maya#176

@iLLiCiTiT
Copy link
Member

It should be somewhat functional. Please re-test and report bugs.

QUESTION: What to do about switch dialog? Even I'm not able to make it work across projects, and it will be PITA to allow it for different than current project.

@moonyuet
Copy link
Member Author

It should be somewhat functional. Please re-test and report bugs.

Works okay in my side.
image

QUESTION: What to do about switch dialog? Even I'm not able to make it work across projects, and it will be PITA to allow it for different than current project.

But we need to think about if there is any case of which same folder path and task name across different project....

@BigRoy
Copy link
Collaborator

BigRoy commented Nov 26, 2024

Set Version does not work in scene inventory in Houdini on product from another project. Error:

Traceback (most recent call last):
  File "F:\dev\ayon-core\client\ayon_core\tools\sceneinventory\view.py", line 392, i
n <lambda>
    lambda: self._show_version_dialog(item_ids, active_repre_id)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\dev\ayon-core\client\ayon_core\tools\sceneinventory\view.py", line 821, i
n _show_version_dialog
    versions |= {
                ^
  File "F:\dev\ayon-core\client\ayon_core\tools\sceneinventory\view.py", line 822, i
n <setcomp>
    version_item.version
AttributeError: 'dict' object has no attribute 'version'

@moonyuet
Copy link
Member Author

Set Version does not work in scene inventory in Houdini on product from another project. Error:

Traceback (most recent call last):
  File "F:\dev\ayon-core\client\ayon_core\tools\sceneinventory\view.py", line 392, i
n <lambda>
    lambda: self._show_version_dialog(item_ids, active_repre_id)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\dev\ayon-core\client\ayon_core\tools\sceneinventory\view.py", line 821, i
n _show_version_dialog
    versions |= {
                ^
  File "F:\dev\ayon-core\client\ayon_core\tools\sceneinventory\view.py", line 822, i
n <setcomp>
    version_item.version
AttributeError: 'dict' object has no attribute 'version'

I am testing with other hosts too(Maya, Zbrush and Unreal), it is generally not working when setting version....

@MustafaJafar
Copy link
Contributor

Set Version does not work in scene inventory in Houdini on product from another project. Error:

Traceback (most recent call last):
  File "F:\dev\ayon-core\client\ayon_core\tools\sceneinventory\view.py", line 392, i
n <lambda>
    lambda: self._show_version_dialog(item_ids, active_repre_id)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "F:\dev\ayon-core\client\ayon_core\tools\sceneinventory\view.py", line 821, i
n _show_version_dialog
    versions |= {
                ^
  File "F:\dev\ayon-core\client\ayon_core\tools\sceneinventory\view.py", line 822, i
n <setcomp>
    version_item.version
AttributeError: 'dict' object has no attribute 'version'

I was able to reproduce the same error.

Copy link
Contributor

@MustafaJafar MustafaJafar left a comment

Choose a reason for hiding this comment

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

Tested along ynput/ayon-houdini#185 and it works.

Copy link
Collaborator

@BigRoy BigRoy left a comment

Choose a reason for hiding this comment

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

Works for me now (tested Houdini and Fusion).

Would be nice however if the "Project" was inherited upwards to the parent group, so you don't need to expand the entries to see the Project name.

image

@iLLiCiTiT
Copy link
Member

What about switch dialog? Allow to show it only if items from one project are selected?

@BigRoy
Copy link
Collaborator

BigRoy commented Nov 28, 2024

What about switch dialog? Allow to show it only if items from one project are selected?

I guess that'd be a first step yes. But honestly, I'd just add a Project field in there. If not changed by user, it acts as "do not change project", etc. just like the other fields. However, I imagine that's also quite a refactor - as such, we may want to leave that for separate PR.

@iLLiCiTiT
Copy link
Member

I guess that'd be a first step yes. But honestly, I'd just add a Project field in there. If not changed by user, it acts as "do not change project", etc. just like the other fields. However, I imagine that's also quite a refactor - as such, we may want to leave that for separate PR.

Made it stupid and show the dialog per project (so if containers from 3 projects are selected it will show the dialog 3 times).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/S type: enhancement Improvement of existing functionality or minor addition
Projects
Status: Merge Requested
Development

Successfully merging this pull request may close these issues.

Load and manage products from a library project
5 participants