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

Mocha integration with AYON #5

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

Conversation

antirotor
Copy link
Member

@antirotor antirotor commented Jan 10, 2025

Changelog Description

This PR is adding basic functionality of the addon + in host AYON menu, working workfile tool, and pipeline API implementation. Adding support for publishing tracking data for all available tracking data exporters in Mocha. You can set if you want to publish for selected layers or for all, you can also set exporter options. All formats will be added as representation for product per layer. Adds support for publishing of shape data in similar fashion as tracking data.

Additional review information

Some exporters produce mulitple files, those will be published as resources and their manifest (list of them) will be main representation file.

Stubs

I've auto-generated stubs from mocha python api using mypy stubgen but it lack most type hints and there is some confusion inside to (named arguments in documentation are in fact not named, etc.) I am enhancing the stubs whenever I hit that particular function to help with further development. To use those stubs in PyCharm, just add them to the interpreter paths. Not sure how this is done in VSCode.

Warning

This needs other opened PRs to work;

Note

Closes: #4
Closes: #3

TODO:

  • startup script
  • AYON menu
  • Workfiles
  • Container tools
  • Publish context handling
  • Publishing tracking data
  • Publishing shapes

Notes

opening projects
It seems that Mocha doesn't support opening of project workfile in the current running instance via Python. You can work with them on API level, but there is probably no way to load the project to the current running instance of Mocha Pro. This hinders Workfile tool functionality unfortunately. So whenever you open new workfile via Workfile tool, it will re-run Mocha and close the old instance. The same thing will happen on save.

default tracking clips
There is also no way to set more than one default tracking clip per project and you cannot rename it. So there is two types of loaders, one to load "standard" clip and the other one that will replace the path in the default tracked clip.

@antirotor antirotor added sponsored This is directly sponsored by a client or community member type: feature Adding something new and exciting to the product labels Jan 10, 2025
@antirotor antirotor self-assigned this Jan 10, 2025
@antirotor antirotor linked an issue Jan 10, 2025 that may be closed by this pull request
1 task
@jakubjezek001 jakubjezek001 self-requested a review January 14, 2025 16:26
@jakubjezek001
Copy link
Member

Loading was not working. And the Mocha was freezing after some time. There is not available any console log output which I could share with you.

@jakubjezek001
Copy link
Member

jakubjezek001 commented Jan 24, 2025

Here is another bizarre thing happening since ayon-mocha was added to my testing bundle. Not sure if it is actually related to the Mocha integration of to ayon-core in general.

ynput/ayon-silhouette#1 (comment)

WARNING:ayon_core.lib.python_module_tools:Failed to load path: "C:\CODE\__YNPUT\ayon-mocha\client\ayon_mocha\plugins\load\load_clip.py"
Traceback (most recent call last):
  File "C:\CODE\__YNPUT\ayon-core\client\ayon_core\lib\python_module_tools.py", line 79, in modules_from_path
    module = import_filepath(full_path, mod_name)
  File "C:\CODE\__YNPUT\ayon-core\client\ayon_core\lib\python_module_tools.py", line 31, in import_filepath
    module_loader.exec_module(module)
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "C:\CODE\__YNPUT\ayon-mocha\client\ayon_mocha\plugins\load\load_clip.py", line 9, in <module>
    from ayon_mocha.api.lib import update_ui
  File "C:\Program Files\BorisFX\Silhouette 2024.5\resources\python\Lib\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
    return original_import(name, *args, **kwargs)
  File "C:\CODE\__YNPUT\ayon-mocha\client\ayon_mocha\api\__init__.py", line 2, in <module>
    from .pipeline import (
  File "C:\Program Files\BorisFX\Silhouette 2024.5\resources\python\Lib\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
    return original_import(name, *args, **kwargs)
  File "C:\CODE\__YNPUT\ayon-mocha\client\ayon_mocha\api\pipeline.py", line 26, in <module>
    from mocha.project import Project
  File "C:\Program Files\BorisFX\Silhouette 2024.5\resources\python\Lib\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
    return original_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'mocha'
>>> [ *** Failed to load 1 files
- C:\CODE\__YNPUT\ayon-mocha\client\ayon_mocha\plugins\load\load_clip.py
**********
Traceback (most recent call last):
 
  File "C:\CODE\__YNPUT\ayon-core\client\ayon_core\lib\python_module_tools.py", line 79, in modules_from_path
    module = import_filepath(full_path, mod_name)
 
  File "C:\CODE\__YNPUT\ayon-core\client\ayon_core\lib\python_module_tools.py", line 31, in import_filepath
    module_loader.exec_module(module)
 
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
 
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
 
  File "C:\CODE\__YNPUT\ayon-mocha\client\ayon_mocha\plugins\load\load_clip.py", line 9, in <module>
    from ayon_mocha.api.lib import update_ui
 
  File "C:\Program Files\BorisFX\Silhouette 2024.5\resources\python\Lib\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
    return original_import(name, *args, **kwargs)
 
  File "C:\CODE\__YNPUT\ayon-mocha\client\ayon_mocha\api\__init__.py", line 2, in <module>
    from .pipeline import (
 
  File "C:\Program Files\BorisFX\Silhouette 2024.5\resources\python\Lib\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
    return original_import(name, *args, **kwargs)
 
  File "C:\CODE\__YNPUT\ayon-mocha\client\ayon_mocha\api\pipeline.py", line 26, in <module>
    from mocha.project import Project
 
  File "C:\Program Files\BorisFX\Silhouette 2024.5\resources\python\Lib\site-packages\shiboken2\files.dir\shibokensupport\__feature__.py", line 142, in _import
    return original_import(name, *args, **kwargs)
 
ModuleNotFoundError: No module named 'mocha'
 
********** ] 

EDIT:
I was just testing it in Nuke and this is actually happening in Nuke too - but is visible only in terminal rather then in Script editor's console.

client/ayon_mocha/addon.py Outdated Show resolved Hide resolved
@antirotor
Copy link
Member Author

Loaded clips are not usable as clip source for tracking or roto. This will be great complication for users since they will need to import clips manually anyway and those will not be version controlled.

This is now possible - it seems that you can have only one default trackable clip per project that cannot be change (or renamed). So i added new loader, that is changing source of the clip.

@antirotor antirotor changed the title Add basic functionality Mocha integration with AYON Feb 4, 2025
Comment on lines 25 to 47
project_name = self.project_name
folder_path = self.create_context.get_current_folder_path()
task_name = self.create_context.get_current_task_name()
host_name = self.create_context.host_name

current_folder_path = None
if current_instance is not None:
current_folder_path = current_instance["folderPath"]

if current_instance is None:
folder_entity = ayon_api.get_folder_by_path(
project_name, folder_path
)
task_entity = ayon_api.get_task_by_name(
project_name, folder_entity["id"], task_name
)
product_name = self.get_product_name(
project_name,
folder_entity,
task_entity,
variant,
host_name,
)
Copy link

@BigRoy BigRoy Feb 4, 2025

Choose a reason for hiding this comment

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

This should be refactored to use the entity getters on the create_context, e.g. self.create_context.get_current_task_entity(), etc. | or at least @iLLiCiTiT will tell you that!

I believe Silhouette integration already did that too, and maybe only a few other hosts (I think resolve maybe?). Reference: https://github.com/ynput/ayon-silhouette/blob/3fbd09c0bef7b994d4e27961a5d19a694548f89b/client/ayon_silhouette/plugins/create/create_workfile.py#L31-L37

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah right, it's copypasta from Maya :D

Copy link
Member Author

Choose a reason for hiding this comment

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

maybe - since the code is mostly the same, should we have workfile creator base in ayon-core?

Copy link
Member

Choose a reason for hiding this comment

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

maybe - since the code is mostly the same, should we have workfile creator base in ayon-core?

Deservers issue. I think it does make sense, but when I though about it, the inheritance of classes makes it complicated.

@jakubjezek001
Copy link
Member

During publishing following error had shown to me.

Traceback (most recent call last):
  File "C:\Users\jakub\AppData\Local\Ynput\AYON\dependency_packages\ayon_2412190933_windows.zip\dependencies\pyblish\plugin.py", line 528, in __explicit_process
    runner(*args)
  File "C:\CODE\__YNPUT\ayon-mocha\client\ayon_mocha\plugins\publish\export_shapes.py", line 46, in process
    outputs = self.export(
  File "C:\CODE\__YNPUT\ayon-mocha\client\ayon_mocha\plugins\publish\export_shapes.py", line 206, in export
    raise KnownPublishError(msg)
ayon_core.pipeline.publish.publish_plugins.KnownPublishError: Cannot get extension from Nuke RotoPaint [Basic] exporter.

publish-report-250206-10-39.json

@jakubjezek001
Copy link
Member

And Trackpoints also crashing:

Traceback (most recent call last):
  File "C:\Users\jakub\AppData\Local\Ynput\AYON\dependency_packages\ayon_2412190933_windows.zip\dependencies\pyblish\plugin.py", line 528, in __explicit_process
    runner(*args)
  File "C:\CODE\__YNPUT\ayon-mocha\client\ayon_mocha\plugins\publish\export_tracking_points.py", line 57, in process
    outputs = self.export(
  File "C:\CODE\__YNPUT\ayon-mocha\client\ayon_mocha\plugins\publish\export_tracking_points.py", line 218, in export
    raise KnownPublishError(msg)
ayon_core.pipeline.publish.publish_plugins.KnownPublishError: Cannot get extension from Nuke Corner Pin exporter.

publish-report-250206-10-43.json

@antirotor
Copy link
Member Author

antirotor commented Feb 6, 2025

Can't really reproduce:
image
Are you using Mocha 2025? If so, there might be changes I need to check out.

@antirotor
Copy link
Member Author

I've added support for Mocha Pro 2025 as the above error was caused by it. Unfortunately the exportes are renamed and there is no unique identifier for each exporter so to support them, I had to add separate exporter name mappings. But this now work for 2025 and 2024.5 and it should take much effort to add other versions if needed.

@antirotor
Copy link
Member Author

This PR adds documentation ynput/ayon-documentation#336

ruff.toml Outdated Show resolved Hide resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sponsored This is directly sponsored by a client or community member type: feature Adding something new and exciting to the product
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for publishing shape data Support for publishing track data Workfile management support
4 participants