-
Notifications
You must be signed in to change notification settings - Fork 523
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: config codegen #4378
feat: config codegen #4378
Conversation
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
I don't find writing in Go appealing, especially since almost all of our dev related scripts are written in python. |
@Xuanwo think of it a typed Python script. Better than untyped toml strings.. But maybe I can port all these things into Python with Jinja template or sth. Just no untyped toml, we can write the schema in code. Newer Python can be typed also. |
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
@Xuanwo finished to Python. |
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
Signed-off-by: tison <[email protected]>
########### | ||
# RustGen # | ||
########### | ||
def rust_type(self) -> str: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know what's the idiom to group methods. In Golang, receiver methods can scatter in multiple files. In Python, perhaps we need some design pattern like "XlangConfig(Field)Generator" and take "Config(Field)" a parameter.
Signed-off-by: tison <[email protected]>
Run the following command to generate service config files: | ||
|
||
```bash | ||
pdm genconfig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm opposed to installing tools like pdm
. In fact, I want to avoid adding any new dependencies. We don't need to package/release/dist it. I expect this code generation can be executed with a simple python3 xxx.py
, just like all other scripts. Thus I prefer to keep it inside scripts
.
Or we can make scripts
as a whole new package that managed as a real python project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I want to avoid adding any new dependencies.
This is strange. It means we recreate many utilities by hand.
Code generator isn't such a trivial thing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Or we can make scripts as a whole new package that managed as a real python project.
This is possible. Or call it tools
/pytools
. I suppose we'd have some handy scripts may be not in Python (or Python is not a good fit).
Firstly I'd make a consensus that write a code generator without any 3rdparty will end up with write every utility by hand and it's even .. stupid.
Then we back to the naming issue about how we call the current "codegen" folder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firstly I'd make a consensus that write a code generator without any 3rdparty will end up with write every utility by hand and it's even .. stupid.
Agrees.
Then we back to the naming issue about how we call the current "codegen" folder.
We can merge current scripts
and codegen
into one tools
or odev
.
And maybe we can use the same entry point: odev
?
Having a odev --help
maybe make it easier to discover?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And maybe we can use the same entry point:
odev
?
This is much furthur on current codebase. We can start with treating tools
as a python project first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I plan to generate more codes for S3Builder
. Therefore, I prefer to maintain them separately in each service rather than composing everything into one large config.rs
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is possible. So we keep generate the S3 config to core/src/service/s3/?
.
Maybe you have some inputs about the layout. I'm open to this point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can have core/src/service/${service}/generated.rs
. It's also fine to me to have core/src/service/${service}/config.generated.rs
Forcely combine it with our current work is strange and extremely dirty. We're merging two irrelevant things while implementing one of it in a single PR. If we don't collaborate but rush alone and fix it, it's possible. But now we're trying to review it; then it won't work or just blindly merge. I don't want to do this. |
Let's see if we'd like to go in this way.