-
Notifications
You must be signed in to change notification settings - Fork 382
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
[#5960] fix(CLI): Add register and link commands to CLI for model #6066
Conversation
H @justinmclean @tengqm , could you please review this PR when you have time? I’d really appreciate your feedback. |
clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoCommandLine.java
Show resolved
Hide resolved
System.out.println("Successful register " + registeredModel.name() + "."); | ||
} else { | ||
System.err.println("Failed to register model: " + model + "."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two confusions here:
- Do we have a protocol regarding where to output error/info messages?
- Are we always printing something on the command line when some actions were successful?
I am thinking of a scenario where the command line tool is invoked from an upper
layer script. Getting this verbose message are not so "helpful" as we expect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes errors do to standard output and the program should exit with -1. Scripts can check the exit code to see if something worked. Output like this is helpful to users, as if a command has no output, they don't know if it worked or not.
From https://clig.dev:
- Return zero exit code on success, non-zero on failure.
- Send output to stdout.
- Send messaging to stderr.
- Display output on success, but keep it brief.
In this case, I probably wouldn't mention the model name on success, but it is probably OK to do so.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think "display output on success ..." is a common practice.
(venv) tmp $ rm q19.zip
(venv) tmp $ rm q19.zip
rm: q19.zip: No such file or directory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For commands like rm and others that were written 30 or so years ago, they had little output. Thinking about that has changed over those decades. I would suggest we follow the advice in that document. Here it is in full:
"Display output on success, but keep it brief. Traditionally, when nothing is wrong, UNIX commands display no output to the user. This makes sense when they’re being used in scripts, but can make commands appear to be hanging or broken when used by humans. For example, cp will not print anything, even if it takes a long time.
It’s rare that printing nothing at all is the best default behavior, but it’s usually best to err on the side of less."
You note that more modern commands (like git or the GitHub CLI) do output on success and follow this design.
It also suggests that if you want no output, you should add a --quiet flag to do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@justinmclean , Should we add the --quit
option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
--quiet
not --quit
:-) There is no need to add it here, as it would impact many commands. We can add it in another issue/PR if we think it is needed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the --quiet
idea.
I am not a big fan of verbose outputs from commands. For example, when I'm doing gcli get something
, I'm expecting an output which is the data I'm retrieving. I may go further down this road anticipating a --format
option, with which I can dump the output as a JSON. Yes, we can do an --output
to dump/redirect this data. But this is not script friendly.
For commands other than get
or list
, I'm not expecting data from the server.
I'm not expecting an output from the client side tool either (I admit that this is a personal taste and I don't want to argue over this).
The bizarre point is that ... the CLI now has two kinds of outputs.
Sometimes, it produces meaningful (business) data and prints them out
(think the get
, list
case), other times ... it is producing something verbose,
just for the purpose of producing something.
By the way, the cp
command is a synchronous action. It will not return control to
you until it succeeds or fail with an error message. It is not a good example, though I get your points.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have an option for different formats (currently plain and table). However, we would unlikely add a JSON format as the REST interface already provides information in that format. But if there was demand for it or someone wanted to develop that feature, they could. Originally, the CLI prototype was a wrapper on the REST and provided plain text and JSON output, but it was decided to wrap the Java API instead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note it is also recommended that commands that take time to run produce output so the user knows they are doing something. Again, more modern commands like git will do this. We currently don't have any commands that take a long time to run.
clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoCommandLine.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/LinkModel.java
Outdated
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/RegisterModel.java
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/RegisterModel.java
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/GravitinoCommandLine.java
Show resolved
Hide resolved
clients/cli/src/main/java/org/apache/gravitino/cli/commands/RegisterModel.java
Show resolved
Hide resolved
System.out.println("Successful register " + registeredModel.name() + "."); | ||
} else { | ||
System.err.println("Failed to register model: " + model + "."); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think "display output on success ..." is a common practice.
(venv) tmp $ rm q19.zip
(venv) tmp $ rm q19.zip
rm: q19.zip: No such file or directory
74f370e
to
6bafa74
Compare
1. Add register and link commands to CLI for model. 2. Add two option for model --uri and --alias.
6bafa74
to
a0fe9a2
Compare
@justinmclean , I’ve finished updating the code. Please take a look at the PR again when you have time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM thanks again for your contribution.
…el (apache#6066) Add register and link commands to CLI for model - register a model:`model create` - link a model:`model update <—uri uri> [--alias aliaA aliaB]` meantime, add two options - `—uri` :The URI of the model version artifact. - `—alias` :The aliases of the model version. The documentation will be updated after apache#6047 merge and I will create a new issue. Fix: apache#5960 NO ```bash gcli model create -m demo_metalake --name Hive_catalog.default.model gcli model create -m demo_metalake --name Hive_catalog.default.model --comment comment gcli model create -m demo_metalake --name Hive_catalog.default.model --properties key1=val1 key2=val2 gcli model create -m demo_metalake --name Hive_catalog.default.model --properties key1=val1 klinkey2=val2 --comment comment ``` ```bash gcli model update -m demo_metalake --name Hive_catalog.default.model --uri file:///tmp/file gcli model update -m demo_metalake --name Hive_catalog.default.model --uri file:///tmp/file --alias aliasA aliasB gcli model update -m demo_metalake --name Hive_catalog.default.model --uri file:///tmp/file --alias aliasA aliasB --comment comment --properties key1=val1 key2=val2 gcli model update -m demo_metalake --name Hive_catalog.default.model ```
What changes were proposed in this pull request?
Add register and link commands to CLI for model
model create
model update <—uri uri> [--alias aliaA aliaB]
meantime, add two options
—uri
:The URI of the model version artifact.—alias
:The aliases of the model version.The documentation will be updated after #6047 merge and I will create a new issue.
Why are the changes needed?
Fix: #5960
Does this PR introduce any user-facing change?
NO
How was this patch tested?
register test
link test