In rez.resolved_context for the ResolvedContext class, the expected type of the package_filter parameter in the documentation seems to be incorrect compared to what is actually expected by the code.
The expected type according to the documentation is PackageFilterBase which should mean that I can pass a PackageFilter object for this parameter, however, when I pass a PackageFilter class, I get the following error:
11:44:55 ERROR ResolvedContextError: Failed to load context from C:\Users\MY_USER\AppData\Local\Temp\rez_context_ta9orw0v\context.rxt: AttributeError: 'str' object has no attribute 'get'
From what I can tell, you must pass a PackageFilterList object instead. If you pass a PackageFilterList instead, then the resolved context works as intended.
Environment
Windows 10
Rez 2.112
Python 3.7
To Reproduce
Ensure the Rez Python API is in your PYTHONPATH
Run a Python interpreter and the following commands:
from rez.package_filter import PackageFilter, Rule
from rez.resolved_context import ResolvedContext
**Expected behavior**
A successful resolve, with no errors.
**Actual behavior**
A corrupt context was created. I am placed inside the shell, but I cannot run `rez context` as I usually can, as running `rez context` prints out the same error and does not give me any information about the current Rez context.
Running the following commands in the interpreter works as expected. Note that I am using the `PackageFilterList` class instead of `PackageFilter` class.
from rez.package_filter import PackageFilterList, Rule
from rez.resolved_context import ResolvedContext
In
rez.resolved_context
for theResolvedContext
class, the expected type of thepackage_filter
parameter in the documentation seems to be incorrect compared to what is actually expected by the code.The expected type according to the documentation is
PackageFilterBase
which should mean that I can pass aPackageFilter
object for this parameter, however, when I pass aPackageFilter
class, I get the following error:From what I can tell, you must pass a
PackageFilterList
object instead. If you pass aPackageFilterList
instead, then the resolved context works as intended.Environment
To Reproduce
pkg_filter = PackageFilter() rule = Rule.parse_rule('*-beta') pkg_filter.add_exclusion(rule) rez_ctx = ResolvedContext(['MY_PKG'], package_filter=pkg_filter) rez_ctx.execute_shell()
from rez.package_filter import PackageFilterList, Rule from rez.resolved_context import ResolvedContext
pkg_filter = PackageFilterList() rule = Rule.parse_rule('*-beta') pkg_filter.add_exclusion(rule) rez_ctx = ResolvedContext(['MY_PKG'], package_filter=pkg_filter) rez_ctx.execute_shell()