Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

LibraryLoader: Use current project for asset query in families filter #3042

Merged
merged 1 commit into from
Apr 11, 2022

Conversation

iLLiCiTiT
Copy link
Member

Brief description

Family filter now query asset from current project instead of project selected in library loader.

Description

Library loader queried asset document which defines family filters from the project defined in library loader instead of from current project which caused missing asset document bug.

Testing notes:

  1. You have to have at least one library project
  2. Open host in other project
  3. Open Library loader in the host
  4. Select a library project
  5. Tool should not crash due to missing asset document

Source traceback

# Traceback (most recent call last):
#   File ".\openpype\openpype-v3.9.1\openpype\tools\libraryloader\app.py", line 278, in on_project_change
#     self._refresh_assets()
#   File ".\openpype\openpype-v3.9.1\openpype\tools\libraryloader\app.py", line 343, in _refresh_assets
#     self._families_filter_view.refresh()
#   File ".\openpype\openpype-v3.9.1\openpype\tools\loader\widgets.py", line 1047, in refresh
#     self._family_model.refresh()
#   File ".\openpype\openpype-v3.9.1\openpype\tools\loader\widgets.py", line 943, in refresh
#     family_config = self.family_config_cache.family_config(family)
#   File ".\openpype\openpype-v3.9.1\openpype\tools\utils\lib.py", line 354, in family_config
#     self._refresh()
#   File ".\openpype\openpype-v3.9.1\openpype\tools\utils\lib.py", line 417, in _refresh
#     tasks_info = asset_doc.get("data", {}).get("tasks") or {}
# AttributeError: 'NoneType' object has no attribute 'get'

@iLLiCiTiT iLLiCiTiT self-assigned this Apr 8, 2022
@iLLiCiTiT iLLiCiTiT added the type: bug Something isn't working label Apr 8, 2022
@BigRoy
Copy link
Collaborator

BigRoy commented Apr 8, 2022

This doesn't sound like the right way to do this?

For the Library Loader it shouldn't at all rely on os.environ because that is the current local project, but not the library project?

Instead it should be getting them from dbcon.Session?

@iLLiCiTiT
Copy link
Member Author

This doesn't sound like the right way to do this?

The filtering works based on your current context, not on selected context in UI, so it is actually the right way :)

@BigRoy
Copy link
Collaborator

BigRoy commented Apr 8, 2022

The filtering works based on your current context, not on selected context in UI, so it is actually the right way :)

Well, yes and no. (I might need more coffee so please correct me again if I'm wrong!)

Say I'm browsing project "Library X" and I'm working in "Project Y".
I'm checking out library project "Library X" asset "AssetX".

It will then try to find that "AssetX" name in "Project Y". And likely won't find an asset with a name match... and thus won't be able to retrieve an asset type either. So it's still wrong?

It sounds like what you want is to use the Profiles settings from Project Y but sample the data from Library X so your icons and filters match your current project and not from the library project? Which might get us in all some kind of edge cases.

Nevermind. I think I understand. It's not even checking a particular asset... that's what you meant with "current context".

Nonetheless it feels weird that we're checking the representations in LIBRARY X with config and family settings from PROJECT Y. But I can see why you might want that. In that way if Project X would never require "renders" you can e.g. always filter them by default too in the Library Loader. That makes sense.

Copy link
Member

@kalisp kalisp left a comment

Choose a reason for hiding this comment

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

Fixes the exception.

@iLLiCiTiT iLLiCiTiT merged commit 6e05a3a into develop Apr 11, 2022
@iLLiCiTiT iLLiCiTiT deleted the bugfix/library_loader_query_from_right_project branch April 11, 2022 10:15
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants