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

feat: config codegen #4378

Closed
wants to merge 33 commits into from
Closed

feat: config codegen #4378

wants to merge 33 commits into from

Conversation

tisonkun
Copy link
Member

Let's see if we'd like to go in this way.

tisonkun added 10 commits March 18, 2024 22:56
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]>
@Xuanwo
Copy link
Member

Xuanwo commented Mar 19, 2024

I don't find writing in Go appealing, especially since almost all of our dev related scripts are written in python.

@tisonkun
Copy link
Member Author

@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]>
@tisonkun
Copy link
Member Author

@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:
Copy link
Member Author

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.

@tisonkun
Copy link
Member Author

Follow up -

  • Tracking issues to convert other configs in this pattern.
  • Work on generate code for Java / Python / ...

cc @Xuanwo @PsiACE

Run the following command to generate service config files:

```bash
pdm genconfig
Copy link
Member

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.

Copy link
Member Author

@tisonkun tisonkun Mar 19, 2024

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.

Copy link
Member Author

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.

Copy link
Member

@Xuanwo Xuanwo Mar 19, 2024

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?

Copy link
Member

@Xuanwo Xuanwo Mar 19, 2024

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.

Copy link
Member

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.

Copy link
Member Author

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.

Copy link
Member

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

@Xuanwo Xuanwo marked this pull request as draft March 19, 2024 11:56
@tisonkun
Copy link
Member Author

tisonkun commented Mar 20, 2024

scripts/ is written with a mindset used standalone.

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.

@tisonkun tisonkun closed this Mar 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants