-
-
Notifications
You must be signed in to change notification settings - Fork 331
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
Improved show
output to be valid JSON and added showNamed
#1765
Conversation
Fix com-lihaoyi#1763 To implement this, I needed to enlarge the result values of some evaluate methods to also contain the task name. I was uncreative and just added a "1" to the existing methods. Any suggestions for better names are much appreciated. Review by @lolgab, @daddykotex
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.
Can you add a test that checks the newly generated JSON structure?
Changed `evaluateTasks1` to also return the underlying result.
(res._1, res._2.map(_.map(p => (p._1, p._2.map(_._2))))) | ||
val (watched, results) = evaluate1(evaluator, targets) | ||
// we drop the task name in the inner tuple | ||
(watched, results.map(_.map(p => (p._1, p._2.map(_._2))))) |
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.
You could also assign names in the map
and avoid p._1
and p._2
@lefou could you update the PR description to give an example before and after of what the |
Done |
My concerns are addressed but didn't review it thoroughly yet.
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.
Great work, thanks for resolving this so quickly
I think this looks reasonable to me for the multi-target use case. One thing that worries me is that for running If we assume that |
in my use case, I have no need for the task(s) name in the json, as I said I can on target on multiple module, so I know what's coming out of the json but if you can send multiple targets like personally, I would just run |
Ok, yeah, looks like I hit a nerve here. (The thing with assumptions is, well, ... Here is some funny pic about someone using your product: https://twitter.com/WdeB/status/1482798979511373828, haha) I can imagine lots of different ways to address. Yet, I'd like to have a rather small solution, which is also backwards compatible, so here is a compromise:
WDYT? |
If none of us already has "some python script" that does parse the output of |
@lefou what you propose sounds good to me. I'd prefer single results appear alone, but I can see the arguments either way. |
I now implemented it and update the PR description. I will add it to the documentation later, too. Anyone who has a better suggestion to the new |
show
output to contain the task names and be valid JSONshow
output to be valid JSON and added showNamed
I'm done with editing, unless you have another objection. |
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.
Perfect for me
Co-authored-by: David Francoeur <dfrancoeur04@gmail.com>
Currently, show invoked with more than one target returns invalid JSON, as it is only concatenating multiple JSON values.
Example:
This PR makes its output valid JSON by outputting a proper JSON array when there is more than one task result.
Example:
Also it introduces a new
showNamed
command, which puts each task result in a JSON dictionary. The keys are reflecting the task names.Example:
This makes the output of
show
andshowNamed
much more usable. For humans it's easier to recognize, which task outputted what, and for external tools, as they now can process themill show
output as-is.Fix #1763
To implement this, I needed to enlarge the result values of some
evaluate methods to also contain the task name, so I added new methods.
These now also transport the actual result value in addition to the watched paths.
I was uncreative and just added a "1" to the existing methods names.
Any suggestions for better names are much appreciated.
I also took the opportunity to let
show
andshowNamed
return their result.