File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # dfanalyzer
1+ # dfanalyzer
2+ ## Report mode
3+
4+ You can now run all of the existing ` dfreport.py ` reports directly through the main ` dfanalyzer ` executable:
5+
6+ ``` bash
7+ # per-node summary:
8+ dfanalyzer --report --node /path/to/COMPACT/
9+
10+ # per-process, highlight the max across processes:
11+ dfanalyzer --report --process --aggregate /path/to/COMPACT/
12+
13+ # ### How it works
14+
15+ - **`cli ()` ** inspects ` sys.argv` before Hydra ever sees it.
16+ - If ` --report` is present, we strip it out (so ` argparse` in ` dfreport.py` still works unchanged) and call ` dfreport.main()` .
17+ - Otherwise we call the original ` main()` , so nothing else in your toolchain is disturbed.
18+ - Finally, by repointing the ` dfanalyzer` console script to ` cli()` , any ` dfanalyzer ...` invocation will first check for ` --report` .
19+
20+ This gives you exactly what you asked for ` dfanalyzer --report [dfreport options]` with minimal changes to the rest of the repo.
Original file line number Diff line number Diff line change 1+ # File: dfanalyzer/dfanalyzer/__main__.py
2+
3+ import sys
14import hydra
25from distributed import Client
36from hydra .utils import instantiate
811from .cluster import ExternalCluster
912from .types import Rule
1013
11-
1214init_hydra_config_store ()
1315
16+ def cli ():
17+ """
18+ Dispatch between the new --report mode and the usual Hydrabpowered analysis.
19+ """
20+ if '--report' in sys .argv :
21+ # Remove our flag so dfreport.py sees only its own args
22+ sys .argv .remove ('--report' )
23+ from .utils .dfreport import main as report_main
24+ report_main ()
25+ else :
26+ main ()
1427
1528@hydra .main (version_base = None , config_name = "config" )
1629def main (cfg : Config ) -> None :
@@ -21,6 +34,7 @@ def main(cfg: Config) -> None:
2134 client .restart ()
2235 else :
2336 client = Client (cluster )
37+
2438 analyzer : AnalyzerType = instantiate (
2539 cfg .analyzer ,
2640 debug = cfg .debug ,
@@ -36,11 +50,13 @@ def main(cfg: Config) -> None:
3650 unoverlapped_posix_only = cfg .unoverlapped_posix_only ,
3751 view_types = cfg .view_types ,
3852 )
53+
3954 output : OutputType = instantiate (cfg .output )
4055 output .handle_result (result = result )
56+
4157 client .close ()
4258 cluster .close () # type: ignore
4359
44-
4560if __name__ == "__main__" :
46- main ()
61+ cli ()
62+
Original file line number Diff line number Diff line change @@ -48,7 +48,7 @@ dependencies = [
4848darshan = [" darshan>=3.4" ]
4949
5050[project .scripts ]
51- dfanalyzer = " dfanalyzer.__main__:main "
51+ dfanalyzer = " dfanalyzer.__main__:cli "
5252dfanalyzer-cluster = " dfanalyzer.cluster:main"
5353dfanalyzer-plot = " dfanalyzer.plots:main"
5454
You can’t perform that action at this time.
0 commit comments