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

Validate opening and closing brackets on Anatomy keys. #846

Merged
merged 6 commits into from
Aug 19, 2024

Conversation

robin-ynput
Copy link
Contributor

Changelog Description

Additional fix to address: ynput/ayon-nuke#9 root cause
Currently anatomy keys with unmached [ and ] will be hard failing at formatting attempt. Redirect to AnatomyTemplateUnsolved instead.

Additional info

@iLLiCiTiT this one is mostly to trigger a discussion. See how you like it, I might not have fixed the way it should (hence keeping it as draft). Please feel free to recommend another implementation.

Testing notes:

Introduce a variant] key in the publish/test/directory anatomy setting.

from ayon_core.pipeline import Anatomy, get_current_project_name

prj = get_current_project_name()
ana = Anatomy(prj)
ttt = ana.format(data)
ttt["publish"]["test"]["directory"]

before fix:

  File "C:\Users\robert\AppData\Local\Ynput\AYON\addons\core_0.4.2\ayon_core\pipeline\anatomy\templates.py", line 348, in format
    value = value.format(data, strict)
  File "C:\Users\robert\AppData\Local\Ynput\AYON\addons\core_0.4.2\ayon_core\pipeline\anatomy\templates.py", line 297, in format
    value = value.format(data)
  File "C:\Users\robert\AppData\Local\Ynput\AYON\addons\core_0.4.2\ayon_core\pipeline\anatomy\templates.py", line 96, in format
    result = StringTemplate.format(self, data)
  File "C:\Users\robert\AppData\Local\Ynput\AYON\addons\core_0.4.2\ayon_core\lib\path_templates.py", line 117, in format
    part.format(data, result)
  File "C:\Users\robert\AppData\Local\Ynput\AYON\addons\core_0.4.2\ayon_core\lib\path_templates.py", line 532, in format
    formatted_value = self.template.format(**fill_data)
KeyError: 'variant]'

after fix:

raise AnatomyTemplateUnsolved(ayon_core.pipeline.anatomy.exceptions.AnatomyTemplateUnsolved: Anatomy template "{root[work]}/{project[name]}/{hierarchy}/{folder[name]}/source/{variant]}/v{version:0>3}" is unsolved. Missing keys: "variant]". Keys with invalid data type: `"version" <class 'NoneType'>`.

@robin-ynput robin-ynput self-assigned this Aug 14, 2024
@ynbot ynbot added size/XS type: bug Something isn't working labels Aug 14, 2024
robin-ynput and others added 4 commits August 19, 2024 08:08
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com>
@BigRoy
Copy link
Collaborator

BigRoy commented Aug 19, 2024

Out of curiosity - after the fix this reports:

AnatomyTemplateUnsolved(ayon_core.pipeline.anatomy.exceptions.AnatomyTemplateUnsolved: Anatomy template "{root[work]}/{project[name]}/{hierarchy}/{folder[name]}/source/{variant]}/v{version:0>3}" is unsolved. Missing keys: "variant]". Keys with invalid data type: "version" <class 'NoneType'>``

Where does that invalid data type of version come from in that report? Seems... unrelated or oddly reported together with the missing key?

@iLLiCiTiT
Copy link
Member

iLLiCiTiT commented Aug 19, 2024

Where does that invalid data type of version come from in that report? Seems... unrelated or oddly reported together with the missing key?

What was the template? Or where did you came up with data you've used?

@BigRoy
Copy link
Collaborator

BigRoy commented Aug 19, 2024

What was the template? Or where did you came up with data you've used?

If you're asking me. I took this output report line from @robin-ynput PR description :)

@robin-ynput
Copy link
Contributor Author

robin-ynput commented Aug 19, 2024

@BigRoy @iLLiCiTiT
{root[work]}/{project[name]}/{hierarchy}/{folder[name]}/source/{variant]}/{@version} in publish/test/directory

@BigRoy
Copy link
Collaborator

BigRoy commented Aug 19, 2024

@BigRoy @iLLiCiTiT {root[work]}/{project[name]}/{hierarchy}/{folder[name]}/source/{variant]}/{@version} in publish/test/directory

I see now. It's just a report of all the invalid things after each other, one one line. It's a bit confusing to read without context but I guess in a way it makes sense? Fine to ignore for me unless we (or just me?) get confused later again.

@iLLiCiTiT iLLiCiTiT merged commit 874a0f1 into develop Aug 19, 2024
5 checks passed
@iLLiCiTiT iLLiCiTiT deleted the bugfix/fix_anatomy_format branch August 19, 2024 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
host: cross size/XS type: bug Something isn't working
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants