-
Notifications
You must be signed in to change notification settings - Fork 890
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
feat(framework) Add JSON formatting to flwr ls
output
#4610
base: introduce-json-format
Are you sure you want to change the base?
Conversation
src/py/flwr/cli/ls.py
Outdated
if suppress_output: | ||
restore_output() | ||
e_message = captured_output.getvalue() | ||
_print_json_error(e_message, e) |
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.
Does that mean no exception message will be available in default format?
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.
No, if there're any exceptions in default mode, the errors are not redirected.
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.
But all exceptions are captured, no?
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, but the error messages are not redirected. So the if
statement doesn't affect the default mode.
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 so. All exceptions are captured here, but if you look at the code above, it only captures ValueError
. This approach will suppress all other exceptions. For example, if there’s a gRPC exception when using the stub
object, users will see the exception in --format json
mode, but nothing will appear in the default mode. See below:
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.
_print_json_error(e_message, e) | |
_print_json_error(e_message, e) | |
else: | |
raise |
Console().print_json( | ||
json.dumps( | ||
{ | ||
"success": "false", |
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.
"success": "false", | |
"success": False, |
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.
Shouldn't it be a true bool
?
Merge afte #4613