-
Notifications
You must be signed in to change notification settings - Fork 159
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
feat: expose interface for getting info at building #1267
Comments
/assign |
We had some discussions here #1132 (comment) about the interface. I think it's better to make it as a key-value interface instead of methods. |
What's the advantage of key-value interface? I think this info is not static, thus a method would be suitable. |
@kemingy So that every function can provide such information. For example envdlib can provide |
Do you mean that it's also mutable and can be modified with assignment statements? |
Yes. Something like
|
I like this way, it could act as a hack of lazy-evaluate, if the def get_os():
info_dict = get_build_info()
return info_dict["os"] As it actually convey a copy/value of graph, not reference of graph, people may mistakenly think they can write the graph. Apart from that, we couldn't provide the exact graph, but only parts of it and flatten one, as starlark don't support class/struct. Rather than named As it is a dict of fixed keys, We can use TypedDict for Python type hint: from typing import TypedDict
class Movie(TypedDict):
name: str
year: int
movie: Movie = {'name': 'Blade Runner',
'year': 1982} |
@cutecutecat Actually I think it's fine for the users to write into the key-value graph. For example, some library will depends on tensorrt version, and tensorrt is only provided in envdlib. User may want to check the tensorrt version when installing other libraries |
If we support def build():
base(os="ubuntu18.04", language="python3.8")
info_dict = get_build_graph()
info_dict["os"] = "centos6.5"
info_dict["language"] = "R" If these setters occurs in different extensions, it is difficult to debug where the change happens. I think we should only support Obviously, for env.set('tensorchord.envdlib.tensorrt.version', "1.0")
version = env.get('tensorchord.envdlib.tensorrt.version') and the build graph API likes this: os = env.graph.os() |
There might need more discussion before proceeding this. /unassign |
Some thoughts:
|
Description
We introduce a global module
env
with a getter functionos()
in starlark APIThis can exposed some variables for subsequent building procedure, especially for some library function developing, they can automatically detect
os version
orlanguage
, and be compatible with them without user input these information again.There could be more getters implementation in this module in the future.
Examples
PS. It would be better to be a lazy-evaluate variable
env.os
for design, but starlark doesn't support lazy-evaluate!ref: tensorchord/envdlib#14
Message from the maintainers:
Love this enhancement proposal? Give it a 👍. We prioritise the proposals with the most 👍.
The text was updated successfully, but these errors were encountered: