Skip to content
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

Merged
merged 39 commits into from
Sep 30, 2024

Conversation

yarikoptic
Copy link
Member

@yarikoptic yarikoptic commented Sep 20, 2024

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

[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

image

duct --colors echo 1

image

duct --colors false

image

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

image

duct --summary-format "                              
exit: {exit_code\!E}
walltime: {wall_clock_time:.3f}" sleep 1.1111111111

image

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
src/con_duct/__main__.py Outdated Show resolved Hide resolved
src/con_duct/__main__.py Outdated Show resolved Hide resolved
src/con_duct/__main__.py Outdated Show resolved Hide resolved
@asmacdo
Copy link
Member

asmacdo commented Sep 20, 2024

When we dont get measurements, use red.

duct -p Z_ --s-i 0.1 --r-i 1 --clobber ls

image

When we do get measurements, use green

duct -p Z_ --s-i 0.1 --r-i 1 --clobber sleep 1

image

@asmacdo
Copy link
Member

asmacdo commented Sep 20, 2024

Next up, need to add lots of tests.

@asmacdo asmacdo mentioned this pull request Sep 23, 2024
Copy link

codecov bot commented Sep 24, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.49%. Comparing base (7f5a3ae) to head (58a1ff1).
Report is 42 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

@asmacdo asmacdo added the semver-minor Increment the minor version when merged label Sep 24, 2024
=== 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 ^^^
@asmacdo asmacdo force-pushed the enh-formatter branch 2 times, most recently from 5a44de8 to ae7948a Compare September 24, 2024 20:56
@asmacdo asmacdo marked this pull request as ready for review September 25, 2024 15:22
Copy link
Member Author

@yarikoptic yarikoptic left a 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".

README.md Show resolved Hide resolved
README.md Show resolved Hide resolved
src/con_duct/filesize.py Outdated Show resolved Hide resolved
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
@asmacdo
Copy link
Member

asmacdo commented Sep 29, 2024

@yarikoptic If the user provides an invalid value, we shouldnt be returning a tb to them, so I added [No user-facing tb even with invalid summary-format](https://github.com/con/duct/pull/183/commits/264ae8b7d57ee4f9da6ddef28edf5a8cb98e2927)

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
@yarikoptic
Copy link
Member Author

@yarikoptic If the user provides an invalid value, we shouldnt be returning a tb to them

why?

@yarikoptic
Copy link
Member Author

Let's proceed. thank you @asmacdo !

@yarikoptic yarikoptic added the release Create a release when this pr is merged label Sep 30, 2024
@yarikoptic yarikoptic merged commit 9274d92 into main Sep 30, 2024
15 checks passed
@asmacdo asmacdo deleted the enh-formatter branch October 4, 2024 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release Create a release when this pr is merged semver-minor Increment the minor version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants