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

New con-duct ls command #224

Merged
merged 1 commit into from
Feb 7, 2025
Merged

New con-duct ls command #224

merged 1 commit into from
Feb 7, 2025

Conversation

asmacdo
Copy link
Member

@asmacdo asmacdo commented Nov 12, 2024

Fixes #185

summaries

Command: sleep 0.11
	Wall Clock Time: 0.112 sec
	Memory Peak Usage (RSS): 2.0 MB
	Virtual Memory Peak Usage (VSZ): 232.4 MB
	Memory Peak Percentage: 0.00%
	CPU Peak Usage: 0.00%

Command: sleep 0.1
	Wall Clock Time: 0.102 sec
	Memory Peak Usage (RSS): 2.0 MB
	Virtual Memory Peak Usage (VSZ): 232.4 MB
	Memory Peak Percentage: 0.00%
	CPU Peak Usage: 0.00%

yaml

command: sleep 0.11
duct_version: 0.8.0
env: {}
execution_summary:
  average_pcpu: 0.0
  average_pmem: 0.0
  average_rss: 1961984
  average_vsz: 232374272
  command: sleep 0.11
  end_time: 1731385053.3107307
  exit_code: 0
  logs_prefix: .duct/logs/2024.11.11T22.17.33-130359_
  num_reports: 2
  num_samples: 1
  peak_pcpu: 0.0
  peak_pmem: 0.0
  peak_rss: 1961984
  peak_vsz: 232374272
  start_time: 1731385053.198443
  wall_clock_time: 0.11228775978088379
gpu: null
output_paths:
  info: .duct/logs/2024.11.11T22.17.33-130359_info.json
  prefix: .duct/logs/2024.11.11T22.17.33-130359_
  stderr: .duct/logs/2024.11.11T22.17.33-130359_stderr
  stdout: .duct/logs/2024.11.11T22.17.33-130359_stdout
  usage: .duct/logs/2024.11.11T22.17.33-130359_usage.json
schema_version: 0.2.0
system:
  cpu_total: 20
  hostname: fancy
  memory_total: 33336127488
  uid: 1000
  user: austin

command: sleep 0.1
duct_version: 0.8.0
env: {}
execution_summary:
  average_pcpu: 0.0
  average_pmem: 0.0
  average_rss: 1978368
  average_vsz: 232374272
  command: sleep 0.1
  end_time: 1731385056.415762
  exit_code: 0
  logs_prefix: .duct/logs/2024.11.11T22.17.36-130380_
  num_reports: 2
  num_samples: 1
  peak_pcpu: 0.0
  peak_pmem: 0.0
  peak_rss: 1978368
  peak_vsz: 232374272
  start_time: 1731385056.3133166
  wall_clock_time: 0.10244536399841309
gpu: null
output_paths:
  info: .duct/logs/2024.11.11T22.17.36-130380_info.json
  prefix: .duct/logs/2024.11.11T22.17.36-130380_
  stderr: .duct/logs/2024.11.11T22.17.36-130380_stderr
  stdout: .duct/logs/2024.11.11T22.17.36-130380_stdout
  usage: .duct/logs/2024.11.11T22.17.36-130380_usage.json
schema_version: 0.2.0
system:
  cpu_total: 20
  hostname: fancy
  memory_total: 33336127488
  uid: 1000
  user: austin

json

{"command": "sleep 0.11", "system": {"cpu_total": 20, "memory_total": 33336127488, "hostname": "fancy", "uid": 1000, "user": "austin"}, "env": {}, "gpu": null, "duct_version": "0.8.0", "schema_version": "0.2.0", "execution_summary": {"exit_code": 0, "command": "sleep 0.11", "logs_prefix": ".duct/logs/2024.11.11T22.17.33-130359_", "wall_clock_time": 0.11228775978088379, "peak_rss": 1961984, "average_rss": 1961984, "peak_vsz": 232374272, "average_vsz": 232374272, "peak_pmem": 0.0, "average_pmem": 0.0, "peak_pcpu": 0.0, "average_pcpu": 0.0, "num_samples": 1, "num_reports": 2, "start_time": 1731385053.198443, "end_time": 1731385053.3107307}, "output_paths": {"stdout": ".duct/logs/2024.11.11T22.17.33-130359_stdout", "stderr": ".duct/logs/2024.11.11T22.17.33-130359_stderr", "usage": ".duct/logs/2024.11.11T22.17.33-130359_usage.json", "info": ".duct/logs/2024.11.11T22.17.33-130359_info.json", "prefix": ".duct/logs/2024.11.11T22.17.33-130359_"}}
{"command": "sleep 0.1", "system": {"cpu_total": 20, "memory_total": 33336127488, "hostname": "fancy", "uid": 1000, "user": "austin"}, "env": {}, "gpu": null, "duct_version": "0.8.0", "schema_version": "0.2.0", "execution_summary": {"exit_code": 0, "command": "sleep 0.1", "logs_prefix": ".duct/logs/2024.11.11T22.17.36-130380_", "wall_clock_time": 0.10244536399841309, "peak_rss": 1978368, "average_rss": 1978368, "peak_vsz": 232374272, "average_vsz": 232374272, "peak_pmem": 0.0, "average_pmem": 0.0, "peak_pcpu": 0.0, "average_pcpu": 0.0, "num_samples": 1, "num_reports": 2, "start_time": 1731385056.3133166, "end_time": 1731385056.415762}, "output_paths": {"stdout": ".duct/logs/2024.11.11T22.17.36-130380_stdout", "stderr": ".duct/logs/2024.11.11T22.17.36-130380_stderr", "usage": ".duct/logs/2024.11.11T22.17.36-130380_usage.json", "info": ".duct/logs/2024.11.11T22.17.36-130380_info.json", "prefix": ".duct/logs/2024.11.11T22.17.36-130380_"}}

jsonpp

{'command': 'sleep 0.11',
 'duct_version': '0.8.0',
 'env': {},
 'execution_summary': {'average_pcpu': 0.0,
                       'average_pmem': 0.0,
                       'average_rss': 1961984,
                       'average_vsz': 232374272,
                       'command': 'sleep 0.11',
                       'end_time': 1731385053.3107307,
                       'exit_code': 0,
                       'logs_prefix': '.duct/logs/2024.11.11T22.17.33-130359_',
                       'num_reports': 2,
                       'num_samples': 1,
                       'peak_pcpu': 0.0,
                       'peak_pmem': 0.0,
                       'peak_rss': 1961984,
                       'peak_vsz': 232374272,
                       'start_time': 1731385053.198443,
                       'wall_clock_time': 0.11228775978088379},
 'gpu': None,
 'output_paths': {'info': '.duct/logs/2024.11.11T22.17.33-130359_info.json',
                  'prefix': '.duct/logs/2024.11.11T22.17.33-130359_',
                  'stderr': '.duct/logs/2024.11.11T22.17.33-130359_stderr',
                  'stdout': '.duct/logs/2024.11.11T22.17.33-130359_stdout',
                  'usage': '.duct/logs/2024.11.11T22.17.33-130359_usage.json'},
 'schema_version': '0.2.0',
 'system': {'cpu_total': 20,
            'hostname': 'fancy',
            'memory_total': 33336127488,
            'uid': 1000,
            'user': 'austin'}}
{'command': 'sleep 0.1',
 'duct_version': '0.8.0',
 'env': {},
 'execution_summary': {'average_pcpu': 0.0,
                       'average_pmem': 0.0,
                       'average_rss': 1978368,
                       'average_vsz': 232374272,
                       'command': 'sleep 0.1',
                       'end_time': 1731385056.415762,
                       'exit_code': 0,
                       'logs_prefix': '.duct/logs/2024.11.11T22.17.36-130380_',
                       'num_reports': 2,
                       'num_samples': 1,
                       'peak_pcpu': 0.0,
                       'peak_pmem': 0.0,
                       'peak_rss': 1978368,
                       'peak_vsz': 232374272,
                       'start_time': 1731385056.3133166,
                       'wall_clock_time': 0.10244536399841309},
 'gpu': None,
 'output_paths': {'info': '.duct/logs/2024.11.11T22.17.36-130380_info.json',
                  'prefix': '.duct/logs/2024.11.11T22.17.36-130380_',
                  'stderr': '.duct/logs/2024.11.11T22.17.36-130380_stderr',
                  'stdout': '.duct/logs/2024.11.11T22.17.36-130380_stdout',
                  'usage': '.duct/logs/2024.11.11T22.17.36-130380_usage.json'},
 'schema_version': '0.2.0',
 'system': {'cpu_total': 20,
            'hostname': 'fancy',
            'memory_total': 33336127488,
            'uid': 1000,
            'user': 'austin'}}

TODO

  • pyout

Copy link

codecov bot commented Nov 12, 2024

Codecov Report

Attention: Patch coverage is 85.84906% with 15 lines in your changes missing coverage. Please review.

Project coverage is 94.05%. Comparing base (50a711e) to head (2bd83e4).
Report is 29 commits behind head on main.

Files with missing lines Patch % Lines
src/con_duct/suite/ls.py 84.37% 11 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #224      +/-   ##
==========================================
- Coverage   95.36%   94.05%   -1.32%     
==========================================
  Files           4        5       +1     
  Lines         626      740     +114     
  Branches       70       93      +23     
==========================================
+ Hits          597      696      +99     
- Misses         15       26      +11     
- Partials       14       18       +4     

☔ 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 Nov 12, 2024
@asmacdo
Copy link
Member Author

asmacdo commented Jan 15, 2025

Overall:

  • ls should be more of a list, rather than a list of long summaries.
  • maybe pyout will be cleaner

Info that seems most important:

  • command
  • info.json path
  • exit code
  • walltime

@yarikoptic
Copy link
Member

note that command might be too long to show in full "by default", max memory resource i think would also be nice to know.

@asmacdo
Copy link
Member Author

asmacdo commented Jan 15, 2025

@yarikoptic i've hacked together something with pyout

image

I'm not sure how I want to handle the "include_only" list, since ideally that would be agnostic to the output format, and I don't see a clean way to incorporate with LS_SUMMARY_FORMAT. But pyout is nice and easy!

@yarikoptic
Copy link
Member

I'm not sure how I want to handle the "include_only" list,

sorry -- could you describe what you mean by "include_only" list here?

@asmacdo
Copy link
Member Author

asmacdo commented Jan 15, 2025

@asmacdo asmacdo force-pushed the con-duct-ls branch 2 times, most recently from 7fb180b to 39e0e0f Compare January 21, 2025 19:45
Comment on lines 10 to 31
VALUE_TRANSFORMATION_MAP = {
"exit_code": "{value!E}",
"wall_clock_time": "{value:.3f} sec",
"peak_rss": "{value!S}",
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@yarikoptic if we use the custom formatter like this, the user can't provide their own format string, so its a bit less flexible than we did for regular duct output, but I think its a whole lot cleaner/dryer. And the user experience seems better too-- ie, provide an ordered list of fields that you want, rather than a format string that requires knowledge of how the formatter works.

If you like this approach too, I'll fill out this map with all the fields, and perhaps refactor regular duct output to function this way.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get some way done, let us try and then lets discuss and potentially improve.

Eventually I would expect us to be able to extend list of relevant attributes to be visualized in ls based on user's inputs. Might even be some kind of a "run a regex across stdout or stderr to get information of interest to be printed in each row" to support some custom extraction but for that I do not have immediate use case hence just a wild idea (must not be yet implemented anyhow).

@asmacdo
Copy link
Member Author

asmacdo commented Jan 21, 2025

Some significantly improved UX/rendering IMO!

Heres some samples of what it looks like now
$ con-duct ls -f pyout --fields exit_code 
PREFIX                                  EXIT_CODE
.duct/logs/2025.01.21T13.58.12-1102513_ 0        
.duct/logs/2025.01.21T13.58.16-1102532_ 0        
.duct/logs/2025.01.21T13.58.18-1102575_ 0        
.duct/logs/2025.01.21T13.58.21-1102593_ 0 
$ con-duct ls -f pyout                   
PREFIX                                  COMMAND     EXIT_CODE WALL_CLOCK_TIME PEAK_RSS
.duct/logs/2025.01.21T13.58.12-1102513_ sleep 0.1   0         0.102 sec       2.0 MB  
.duct/logs/2025.01.21T13.58.16-1102532_ sleep 0.11  0         0.113 sec       2.0 MB  
.duct/logs/2025.01.21T13.58.18-1102575_ sleep 0.111 0         0.113 sec       1.9 MB  
.duct/logs/2025.01.21T13.58.21-1102593_ sleep 0.1   0         0.102 sec       2.0 MB  
$ con-duct ls         
Prefix: .duct/logs/2025.01.21T13.58.12-1102513_
	Command: sleep 0.1
	Exit Code: 0
	Wall Clock Time: 0.102 sec
	Peak Rss: 2.0 MB
Prefix: .duct/logs/2025.01.21T13.58.16-1102532_
	Command: sleep 0.11
	Exit Code: 0
	Wall Clock Time: 0.113 sec
	Peak Rss: 2.0 MB
Prefix: .duct/logs/2025.01.21T13.58.18-1102575_
	Command: sleep 0.111
	Exit Code: 0
	Wall Clock Time: 0.113 sec
	Peak Rss: 1.9 MB
Prefix: .duct/logs/2025.01.21T13.58.21-1102593_
	Command: sleep 0.1
	Exit Code: 0
	Wall Clock Time: 0.102 sec
	Peak Rss: 2.0 MB
$ con-duct ls -f json_pp
[
 {
  "prefix": ".duct/logs/2025.01.21T13.58.12-1102513_",
  "command": "sleep 0.1",
  "exit_code": "0",
  "wall_clock_time": "0.102 sec",
  "peak_rss": "2.0 MB"
 },
 {
  "prefix": ".duct/logs/2025.01.21T13.58.16-1102532_",
  "command": "sleep 0.11",
  "exit_code": "0",
  "wall_clock_time": "0.113 sec",
  "peak_rss": "2.0 MB"
 },
 {
  "prefix": ".duct/logs/2025.01.21T13.58.18-1102575_",
  "command": "sleep 0.111",
  "exit_code": "0",
  "wall_clock_time": "0.113 sec",
  "peak_rss": "1.9 MB"
 },
 {
  "prefix": ".duct/logs/2025.01.21T13.58.21-1102593_",
  "command": "sleep 0.1",
  "exit_code": "0",
  "wall_clock_time": "0.102 sec",
  "peak_rss": "2.0 MB"
 }
]

@yarikoptic
Copy link
Member

we should see what we should display in "LOG_PREFIX",

❯ pwd
/home/yoh/proj/CON/duct-logs
❯ ls
2024.09.06T19.27.45-2130978_info.json  2024.09.06T19.27.45-2130978_stdout      fmriprep-000003/
2024.09.06T19.27.45-2130978_stderr     2024.09.06T19.27.45-2130978_usage.json  mriqc-demo-2024-10-10/
❯ ls */duct*
fmriprep-000003/duct_info.json*   mriqc-demo-2024-10-10/duct_info.json  mriqc-demo-2024-10-10/duct_stdout      mriqc-demo-2024-10-10/duct_usage.png
fmriprep-000003/duct_usage.json*  mriqc-demo-2024-10-10/duct_stderr     mriqc-demo-2024-10-10/duct_usage.json
❯ DUCT_OUTPUT_PREFIX='*/duct{' con-duct ls
PREFIX              COMMAND                                                                                                                       EXIT_CODE WALL_CLOCK_TIME PEAK_RSS
logs/duct_          ./code/containers/scripts/singularity_cmd run code/containers/images/bids/bids-fmriprep--24.1.1.sing sourcedata/ds000003-d... 0         105813.460 sec  10.0 GB 
participant-1/duct_ singularity run --contain --bind /mnt/DATA/data/asmacdo/duct-demo-full-ds000003/sourcedata:/data:ro --bind /mnt/DATA/data/... 0         623.852 sec     93.8 GB 

so we display PREFIX as loaded from the files. But of interest here likely is actually "FILES_PREFIX" based on the filenames loaded.

@asmacdo asmacdo marked this pull request as ready for review February 4, 2025 17:38
@asmacdo asmacdo force-pushed the con-duct-ls branch 2 times, most recently from 98bad79 to 896972a Compare February 6, 2025 17:34
@asmacdo asmacdo marked this pull request as draft February 6, 2025 17:56
@asmacdo asmacdo added the release Create a release when this pr is merged label Feb 6, 2025
@asmacdo asmacdo marked this pull request as ready for review February 6, 2025 18:15
@yarikoptic yarikoptic merged commit 7c3b222 into con:main Feb 7, 2025
13 of 15 checks passed
@yarikoptic yarikoptic changed the title Con duct ls con-duct ls Feb 7, 2025
@yarikoptic yarikoptic changed the title con-duct ls New con-duct ls command Feb 7, 2025
Copy link

github-actions bot commented Feb 7, 2025

🚀 PR was released in v0.10.0 🚀

@yarikoptic
Copy link
Member

Please do not forget next time to make PR titles descriptive enough to serve as a changelog entry.

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 released semver-minor Increment the minor version when merged
Projects
None yet
Development

Successfully merging this pull request may close these issues.

con-duct ls [-f pyout,summary,json,json_pp,yaml]
2 participants