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

General: Fix import after movements #3028

Merged
merged 2 commits into from
Apr 7, 2022

Conversation

iLLiCiTiT
Copy link
Member

Brief description

One of refactor PRs broke import of get_representation_context.

Description

Added get_representation_context to openpype.pipeline import level and changed import in TVPaint load plugin.

Testing notes:

  1. TVPaint loader should be visible
  2. Maya loader ImportModelRender should work

@iLLiCiTiT iLLiCiTiT self-assigned this Apr 6, 2022
@BigRoy
Copy link
Collaborator

BigRoy commented Apr 7, 2022

✅ It fixes this for Maya right click in scene inventory on a container (as reported here):

// Warning: openpype.lib.python_module_tools : Failed to load path: "S:\openpype\OpenPype\openpype\hosts\maya\plugins\inventory\import_modelrender.py"
Traceback (most recent call last):
  File "S:\openpype\OpenPype\openpype\lib\python_module_tools.py", line 92, in modules_from_path
    module = import_filepath(full_path, mod_name)
  File "S:\openpype\OpenPype\openpype\lib\python_module_tools.py", line 37, in import_filepath
    module_loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 728, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "S:\openpype\OpenPype\openpype\hosts\maya\plugins\inventory\import_modelrender.py", line 4, in <module>
    from openpype.pipeline import (
ImportError: cannot import name 'get_representation_context' from 'openpype.pipeline' (S:\openpype\OpenPype\openpype\pipeline\__init__.py) // 

🔥 But now shows this error:

// Warning: openpype.lib.python_module_tools : Failed to load path: "S:\openpype\OpenPype\openpype\hosts\maya\plugins\inventory\import_modelrender.py"
Traceback (most recent call last):
  File "S:\openpype\OpenPype\openpype\lib\python_module_tools.py", line 92, in modules_from_path
    module = import_filepath(full_path, mod_name)
  File "S:\openpype\OpenPype\openpype\lib\python_module_tools.py", line 42, in import_filepath
    six.exec_(_stream.read(), module.__dict__)
  File "S:\openpype\OpenPype\.venv\lib\site-packages\six.py", line 735, in exec_
    exec("""exec _code_ in _globs_, _locs_""")
  File "<string>", line 1, in <module>
  File "<string>", line 4, in <module>
ImportError: cannot import name get_representation_path_from_context // 

That'd be fixed if imported directly into openpype.pipeline from openpype.pipeline.load (or even better if loaded from openpype.pipeline.utils) OR if the import in import_modelrender.py is refactored to import from openpype.pipeline.utils itself.)

The same missing import issue for get_representation_path_from_context exists here in Photoshop Load Image from Sequence

Remove redundant import of get_representation_path.. into openpype.pipeline.load

I'd actually also remove the import of get_representation_path_from_context into openpype.pipeline.load from openpype.pipeline.load.utils since that's currently unused from openpype.pipeline.load and just adds to the confusion that was recently brought up on Discord by Oscar Domingo where imports are imported from elsewhere, from elsewhere, from elsewhere and it's a long trail.

Same goes for get_representation_path - I believe everywhere it's imported from openpype.pipeline and that file can just directly import from openpype.pipeline.load.utils

@iLLiCiTiT
Copy link
Member Author

We'll be dealing with these structure changes over time and after moving avalon. For example functions working with database will be moved at one place. Also these functions may change or be removed.

@iLLiCiTiT iLLiCiTiT merged commit d3a8f9c into develop Apr 7, 2022
@iLLiCiTiT iLLiCiTiT deleted the bugfix/fix_get_repre_context_import branch April 7, 2022 09:38
@mkolar mkolar added this to the 3.9.3 milestone Apr 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants