-
Notifications
You must be signed in to change notification settings - Fork 2
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
Add custom formatter conversion flags and colors based on datalad ls #183
Conversation
In principle works, here is current outputs ❯ duct sleep 2 2024-09-20T10:16:52-0400 [INFO ] con-duct: duct is executing 'sleep 2'... 2024-09-20T10:16:52-0400 [INFO ] con-duct: Log files will be written to .duct/logs/2024.09.20T10.16.52-182670_ 2024-09-20T10:16:54-0400 [INFO ] con-duct: Summary: Exit Code: 0 Command: sleep 2 Log files location: .duct/logs/2024.09.20T10.16.52-182670_ Wall Clock Time: 2.001 sec Memory Peak Usage (RSS): 2.0 MB Memory Average Usage (RSS): 2.0 MB Virtual Memory Peak Usage (VSZ): 5.7 MB Virtual Memory Average Usage (VSZ): 5.7 MB Memory Peak Percentage: 0.0% Memory Average Percentage: 0.0% CPU Peak Usage: 0.0% Average CPU Usage: 0.0% Samples Collected: 3 Reports Written: 2 ❯ duct echo 1 2024-09-20T10:16:58-0400 [INFO ] con-duct: duct is executing 'echo 1'... 2024-09-20T10:16:58-0400 [INFO ] con-duct: Log files will be written to .duct/logs/2024.09.20T10.16.58-182729_ 1 2024-09-20T10:16:58-0400 [INFO ] con-duct: Summary: Exit Code: 0 Command: echo 1 Log files location: .duct/logs/2024.09.20T10.16.58-182729_ Wall Clock Time: 0.001 sec Memory Peak Usage (RSS): - Memory Average Usage (RSS): - Virtual Memory Peak Usage (VSZ): - Virtual Memory Average Usage (VSZ): - Memory Peak Percentage: ✗% Memory Average Percentage: ✗% CPU Peak Usage: ✗% Average CPU Usage: ✗% Samples Collected: 0 Reports Written: 1
…efix into format string
Rather than replace everywehere, just use concise super()
>80% doesnt work for CPU, which caps at num_cores*100% Instead lets extend X, which will give us red with no measurement or 0 green for a measurement
No measurement should be red, but 0 should be green
Next up, need to add lots of tests. |
Unicode is just sugar, not worth the risk it might blow up on some system.
Removes lots of unused code form ansi_colors.py
Color to be tested in test_formatter, not execution tests
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #183 +/- ##
==========================================
+ Coverage 94.97% 95.49% +0.51%
==========================================
Files 2 2
Lines 478 533 +55
Branches 73 84 +11
==========================================
+ Hits 454 509 +55
Misses 12 12
Partials 12 12 ☔ View full report in Codecov by Sentry. |
=== Do not change lines below === { "chain": [], "cmd": "./.update-readme-help.py", "exit": 0, "extra_inputs": [], "inputs": [], "outputs": [], "pwd": "." } ^^^ Do not change lines above ^^^
=== Do not change lines below === { "chain": [], "cmd": "./.update-readme-help.py", "exit": 0, "extra_inputs": [], "inputs": [], "outputs": [], "pwd": "." } ^^^ Do not change lines above ^^^
5a44de8
to
ae7948a
Compare
Since they are unused I do not want them to go untested.
ae7948a
to
7baf455
Compare
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.
PS since I am the author of the PR, can't "Request changes"
Looks great! Let's just bring in new file into "the script".
If the user provides an invalid summary-format, we should: 1. Continue with the execution 2. Log a warning 3. Fallback str rather than whatever fancy formatting
e0194bf
to
5ed3be1
Compare
@yarikoptic If the user provides an invalid value, we shouldnt be returning a tb to them, so I added |
I did not mind the comment mess when it lived in a separate file, but in the main file, it is distracting. Easy enough to reacreate from the git history, keywords: decimal, gnu, binary, KiB, MiB, GiB
why? |
Let's proceed. thank you @asmacdo ! |
In principle works, here is current outputs
[EDIT asmacdo] I've made some tweaks to how the individual conversion flags work. The biggest user-interface difference is that I've made colors off by default.
duct --colors sleep 2
duct --colors echo 1
duct --colors false
And of course the user can specify --summary-format and use the custom conversion flags (documented in --help)
duct --colors --summary-format "JUST EXIT CODE: {exit_code\!E}" false