AcademySoftwareFoundation / AcademySoftwareFoundation/rez

Nested env variable defined can't be tested

Open
#479 1 comment 0 reactions 0 assignees View on GitHub
documentation enhancement
Dominant language
Python
Stars
1.1k
Forks
369
Avg merge
12d 3h
Merged PRs (30d)
5

Description

Hello Guys,

I think I might have got find something strange.
We where doing tests on nested env using a package looking like this (let's say the env is named test_env):
```
def pre_commands():
if not defined('TEST'):
env.TEST = 'test'
print 'package: ', 'PRE', env.TEST

def commands():
print 'package: ', '1', env.TEST
env.TEST.append('test2')
print 'package: ','2',env.TEST
```
On the first resolution the output looks like:

> ~ \> rez env test_package
> package: PRE test
> package: 1 test
> package: 2 test:test2
>
> You are now in a rez-configured environment.
>
> \>(test_package): ~ \>

Which is what we want.
But if we run the resolution a second time (within this first env), here is what we see:

> \>(test_package): ~ > rez env test_package
> package: PRE test:test2
> package: 1 test:test2
> package: 2 test2
>
> You are now in a rez-configured environment.
>
> \>\>(test_package): ~ >

The variable has been overriden during the append call. Instead of _test:test2_ we only got _test_. So I took a while to look at the rex API, and finally found out that this was due to the parent_variable config. But, it seems like the test for wether a variable is defined or not is not responding correctly.
I feel like instead of testing if a key is contained wihtin the current env, or the parent env, it should also test if the var will be herited by the current context from it's parent. #478

Contributor guide

Open the contributing guide

Research direction

Reproduce the two nested `rez env test_package` resolutions and inspect the rex API, especially the `parent_variable` configuration mentioned in the report and issue #478. Trace how `defined('TEST')` handles inherited variables; done means the second resolution preserves the expected `test:test2` value instead of overwriting it.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.