Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add optionvars #1036

Merged
merged 4 commits into from
Mar 30, 2021
Merged

Conversation

davidlatwe
Copy link
Contributor

Feature propose

Add rezconfig.optionvars to store arbitrary key-value data and retrieve them in package.

# rezconfig.py
optionvars = {
    "hello": "world"
}
# package.py
name = "foo"
def commands():
    print(optionvars("hello"))
> rez-env foo
world

Use case

I currently would use this feature to setup local payload path for package development across developer machines.

# package.py
name = "foo"
def commands():
    if intersects(ephemerals.get("dev.foo", "dev.foo-0"), "1"):
        env.PYTHONPATH.append(optionvars("foo_dev_src"))
    else:
        env.PYTHONPATH.append("{root}/payload")

I know my use case could have many alternatives, but I thought this would be the most convenient approach with ephemeral packages and rezconfig involved.

What do you think ?

@davidlatwe
Copy link
Contributor Author

davidlatwe commented Mar 8, 2021

Just to be more clearer.

The main idea of this feature, is like adding user preferences on package or the value of corresponding ephemeral, which may not easy to define in package's definition file due to the differences between machines/users/pipeline-roles.

Although we can define those as environment variables in a shell launching script, but I think it would be better if those can be managed by rezconfig, and traced with rez-config command. In result, the startup environment can be simplified.

@nerdvegas
Copy link
Contributor

What if we were just to expose the config object instead? I like this idea as it may be helpful to expose other exisitng config settings; but also a studio isn't forced to use a specific optionvars key and could instead choose their own.

@davidlatwe
Copy link
Contributor Author

Thanks !!

isn't forced to use a specific optionvars key and could instead choose their own.

Not sure I understand this, do you mean that one could pick their own name instead of "optionvars" ?
If so, I think we cannot do this actually, rezconfig only accept key that is in it's schema.

@nerdvegas
Copy link
Contributor

nerdvegas commented Mar 9, 2021 via email

src/rez/rex.py Outdated Show resolved Hide resolved
@davidlatwe
Copy link
Contributor Author

Great, thanks !
Will start updating Wiki doc for this.

@nerdvegas
Copy link
Contributor

Note that when updating the wiki, you need a section in https://github.com/nerdvegas/rez/wiki/Package-Commands#objects. In this case I think it'd be fine for that to be very brief and link to the optionvars section in Configuring-Rez. Something like

### optionvars
*Function*

Arbitrary data from the rez config, that can be accessed by packages. See the [config setting](...) for more details.

@davidlatwe
Copy link
Contributor Author

Thanks for the hints @nerdvegas.
Wiki updated. :)

@davidlatwe
Copy link
Contributor Author

Just checking, is this able to be merged ?

@nerdvegas
Copy link
Contributor

nerdvegas commented Mar 24, 2021 via email

@nerdvegas nerdvegas merged commit 3b09d60 into AcademySoftwareFoundation:master Mar 30, 2021
@davidlatwe davidlatwe deleted the optionvars branch March 30, 2021 03:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants