You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Rez version: 2.75.0
Platform and OS: Linux - Fedora 33
Problem
When doing a Rez resolve with inclusion or exclusion filters an exception is raised if one or more filters contain a - and others don't. For example:
rez-env os --exclude "*.beta""os-windows*"
Traceback (most recent call last):
File "/opt/rez/bin/rez/rez-env", line 8, in<module>sys.exit(run_rez_env())
File "/opt/rez/lib64/python3.9/site-packages/rez/cli/_entry_points.py", line 143, in run_rez_env
return run("env")
File "/opt/rez/lib64/python3.9/site-packages/rez/cli/_main.py", line 170, in run
returncode = run_cmd()
File "/opt/rez/lib64/python3.9/site-packages/rez/cli/_main.py", line 162, in run_cmd
return func(opts, opts.parser, extra_arg_groups)
File "/opt/rez/lib64/python3.9/site-packages/rez/cli/env.py", line 198, incommand
context = ResolvedContext(
File "/opt/rez/lib64/python3.9/site-packages/rez/resolved_context.py", line 293, in __init__
resolver = Resolver(context=self,
File "/opt/rez/lib64/python3.9/site-packages/rez/resolver.py", line 80, in __init__
self.package_filter_hash = package_filter.sha1
File "/opt/rez/lib64/python3.9/site-packages/rez/package_filter.py", line 72, in sha1
returnsha1(str(self).encode("utf-8")).hexdigest()
File "/opt/rez/lib64/python3.9/site-packages/rez/package_filter.py", line 279, in __str__
filters = sorted(self.filters, key=lambda x: (x.cost, str(x)))
File "/opt/rez/lib64/python3.9/site-packages/rez/package_filter.py", line 279, in<lambda>
filters = sorted(self.filters, key=lambda x: (x.cost, str(x)))
File "/opt/rez/lib64/python3.9/site-packages/rez/package_filter.py", line 203, in __str__
returnstr((sorted(self._excludes.items()),
TypeError: '<' not supported between instances of 'str' and 'NoneType'
If you change the second filter to os*windows* it works.
When looking at the source code the problem is because the filters get grouped by family. "os-windows*" would be grouped by "os" while "*.beta" would be grouped under None. Then Rez tries to sort the filters by family, but you of course can't sort None and "os". (Printing the excludes makes it more clear: {None: [glob(*.beta)], 'os': [glob(os-windows*)]}).
Proposed solution
Add a function that can be passed to the key argument of sorted(). That function would convert everything to strings, so the sorting works properly. That would mean None would be turned into "None". Probably it would be nicer to convert None into an empty string.
If the proposed solution seems okay, I can make a merge request if needed. Merge request: #1038
The text was updated successfully, but these errors were encountered:
jasperges
changed the title
An exception is raise when combining filters with - and without -.
An exception is raised when combining filters with - and without -.
Mar 11, 2021
Rez version: 2.75.0
Platform and OS: Linux - Fedora 33
Problem
When doing a Rez resolve with inclusion or exclusion filters an exception is raised if one or more filters contain a
-
and others don't. For example:If you change the second filter to
os*windows*
it works.When looking at the source code the problem is because the filters get grouped by family.
"os-windows*"
would be grouped by"os"
while"*.beta"
would be grouped underNone
. Then Rez tries to sort the filters by family, but you of course can't sortNone
and"os"
. (Printing the excludes makes it more clear:{None: [glob(*.beta)], 'os': [glob(os-windows*)]}
).Proposed solution
Add a function that can be passed to the
key
argument ofsorted()
. That function would convert everything to strings, so the sorting works properly. That would meanNone
would be turned into"None"
. Probably it would be nicer to convertNone
into an empty string.If the proposed solution seems okay, I can make a merge request if needed.Merge request: #1038The text was updated successfully, but these errors were encountered: