This is an automated email from the ASF dual-hosted git repository.
rexxiong pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/celeborn.git
The following commit(s) were added to refs/heads/main by this push:
new 68f32303c [CELEBORN-1572][FOLLOWUP] Support to show Celeborn CLI
version for sub command
68f32303c is described below
commit 68f32303cdfbbce812fa4b8a79233de3c1bd0219
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
### What changes were proposed in this pull request?
Support to show Celeborn CLI version for sub command.
### Why are the changes needed?
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]
...
```
### Does this PR introduce _any_ user-facing change?
No.
### How was this patch tested?
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]>
---
.../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 | 5 ++---
.../celeborn/cli/worker/WorkerSubcommand.scala | 4 ++--
.../celeborn/cli/worker/WorkerSubcommandImpl.scala | 4 ++--
.../celeborn/cli/TestCelebornCliCommands.scala | 7 +++++++
7 files changed, 40 insertions(+), 13 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 a688930ca..ee195cd60 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 ed16c0d84..ce0fa22c5 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
@@ -20,7 +20,6 @@ package org.apache.celeborn.cli.master
import java.util
import scala.collection.JavaConverters._
-import scala.util.Try
import org.apache.commons.lang3.StringUtils
import picocli.CommandLine.{Command, ParameterException}
@@ -29,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 45b7b766f..5f8ceda89 100644
--- a/cli/src/test/scala/org/apache/celeborn/cli/TestCelebornCliCommands.scala
+++ b/cli/src/test/scala/org/apache/celeborn/cli/TestCelebornCliCommands.scala
@@ -305,6 +305,13 @@ class TestCelebornCliCommands extends CelebornFunSuite
with MiniClusterFeature {
captureErrorAndValidateResponse(args, "Invalid timestamp for worker")
}
+ 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",