ynput / ayon-houdini

Houdini addon for AYON
Apache License 2.0
7 stars 6 forks source link

HDA creation fails when project name starts with number #52

Open MustafaJafar opened 1 month ago

MustafaJafar commented 1 month ago

Is there an existing issue for this?

Current Behavior:

HDA creation fails when project name starts with number. Houdini doesn't names that start with number.
and, we currently use this hardcoded template name {project_name}{folder_path}_{node_name} for HDA asset type. Which result in this line in Houdini's log

The name must start with an alphabetic character.

however it works fine for projects starts with an alphabetic character. here's an example from my end.

Expected Behavior:

We should find some solution for it.

Version

1.0.0

What platform you are running on?

Windows

Steps To Reproduce:

  1. Launch Houdini in an AYON project starts with a number.
  2. Create an HDA

Are there any labels you wish to add?

Relevant log output:

Traceback (most recent call last):
  File "E:\Ynput\ayon-houdini\client\ayon_houdini\api\plugin.py", line 125, in create
    instance_node = self.create_instance_node(
  File "E:\Ynput\ayon-houdini\client\ayon_houdini\plugins\create\create_hda.py", line 221, in create_instance_node
    hda_node = to_hda.createDigitalAsset(
  File "C:\PROGRA~1/SIDEEF~1/HOUDIN~1.805/houdini/python3.9libs\houpythonportion\ui.py", line 1119, in decorator
    return func(*args, **kwargs)
  File "C:\PROGRA~1/SIDEEF~1/HOUDIN~1.805/houdini/python3.9libs\hou.py", line 16238, in createDigitalAsset
    return _hou.Node_createDigitalAsset(self, name, hda_file_name, description, min_num_inputs, max_num_inputs, compress_contents, comment, version, save_as_embedded, ignore_external_references, compile_asset, change_node_type, create_backup, install_path)
hou.OperationFailed: The attempted operation failed.
The name must start with an alphabetic character.

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "ayon_create.io.openpype.creators.houdini.hda", line 3, in <module>
  File "E:\Ynput\ayon-houdini\client\ayon_houdini\api\creator_node_shelves.py", line 119, in create_interactive
    context.create(
  File "E:\Ynput\ayon-core\client\ayon_core\pipeline\create\context.py", line 2140, in create
    return creator.create(
  File "E:\Ynput\ayon-houdini\client\ayon_houdini\api\plugin.py", line 152, in create
    six.reraise(
  File "E:\Ynput\ayon-launcher\.venv\lib\site-packages\six.py", line 718, in reraise
    raise value.with_traceback(tb)
  File "E:\Ynput\ayon-houdini\client\ayon_houdini\api\plugin.py", line 125, in create
    instance_node = self.create_instance_node(
  File "E:\Ynput\ayon-houdini\client\ayon_houdini\plugins\create\create_hda.py", line 221, in create_instance_node
    hda_node = to_hda.createDigitalAsset(
  File "C:\PROGRA~1/SIDEEF~1/HOUDIN~1.805/houdini/python3.9libs\houpythonportion\ui.py", line 1119, in decorator
    return func(*args, **kwargs)
  File "C:\PROGRA~1/SIDEEF~1/HOUDIN~1.805/houdini/python3.9libs\hou.py", line 16238, in createDigitalAsset
    return _hou.Node_createDigitalAsset(self, name, hda_file_name, description, min_num_inputs, max_num_inputs, compress_contents, comment, version, save_as_embedded, ignore_external_references, compile_asset, change_node_type, create_backup, install_path)
ayon_core.pipeline.create.creator_plugins.CreatorError: Creator error: The attempted operation failed.
The name must start with an alphabetic character.

Additional context:

Sometimes we can't avoid starting project names with numbers.

Internal Ticket Number: AY-6177

MustafaJafar commented 1 month ago

@moonyuet @BigRoy What do you think guys about this issue ? I thought about exposing the HDA asset type in HDA creator settings, which may/might break something or bring this issue back https://github.com/ynput/ayon-core/issues/534 .

BigRoy commented 1 month ago

I'm not sure - we may need to discuss this in a call. I still wonder why this is "so complicated" even though we have full control over how we name the HDA inside the file.

As far as I know the filename containing the HDA can have any name, including starting with a number whilst the node it defines internally we can define any name we want as well. I wonder what is currently REALLY restricting that "alphabetic number" thing, etc.

MustafaJafar commented 1 month ago

it's the to_hda.createDigitalAsset call. it didn't like the type_name that starts with number.

moonyuet commented 1 month ago

I'm not sure - we may need to discuss this in a call. I still wonder why this is "so complicated" even though we have full control over how we name the HDA inside the file.

As far as I know the filename containing the HDA can have any name, including starting with a number whilst the node it defines internally we can define any name we want as well. I wonder what is currently REALLY restricting that "alphabetic number" thing, etc.

This is really weird bug and it's only happened when you have a scene starting with a number? it could have been their functions itself encounter some decoding issue when dealing with some characters.

MustafaJafar commented 1 month ago

This is really weird bug and it's only happened when you have a scene starting with a number?

The problem happens because the project name is put at the beginning of the HDA type name template which causes Houdini to error as the asset type name in this situation will be starting by a number.

https://github.com/ynput/ayon-houdini/blob/649c6115b40faf6302fb2e5850d9f1a59a823a62/client/ayon_houdini/plugins/create/create_hda.py#L212-L226

BigRoy commented 1 month ago

What we've done in the past when e.g. defining namespaces for maya using the folder name when a folder name started with digits (which maya doesn't like in node names or namespaces) then we prefixed it with _. I wonder if that'd be 'ok' here too?

Or does that make usage of the node that much less nice? Or we just always prefix it with AYON_ hehe. Or hda_ - also doesn't sound too nice.

MustafaJafar commented 1 month ago

What we've done in the past when e.g. defining namespaces for maya using the folder name when a folder name started with digits (which maya doesn't like in node names or namespaces) then we prefixed it with _. I wonder if that'd be 'ok' here too?

I wonder if we should expose that template name to settings with a note about changing the name may break something ?

Or does that make usage of the node that much less nice? Or we just always prefix it with AYON_ hehe. Or hda_ - also doesn't sound too nice.

hda_{project_name}{folder_path}_{node_name} 🤔 this could work. I think some projects may start with ayon making the asset type name look weird ayon_ayon..._....

BigRoy commented 1 month ago

When does the user 'access' these names? Where does it see it? what does it influence? The default node name when created? In the tab creation menu?

Also, what if we just start the type name with the node name (but end with the project and folder path?) Or doesn't it allow trailing numbers either?

MustafaJafar commented 1 month ago

It doesn't affect the node name at all. It won't show up to users until they enable viewing asset definition. where they will be able to see the type name. image

I think reversing the template will fix the problem as well. {node_name}_{project_name}{folder_path}

BigRoy commented 1 month ago

I think reversing the template will fix the problem as well. {nodename}{project_name}{folder_path}

Maybe that is nicer anyway so that the node name (defining the type's name) is the most visible? :)

MustafaJafar commented 1 month ago

Maybe that is nicer anyway so that the node name (defining the type's name) is the most visible? :)

Maybe. also, it is defiantly starts with a alphabetic character.

BigRoy commented 1 month ago

Maybe confirm with client whether it's "fine" for them as well, and when confirmed - make a PR to swap it around to resolve the issue for now. We can always keep an issue open to investigate other ways to customize it? Or maybe the user can already customize it manually after create?

MustafaJafar commented 1 month ago

I'm not sure if artists need to deal with the asset type name/ operator type name/internal name Unlike TDs because they may use it for some automations (I mean Houdinish automations that don't use AYON api to get the data)

image


I was testing the new HDA operator type name template {node_name}_{project_name}{folder_path}
It fixed the problem with the HDA creation but exposed a bug in the HDA Loader! I opened a new scene and created an HDA with the same name as existent published HDA product. AYON recognized it as a new version and worked as expected but when loading that back, I can't switch the HDA product to an older version.

This bug can be replicated when the product name is the same but the operator type differs when publishing from multiple workfiles.

Traceback (most recent call last):
  File "E:\Ynput\ayon-core\client\ayon_core\tools\sceneinventory\view.py", line 366, in <lambda>
    lambda: self._show_version_dialog(item_ids, active_repre_id)
  File "E:\Ynput\ayon-core\client\ayon_core\tools\sceneinventory\view.py", line 843, in _show_version_dialog
    self._update_containers_to_version(
  File "E:\Ynput\ayon-core\client\ayon_core\tools\sceneinventory\view.py", line 1032, in _update_containers_to_version
    self._update_containers(item_ids, versions)
  File "E:\Ynput\ayon-core\client\ayon_core\tools\sceneinventory\view.py", line 1007, in _update_containers
    update_container(container, item_version)
  File "E:\Ynput\ayon-core\client\ayon_core\pipeline\load\utils.py", line 539, in update_container
    return Loader().update(container, context)
  File "E:\Ynput\ayon-houdini\client\ayon_houdini\plugins\load\load_hda.py", line 72, in update
    new = def_paths.index(file_path)
ValueError: '//storage/work/ayon_projects/Robo/Assets/Character/moco/publish/hda/mocopigHead/v002/robo_moco_mocopigHead_v002.hda' is not in list