Unable to retrieve version number

Hello everyone :slight_smile:

I noticed that error when publishing a first asset Unable to retrieve version number from filename: Urbn-batman-Model-v001.ma.
We use dash - as a token separator in our file templates instead of the default underscore _.
The regex used to find the version number (here on github) is expecting an underscore
[\._]v([0-9]+)
Could we either :

  • Add a dash [\._-]v([0-9]+)
  • Use a more generic approach like [^a-z\d]+v(\d+)
  • Make it talk to the template ?

Hereā€™s the traceback for reference :

DEBUG: Collecting scene version from filename: Urbn-batman-Model-v001.ma
ERROR: templates:get_version_from_workfile:`Urbn-batman-Model-v001.ma` missing version string.Example `v004`
Traceback (most recent call last):
  File "C:\Users\KernelPanic\AppData\Local\Ynput\AYON\dependency_packages\ayon_2310271602_windows.zip\dependencies\pyblish\plugin.py", line 527, in __explicit_process
    runner(*args)
  File "C:\Users\KernelPanic\AppData\Local\Ynput\AYON\addons\openpype_3.18.6\openpype\plugins\publish\collect_scene_version.py", line 63, in process
    raise KnownPublishError("Unable to retrieve version number from "
openpype.pipeline.publish.publish_plugins.KnownPublishError: Unable to retrieve version number from filename: Urbn-batman-Model-v001.ma
1 Like

This to me sounds like the best option without breaking much backwards compatibility.

Iā€™m a bit worried this might get ā€˜falseā€™ positives like hello_v001_dav0.

But I do wonder what others thinks.

Just an FYI for whom it may concern. you can go to this website to test the regex mentioned in the post.
Just put in parentheses ()

  • ([\._]v([0-9]+))
  • ([\._-]v([0-9]+))
  • ([^a-z\d]+v(\d+))

This is too generic allowing many more characters than - and _
e.g. I can use & in filenames in windows and this regex [^a-z\d]+v(\d+) wonā€™t stop me.

unlike [\._-]v([0-9]+) is safer as BigRoy mentioned.

I tested it. it wonā€™t fail because the regex expects one v letter so _dev0 or _ved0 wonā€™t be a problem.

I think this can be a middle ground to have a place in settings for pipeline admins to add their regex.
but, Iā€™m not sure where to add that setting.

I agree, it is too permissive.
Letā€™s go with [\._-]v([0-9]+), Iā€™ll make an issue + PR.

For those who use regex101 often, if you create an account, youā€™ll be able to save your regexes and test strings :wink:

IMO it should go next to the template in the Anatomy settings as they have a direct relation.

2 Likes

It being configurable I personally think wouldnā€™t be all too bad - but I can imagine thereā€™s some hesitance on this as well because OH BOY - do some people like to mess with the settings, breaking things they literally have no clue about with then having random errors getting spewed about on e.g. Discord which theyā€™ve caused.

Anything thatā€™s customizable basically also ends up being a ā€œhey weā€™ll also need to support this edge caseā€ which if thereā€™s totally free control can easily become unmanageable.

In some way, having the AYON ecosystem is also about laying some foundational structures. Not saying that having _v is the best structure, but it does define a structure that can easily remain consistent.

Hi !

I would like to add why in my company we forbid the dash - , and prefer to use the underscore _ .
On Windows, we have seen several tools (canā€™t remember which ones) who mistakenly treated the dash as an option tag.
Said differently, if we named a scene bottle-v1.ma , we ended up getting this error :
ā€œthere is no option v1ā€.

Hello @Yul, long time no see since Snarx !

Thatā€™s a problem I never faced. Old legacy code can have some hardcoded stuff that make rules hard to change later on.
On the other hand, we use underscores as a space in our entity names.
sq0100_sh0010
treeHouse_int
treeHouse_ext
And dashes as a token separator in our template paths.

Hi @KernelPanic :slightly_smiling_face:
Indeed, it was a long time ago :sunglasses:

1 Like

In essence, should we have limited options for separators e.g. - , _ only ?