FCP-INDI / cpac

A convenience wrapper for https://github.com/FCP-INDI/C-PAC that provides a simple command line interface.
https://fcp-indi.github.io/docs/latest/user/cpac
MIT License
4 stars 3 forks source link

add memory usage/estimation quick parser utility #26

Closed gkiar closed 2 years ago

gkiar commented 2 years ago

Description

When provided with a callback.log file, this utility can sort through the memory runtime usage, estimate, and associated efficiency, to identify the n tasks with the highest or lowest of each of these categories.

Screenshots

When run on callback.log to get the 10 least efficient,

$ python src/cpac/helpers/cpac_parse_resources.py callback.log -f efficiency -g lowest -n 10
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┓
┃ Task ID                                  ┃ Memory Used ┃ Memory Estimated ┃ Memory Efficiency ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━┩
│ cpac_sub-A007_ses-BAS1.montage_mfi_365.… │ 0.2547      │ 10.3500          │ 2.46 %            │
│ cpac_sub-A007_ses-BAS1.montage_mni_anat… │ 0.2772      │ 10.3500          │ 2.68 %            │
│ cpac_sub-A007_ses-BAS1.carpet_seg_353.c… │ 0.2872      │ 10.3500          │ 2.77 %            │
│ cpac_sub-A007_ses-BAS1.carpet_seg_358.g… │ 0.2888      │ 10.3500          │ 2.79 %            │
│ cpac_sub-A007_ses-BAS1.carpet_seg_353.g… │ 0.2975      │ 10.3500          │ 2.87 %            │
│ cpac_sub-A007_ses-BAS1.carpet_seg_353.w… │ 0.2975      │ 10.3500          │ 2.87 %            │
│ cpac_sub-A007_ses-BAS1.carpet_seg_358.w… │ 0.2991      │ 10.3500          │ 2.89 %            │
│ cpac_sub-A007_ses-BAS1.carpet_seg_358.c… │ 0.2992      │ 10.3500          │ 2.89 %            │
│ cpac_sub-A007_ses-BAS1.montage_mni_anat… │ 0.3324      │ 10.3500          │ 3.21 %            │
│ cpac_sub-A007_ses-BAS1.montage_mfi_365.… │ 0.3362      │ 10.3500          │ 3.25 %            │
└──────────────────────────────────────────┴─────────────┴──────────────────┴───────────────────┘

or, the 5 most memory intensive:

$ python src/cpac/helpers/cpac_parse_resources.py callback.log -f runtime -g highest -n 5
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━┓
┃ Task ID                                  ┃ Memory Used ┃ Memory Estimated ┃ Memory Efficiency ┃
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━┩
│ cpac_sub-A007_ses-BAS1.segment_75        │ 1.5509      │ 3.5151           │ 44.12 %           │
│ cpac_sub-A007_ses-BAS1.ANTS_T1_to_templ… │ 1.1426      │ 3.3572           │ 34.04 %           │
│ cpac_sub-A007_ses-BAS1.ANTS_T1_to_templ… │ 1.1017      │ 3.3572           │ 32.82 %           │
│ cpac_sub-A007_ses-BAS1.ANTS_T1_to_templ… │ 1.0256      │ 2.3476           │ 43.69 %           │
│ cpac_sub-A007_ses-BAS1.ANTS_T1_to_templ… │ 1.0226      │ 2.3476           │ 43.56 %           │
└──────────────────────────────────────────┴─────────────┴──────────────────┴───────────────────┘

The help-text is as follows:

$ python src/cpac/helpers/cpac_parse_resources.py -h
usage: src/cpac/helpers/cpac_parse_resources.py [-h] [--filter_field {runtime,estimate,efficiency}]
                                                [--filter_group {lowest,highest}]
                                                [--filter_count FILTER_COUNT]
                                                callback

positional arguments:
  callback              callback.log file found in the 'log' directory of the specified derivatives
                        path

optional arguments:
  -h, --help            show this help message and exit
  --filter_field {runtime,estimate,efficiency}, -f {runtime,estimate,efficiency}
  --filter_group {lowest,highest}, -g {lowest,highest}
  --filter_count FILTER_COUNT, -n FILTER_COUNT

Checklist

Developer Certificate of Origin

Developer Certificate of Origin ``` Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 1 Letterman Drive Suite D4700 San Francisco, CA, 94129 Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. ```