-
Notifications
You must be signed in to change notification settings - Fork 448
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
Go Templates are hard to work with programmatically #857
Comments
@jlewi I think, Parameter substitutions can be worked out by exposing params like |
@johnugeorge why does supporting other job types necessitate the use of GO Templates? Could we come up with a substitution style that down't neccesarily break with yaml parsing; maybe this is already doable and its just a matter of document it? For example suppose the spec was
This string is valid YAML; e.g. you can do
So its easy to programmatically modify the yaml and then dump the yaml before setting the template. Maybe that's already doable today? I guess the question is can a user refer by name to the value of a hyperparameter as opposed to doing a loop over the hyperparameters ? |
I get what you are trying to do. I was trying to say that I couldn't find any alternative other than keeping trial spec as string(though not the best user experience) . With respect to your suggestion to make spec as yaml, I feel that it is possible to implement it. Currently, it is bit tricky because hyper parameters is variable number of key-value pairs. We will need to have our own parameter substitution mechanism(like Tekton) to support the loop over them. We can figure out a solution in the beta api release |
@johnugeorge Do go templates allow referring to hyperparameters by name e.g. can I do something like this
So in my go template I don't need to iterate over the hyperameters. As the author of the Experiment I already have to know the names of my hyper parameters because I have to list them in my Experiment. So If I can explicitly to the hyparameters by name in the go template then I think its possible to still use go templates and produce valid YAML. |
@gaocegege @johnugeorge |
SGTM. Actually, I have researched if we could inject hyperparameters by rewriting Python AST. NNI follows this way. I think it is better to be extensible. We could support multiples approaches. |
yes, AST can be one another |
We can close this, we are using new Trial template now: #1208 |
Issue-Label Bot is automatically applying the labels:
Please mark this comment with 👍 or 👎 to give our bot feedback! |
1 similar comment
Issue-Label Bot is automatically applying the labels:
Please mark this comment with 👍 or 👎 to give our bot feedback! |
/kind feature
Describe the solution you'd like
Katib currently uses go templates to define the training jobs. In the random example
katib/examples/v1alpha2/random-example.yaml
Line 20 in 4e96b94
The training job template is set to
The problem with using go templates is that the manifest is no longer valid yaml. So you can't parse the YAML spec in python and then manipulate that object programmatically.
Consider the following example
Typically we would just define the K8s object a python dictionary and then we can easily set the image.
However, because the training job in the case of katib is a go template we can no longer parse it into a dictionary, manipulate it and then serialize it to YAML.
It might be worth looking at Tekton to see how it does parameter substitution since Tekton objects are valid YAML.
/cc @johnugeorge @richardsliu
The text was updated successfully, but these errors were encountered: