You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gravitino.apache.org by gi...@apache.org on 2026/08/27 06:09:44 UTC

(gravitino) branch cherry-pick-3604c670-to-branch-1.3 created (now facc217c3e)

This is an automated email from the ASF dual-hosted git repository.

github-actions[bot] pushed a change to branch cherry-pick-3604c670-to-branch-1.3
in repository https://gitbox.apache.org/repos/asf/gravitino.git


      at facc217c3e [#12660] fix(mcp-server): Invoke isort/black console scripts and pin their versions (#12661)

This branch includes the following new commits:

     new facc217c3e [#12660] fix(mcp-server): Invoke isort/black console scripts and pin their versions (#12661)

The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.



(gravitino) 01/01: [#12660] fix(mcp-server): Invoke isort/black console scripts and pin their versions (#12661)

Posted by gi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

github-actions[bot] pushed a commit to branch cherry-pick-3604c670-to-branch-1.3
in repository https://gitbox.apache.org/repos/asf/gravitino.git

commit facc217c3e73c429eebd4bcf0da3d039ae05b5bf
Author: Qi Yu <yu...@datastrato.com>
AuthorDate: Thu Aug 27 14:09:10 2026 +0800

    [#12660] fix(mcp-server): Invoke isort/black console scripts and pin their versions (#12661)
    
    ### What changes were proposed in this pull request?
    
    In `mcp-server/build.gradle.kts`:
    
    1. Invoke the formatters through their venv console scripts
    (`.venv/bin/isort`, `.venv/bin/black`) instead of `python -m <tool>`,
    via a small `venvExecutable(name)` helper that mirrors the existing
    `venvPython` Windows/POSIX handling.
    2. Pin the installed versions (`black==26.5.1`, `isort==9.0.0`) instead
    of installing them unconstrained.
    
    ### Why are the changes needed?
    
    `isort` 9.0.0 no longer ships an `isort/__main__.py`, so `python -m
    isort` fails outright:
    
    ```
    .venv/bin/python: No code object available for isort.__main__;
    'isort' is a package and cannot be directly executed
    > Task :mcp-server:formatCheckPython FAILED
    ```
    
    `installFormatTools` installed `black` and `isort` without version
    constraints, so CI resolved the new release as soon as it was published
    and every job that runs `formatCheckPython` started failing — including
    the backend integration test jobs, which run the check before the tests.
    Pinning also keeps a future `black` release from silently changing the
    format check outcome.
    
    Fix: #12660
    
    ### Does this PR introduce _any_ user-facing change?
    
    No.
    
    ### How was this patch tested?
    
    Locally on a clean venv:
    
    - `./gradlew :mcp-server:formatCheckPython` — BUILD SUCCESSFUL (`80
    files would be left unchanged`); fails on `main` with the error above.
    - `./gradlew :mcp-server:formatApplyPython` — BUILD SUCCESSFUL, no files
    modified.
---
 mcp-server/build.gradle.kts | 32 ++++++++++++++++++++++----------
 1 file changed, 22 insertions(+), 10 deletions(-)

diff --git a/mcp-server/build.gradle.kts b/mcp-server/build.gradle.kts
index fe773fcf62..9bc51ad8e6 100644
--- a/mcp-server/build.gradle.kts
+++ b/mcp-server/build.gradle.kts
@@ -39,13 +39,21 @@ fun getUvExecutable(): String {
   }
 }
 
-val venvPython = when {
+// The formatters are invoked through their console scripts rather than `python -m <tool>`:
+// isort 9 no longer ships an `__main__` module, so `python -m isort` cannot be executed.
+fun venvExecutable(name: String): String = when {
   System.getProperty("os.name").contains("win", ignoreCase = true) ->
-    venvDir.resolve("Scripts/python.exe").absolutePath
+    venvDir.resolve("Scripts/$name.exe").absolutePath
   else ->
-    venvDir.resolve("bin/python").absolutePath
+    venvDir.resolve("bin/$name").absolutePath
 }
 
+val venvPython = venvExecutable("python")
+
+// Pinned so that a new formatter release cannot change the outcome of the format check in CI.
+val blackRequirement = "black==26.5.1"
+val isortRequirement = "isort==9.0.0"
+
 tasks {
   register<Exec>("installUv") {
     group = "python"
@@ -160,7 +168,7 @@ tasks {
     workingDir(pythonProjectDir)
 
     doFirst {
-      commandLine(getUvExecutable(), "pip", "install", "--python", venvPython, "black", "isort")
+      commandLine(getUvExecutable(), "pip", "install", "--python", venvPython, blackRequirement, isortRequirement)
     }
 
     doLast {
@@ -213,13 +221,13 @@ tasks {
       // Apply isort
       exec {
         workingDir = pythonProjectDir
-        commandLine(venvPython, "-m", "isort", "mcp_server", "tests")
+        commandLine(venvExecutable("isort"), "mcp_server", "tests")
       }
 
       // Apply Black
       exec {
         workingDir = pythonProjectDir
-        commandLine(venvPython, "-m", "black", "mcp_server", "tests")
+        commandLine(venvExecutable("black"), "mcp_server", "tests")
       }
 
       logger.lifecycle("Python formatting applied (isort + Black)")
@@ -234,8 +242,10 @@ tasks {
     doLast {
       val isortExitCode = exec {
         workingDir = pythonProjectDir
-        commandLine(venvPython, "-m", "isort", "--check", "mcp_server", "tests")
-        isIgnoreExitValue = false
+        commandLine(venvExecutable("isort"), "--check", "mcp_server", "tests")
+        // Let the exit code reach the check below, so the failure is reported with the message
+        // that names the tool instead of a bare Gradle ExecException.
+        isIgnoreExitValue = true
       }.exitValue
 
       if (isortExitCode != 0) {
@@ -244,8 +254,10 @@ tasks {
 
       val blackExitCode = exec {
         workingDir = pythonProjectDir
-        commandLine(venvPython, "-m", "black", "--check", "mcp_server", "tests")
-        isIgnoreExitValue = false
+        commandLine(venvExecutable("black"), "--check", "mcp_server", "tests")
+        // Let the exit code reach the check below, so the failure is reported with the message
+        // that names the tool instead of a bare Gradle ExecException.
+        isIgnoreExitValue = true
       }.exitValue
 
       if (blackExitCode != 0) {