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

rexxiong pushed a commit to branch branch-0.6
in repository https://gitbox.apache.org/repos/asf/celeborn.git


The following commit(s) were added to refs/heads/branch-0.6 by this push:
     new d2982e574 [CELEBORN-1572][FOLLOWUP] Support to show Celeborn CLI 
version for sub command
d2982e574 is described below

commit d2982e5743395060c0c457c3f1081a41ed94a2e2
Author: Wang, Fei <[email protected]>
AuthorDate: Wed Jun 11 14:00:20 2025 +0800

    [CELEBORN-1572][FOLLOWUP] Support to show Celeborn CLI version for sub 
command
    
    Support to show Celeborn CLI version for sub command.
    
    celeborn-cli [master|worker] -V does not show anything.
    
    ```
    (base) ➜  apache-celeborn-0.6.0-bin-ebay ./sbin/celeborn-cli -V
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further 
details.
    Celeborn CLI - Celeborn 0.6.0
    (base) ➜  apache-celeborn-0.6.0-bin-ebay ./sbin/celeborn-cli -V
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further 
details.
    Celeborn CLI - Celeborn 0.6.0
    (base) ➜  apache-celeborn-0.6.0-bin-ebay ./sbin/celeborn-cli master -V
    (base) ➜  apache-celeborn-0.6.0-bin-ebay ./sbin/celeborn-cli worker -V
    (base) ➜  apache-celeborn-0.6.0-bin-ebay ./sbin/celeborn-cli master -h
    Usage: celeborn-cli master [-hV] [--apps=appId] [--auth-header=authHeader]
    ...
    (base) ➜  apache-celeborn-0.6.0-bin-ebay ./sbin/celeborn-cli worker -h
    Usage: celeborn-cli worker [-hV] [--apps=appId] [--auth-header=authHeader]
    ...
    ```
    
    No.
    
    UT.
    
    ```
    (base) ➜  celeborn git:(cli_version) ./dist/sbin/celeborn-cli -V
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further 
details.
    Celeborn CLI - Celeborn 0.7.0-SNAPSHOT
    (base) ➜  celeborn git:(cli_version) ./dist/sbin/celeborn-cli master -V
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further 
details.
    Celeborn CLI - Celeborn 0.7.0-SNAPSHOT
    (base) ➜  celeborn git:(cli_version) ./dist/sbin/celeborn-cli worker -V
    SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
    SLF4J: Defaulting to no-operation (NOP) logger implementation
    SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further 
details.
    Celeborn CLI - Celeborn 0.7.0-SNAPSHOT
    (base) ➜  celeborn git:(cli_version)
    
    ```
    
    Closes #3321 from turboFei/cli_version.
    
    Authored-by: Wang, Fei <[email protected]>
    Signed-off-by: Shuang <[email protected]>
    (cherry picked from commit 68f32303cdfbbce812fa4b8a79233de3c1bd0219)
    Signed-off-by: Shuang <[email protected]>
---
 .../org/apache/celeborn/cli/CelebornCli.scala      |  6 ++----
 .../apache/celeborn/cli/common/BaseCommand.scala   | 23 ++++++++++++++++++++++
 .../celeborn/cli/master/MasterSubcommand.scala     |  4 ++--
 .../celeborn/cli/master/MasterSubcommandImpl.scala |  4 ++--
 .../celeborn/cli/worker/WorkerSubcommand.scala     |  4 ++--
 .../celeborn/cli/worker/WorkerSubcommandImpl.scala |  4 ++--
 .../celeborn/cli/TestCelebornCliCommands.scala     |  7 +++++++
 7 files changed, 40 insertions(+), 12 deletions(-)

diff --git a/cli/src/main/scala/org/apache/celeborn/cli/CelebornCli.scala 
b/cli/src/main/scala/org/apache/celeborn/cli/CelebornCli.scala
index fb2081d7f..e1b9444ae 100644
--- a/cli/src/main/scala/org/apache/celeborn/cli/CelebornCli.scala
+++ b/cli/src/main/scala/org/apache/celeborn/cli/CelebornCli.scala
@@ -19,18 +19,16 @@ package org.apache.celeborn.cli
 import picocli.CommandLine
 import picocli.CommandLine.Command
 
-import org.apache.celeborn.cli.common.{CliLogging, CliVersionProvider}
+import org.apache.celeborn.cli.common.BaseCommand
 import org.apache.celeborn.cli.master.MasterSubcommandImpl
 import org.apache.celeborn.cli.worker.WorkerSubcommandImpl
 @Command(
   name = "celeborn-cli",
-  versionProvider = classOf[CliVersionProvider],
-  mixinStandardHelpOptions = true,
   description = Array("@|bold Scala|@ Celeborn CLI"),
   subcommands = Array(
     classOf[MasterSubcommandImpl],
     classOf[WorkerSubcommandImpl]))
-class CelebornCli extends Runnable with CliLogging {
+class CelebornCli extends BaseCommand {
   override def run(): Unit = {
     logError(
       "Master or Worker subcommand needs to be provided. Please run -h to see 
the usage info.")
diff --git 
a/cli/src/main/scala/org/apache/celeborn/cli/common/BaseCommand.scala 
b/cli/src/main/scala/org/apache/celeborn/cli/common/BaseCommand.scala
new file mode 100644
index 000000000..6e2866a39
--- /dev/null
+++ b/cli/src/main/scala/org/apache/celeborn/cli/common/BaseCommand.scala
@@ -0,0 +1,23 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *    http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.celeborn.cli.common
+
+import picocli.CommandLine.Command
+
+@Command(mixinStandardHelpOptions = true, versionProvider = 
classOf[CliVersionProvider])
+abstract class BaseCommand extends Runnable with CliLogging {}
diff --git 
a/cli/src/main/scala/org/apache/celeborn/cli/master/MasterSubcommand.scala 
b/cli/src/main/scala/org/apache/celeborn/cli/master/MasterSubcommand.scala
index d976f0c6b..5f1af3357 100644
--- a/cli/src/main/scala/org/apache/celeborn/cli/master/MasterSubcommand.scala
+++ b/cli/src/main/scala/org/apache/celeborn/cli/master/MasterSubcommand.scala
@@ -23,13 +23,13 @@ import picocli.CommandLine.{ArgGroup, Mixin, 
ParameterException, ParentCommand,
 import picocli.CommandLine.Model.CommandSpec
 
 import org.apache.celeborn.cli.CelebornCli
-import org.apache.celeborn.cli.common.{CliLogging, CommonOptions}
+import org.apache.celeborn.cli.common.{BaseCommand, CliLogging, CommonOptions}
 import org.apache.celeborn.cli.config.CliConfigManager
 import org.apache.celeborn.rest.v1.master.{ApplicationApi, ConfApi, 
DefaultApi, MasterApi, ShuffleApi, WorkerApi}
 import org.apache.celeborn.rest.v1.master.invoker.ApiClient
 import org.apache.celeborn.rest.v1.model._
 
-trait MasterSubcommand extends CliLogging {
+trait MasterSubcommand extends BaseCommand {
 
   @ParentCommand
   private var celebornCli: CelebornCli = _
diff --git 
a/cli/src/main/scala/org/apache/celeborn/cli/master/MasterSubcommandImpl.scala 
b/cli/src/main/scala/org/apache/celeborn/cli/master/MasterSubcommandImpl.scala
index c32b95bbc..d599dd8f2 100644
--- 
a/cli/src/main/scala/org/apache/celeborn/cli/master/MasterSubcommandImpl.scala
+++ 
b/cli/src/main/scala/org/apache/celeborn/cli/master/MasterSubcommandImpl.scala
@@ -28,8 +28,8 @@ import org.apache.celeborn.cli.config.CliConfigManager
 import org.apache.celeborn.rest.v1.model._
 import org.apache.celeborn.rest.v1.model.SendWorkerEventRequest.EventTypeEnum
 
-@Command(name = "master", mixinStandardHelpOptions = true)
-class MasterSubcommandImpl extends Runnable with MasterSubcommand {
+@Command(name = "master")
+class MasterSubcommandImpl extends MasterSubcommand {
   override def run(): Unit = {
     if (masterOptions.showMastersInfo) log(runShowMastersInfo)
     if (masterOptions.showClusterApps) log(runShowClusterApps)
diff --git 
a/cli/src/main/scala/org/apache/celeborn/cli/worker/WorkerSubcommand.scala 
b/cli/src/main/scala/org/apache/celeborn/cli/worker/WorkerSubcommand.scala
index 204a9c896..5463ec59e 100644
--- a/cli/src/main/scala/org/apache/celeborn/cli/worker/WorkerSubcommand.scala
+++ b/cli/src/main/scala/org/apache/celeborn/cli/worker/WorkerSubcommand.scala
@@ -21,12 +21,12 @@ import picocli.CommandLine.{ArgGroup, Mixin, 
ParameterException, ParentCommand,
 import picocli.CommandLine.Model.CommandSpec
 
 import org.apache.celeborn.cli.CelebornCli
-import org.apache.celeborn.cli.common.{CliLogging, CommonOptions}
+import org.apache.celeborn.cli.common.{BaseCommand, CliLogging, CommonOptions}
 import org.apache.celeborn.rest.v1.model._
 import org.apache.celeborn.rest.v1.worker.{ApplicationApi, ConfApi, 
DefaultApi, ShuffleApi, WorkerApi}
 import org.apache.celeborn.rest.v1.worker.invoker.ApiClient
 
-trait WorkerSubcommand extends CliLogging {
+trait WorkerSubcommand extends BaseCommand {
 
   @ParentCommand
   private var celebornCli: CelebornCli = _
diff --git 
a/cli/src/main/scala/org/apache/celeborn/cli/worker/WorkerSubcommandImpl.scala 
b/cli/src/main/scala/org/apache/celeborn/cli/worker/WorkerSubcommandImpl.scala
index c459e5b4e..a06136fad 100644
--- 
a/cli/src/main/scala/org/apache/celeborn/cli/worker/WorkerSubcommandImpl.scala
+++ 
b/cli/src/main/scala/org/apache/celeborn/cli/worker/WorkerSubcommandImpl.scala
@@ -22,8 +22,8 @@ import picocli.CommandLine.Command
 import org.apache.celeborn.rest.v1.model._
 import org.apache.celeborn.rest.v1.model.WorkerExitRequest.TypeEnum
 
-@Command(name = "worker", mixinStandardHelpOptions = true)
-class WorkerSubcommandImpl extends Runnable with WorkerSubcommand {
+@Command(name = "worker")
+class WorkerSubcommandImpl extends WorkerSubcommand {
 
   override def run(): Unit = {
     if (workerOptions.showWorkerInfo) log(runShowWorkerInfo)
diff --git 
a/cli/src/test/scala/org/apache/celeborn/cli/TestCelebornCliCommands.scala 
b/cli/src/test/scala/org/apache/celeborn/cli/TestCelebornCliCommands.scala
index e47d8cec7..eb8093796 100644
--- a/cli/src/test/scala/org/apache/celeborn/cli/TestCelebornCliCommands.scala
+++ b/cli/src/test/scala/org/apache/celeborn/cli/TestCelebornCliCommands.scala
@@ -291,6 +291,13 @@ class TestCelebornCliCommands extends CelebornFunSuite 
with MiniClusterFeature {
     captureOutputAndValidateResponse(args, "success: true")
   }
 
+  test("--version") {
+    val versionInfo = "Could not resolve version of Celeborn since no RELEASE 
file was found"
+    captureOutputAndValidateResponse(Array("--version"), versionInfo)
+    captureOutputAndValidateResponse(Array("master", "--version"), versionInfo)
+    captureOutputAndValidateResponse(Array("worker", "--version"), versionInfo)
+  }
+
   private def prepareMasterArgs(): Array[String] = {
     Array(
       "master",

Reply via email to