-
Notifications
You must be signed in to change notification settings - Fork 275
Gradle: python code format/check #1986
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
base: main
Are you sure you want to change the base?
Conversation
Thanks for the example PR! Sorry I missed the discussion earlier, just want to understand more about the motivation behind this. Do we want to add python format check to gradle because we want format issue stops CI before enterring the real test cases? Currently the python workflow can do that via the polaris/.github/workflows/python-client.yml Lines 70 to 73 in b0c85e3
IMHO, the python client should be isolated from the main java project and all the dependency management/test/checking should happen with in that folder via poetry and some other python specific tools. And format failure or test failure should not cause irrelevant CI workflow to fail (e.g. Java Gradle test). This could help make it simpler to maintain python and outer java project. We do have open api client generation configured in gradle now for existing quickstart and regtest, but I hope we could make that automated during package installation: #1885 But please let me know if I miss anything or if there are other good thing about gradle python format check : ) |
I'd like to have the same setup as the rest of the code -- CI fails if you have a format issue, and
It makes sense to use python-specific tooling (ruff?) and to have python-specific commands... but the gradle task We already check the python code in the gradle task Agreed that irrelevant CI shouldn't fail -- but there actually is no CI action called Jave Gradle test... |
@HonahX a bit more context on this PR: While i was checking for what to pick up next, I was not aware we have a Makefile that does this already and noticed the code has a bit free-style. Thus, I ended up ran a manual ruff locally to format the code then check-in the changes (#1954). As part of this PR, @eric-maynard suggests we should automate this as part of check-in as how we are doing today such as spotless apply for formatting java code. Thus, I began explore what options are out there with gradle. It turns out there is no a popular plugin for gradle to work with python (the one from LinkedIn has no new release since 2020). At that points, I really have 2 options:
With option one, i think the main benefit is people don't need to know another command to run (assuming everyone is happy with gradle...personally, makefile is a lot easier to use imo and we can create some very powerful makefile to control various tasks). But the down side comes to this plugin may got outdated or has different dependencies which can cause trouble for our existed build (which is the current case...checking what can be done). That being said, I am fine with any of the approach and also open to new approach. Let me know what you think. |
Thanks @eric-maynard and @MonkeyCanCode for the thorough explanations! I think the idea of adding convenient task in gradle is great. The questions lie more on the practical side that we seems do not have well-maintained/well functioned plugin to do so. Apart from the support problem of the current plugin, I am also a little bit concerned that this Is it possible to make gradle task execute purely command line? Ideally the gradle task could be calling the Makefile target we define here #1995. In this way, we keep the MakeFile approach and also have convenient gradle tasks. Developers can choose whatever approaches they want and yet we only have a single dev environment and all deps are managed by poetry. |
As discussed on the other PR, I will convert this to draft mode. Once the makefile is updated to supports additional functionalities, we can revisit this one. |
Here is a sample PR for enable python code format/check from conclusion derived from #1954 (as it is a sample PR, I didn't update the doc as I would like to get more feedback from community first).
Now with this approach, I am using
use-python
module from gradle to setupruff
which later get uses for code check/format/auto-fix etc. Then based offruff
, I introduced two tasks within gradle for code check and code format.Here is the sample output from the two commands mentioned above that are newly added:
Here are the concerns/questions on my end:
@eric-maynard @HonahX