-
Notifications
You must be signed in to change notification settings - Fork 24
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
[Question] [API] How can i get all params (option function call) from the kcl code #254
Comments
At present, it is not possible to obtain the value of prod for all options mixed in the code snippet. However, we construct a schema to represent all variables through the code structure, similar to this
Then obtain the document of the |
Additionally, could you please provide me with more specific scenarios and use cases? So that we can identify some best practices. |
I am developing a template system to process yaml files in our release process. The current tech stack is python+jinjia2. First, a jinjia template is defined, and then we use the following code to get the variables in the template:
The code above gets the keys of the variables in jinja, and then completes the assignment of the keys through some logic, and finally renders the template and submits it. Therefore, if I want to switch to kcl, I need kcl to provide the same capability to get the variables defined in the template. |
I see. In our current template abstraction system, we always define a |
How can I get the variable information defined in the schema in the KCL model, just like I use regular filtering of variable names in jinjia?
|
There are two ways
|
Both of these methods seem to have a high threshold. I understand that parsing variables from templates is something that must be done before rendering, but why don't cue and kcl provide direct APIs for accessing them? |
Make sense. For example, in KCL, if you want to directly use a certain parameter or API, such as |
yes ! |
All right. Actually, we already have such an implementation within KCL at present https://github.com/kcl-lang/kcl/blob/main/kclvm/runtime/src/api/kclvm.rs#L270 However, due to bandwidth limitations, we have not yet exposed higher level APIs, and perhaps we may support such API calls next week. |
We've release kcl-go v0.8.1 See this function https://github.com/kcl-lang/kcl-go/blob/main/pkg/loader/options.go#L12 and examples https://github.com/kcl-lang/kcl-go/blob/main/pkg/loader/options_test.go#L8 to get all params (function |
![]() |
Sorry, we are working hard on lighter KCL. 🙏 kcl-lang/kcl#291 |
![]() ![]()
Eroor func not exist! |
Sorry, can you run |
Make sense. I suggest deleting all KCL related legacy files including |
I noticed that I replied under a topic that has already been closed. Do I need to create a new issue? |
Just here, although this should be an installation issue. |
It worked after I deleted the local kcl. It seems that there is logic that prioritizes using the kcl within the path. |
kclcode
output The default value, type, and required value should not all be empty. Its right show? |
Yes, the default logic uses KCL in PATH, but it can be set through additional environment variables. I am refactoring this logic to make it easier to control through code. See the issue: #257 |
This is the correct logic. The option function is not mandatory by default, and you can set additional parameters for it. e.g.
|
The simple demo package is 90MB in size, which seems a bit large. |
Sorry, we are working hard on lighter KCL. 🙏 kcl-lang/kcl#291 It is expected that the size will be reduced by half by then. This is because we used LLVM for AOT compilation for performance and compilation caching, which resulted in unfriendly cross platform, and therefore included the binary size of all platforms in KCL Go SDK. |
That’s excellent; thank you to the KCL team for your hard work. |
for example,i have a kclfile
how to get a params list :
env str default is "prod"
The text was updated successfully, but these errors were encountered: