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 ?