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

Houdini: Workfile creator fix call to create_context_node on create #506

Merged
merged 3 commits into from
May 13, 2024

Conversation

BigRoy
Copy link
Collaborator

@BigRoy BigRoy commented May 10, 2024

Changelog Description

Fix call to create_context_node on create.

Additional info

The method only exists on the houdini host - not on the plugin itself.

Note that it would actually never error currently because apparently this gets called just beforehand elsewhere:

op_ctx = hou.node(CONTEXT_CONTAINER)
if not op_ctx:
op_ctx = self.create_context_node()

Which in itself, also generates the node. But at least this fixes the broken code were the issue to arise that the node did not exist at that point in time.

I'd actually want to refactor HoudiniHost.get_context_data() to not create a node unless it were 'updating' data. Because now even on querying data it creates a node - which to me feels like the wrong point in time to do so.

Testing notes:

Publishing should work.

@MustafaJafar
Copy link
Contributor

A question that might be irrelevant to this PR:
When should create_context_node() be called ?
tbh, I thought it's part of Installing AYON...

I add a stupid print statement inside it to find out when this method is triggered ?
I found out that:

When it's not called

  • when opening a new file while Skip Opening last workfile is enabled
  • when saving that file inside the same folder path.
  • when opening that file again from launcher while Skip Opening last workfile` is disabled
  • when switching contexts (even if the context node doesn't exist in the other workfile I'm opening)

When it's called

  • when opening a new file while Skip Opening last workfile is enabled and saving to a different folder path.
  • when opening the creator the first time in a scene that doesn't have a context node
  • before Auto-creating workfile instance... in get_context_data if the context node is not found. so, it's always found before running create_workfile.py
  • in update_context_data if the context node is not found. this happens when the node is destroyed after opening the publisher tool.

I think I can now understand your comment:

Note that it would actually never error currently because apparently this gets called just beforehand elsewhere:

op_ctx = hou.node(CONTEXT_CONTAINER)
if not op_ctx:
op_ctx = self.create_context_node()

Which in itself, also generates the node. But at least this fixes the broken code were the issue to arise that the node did not exist at that point in time.

The only way to show the error is by adding

hou.node(CONTEXT_CONTAINER).destroy()

between these two lines

if not op_ctx:
op_ctx = self.create_context_node()

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.

It works.

Copy link
Member

@moonyuet moonyuet left a comment

Choose a reason for hiding this comment

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

Make Sense as create_context_node function lives in HoudiniHost class

@antirotor antirotor merged commit 4d84ed8 into ynput:develop May 13, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants