Skip to content

Commit 2654256

Browse files
committed
Initial integration of dfreport into dfanalyzer
1 parent 50e6cdd commit 2654256

3 files changed

Lines changed: 40 additions & 5 deletions

File tree

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,20 @@
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.

dfanalyzer/__main__.py

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
# File: dfanalyzer/dfanalyzer/__main__.py
2+
3+
import sys
14
import hydra
25
from distributed import Client
36
from hydra.utils import instantiate
@@ -8,9 +11,19 @@
811
from .cluster import ExternalCluster
912
from .types import Rule
1013

11-
1214
init_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")
1629
def 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-
4560
if __name__ == "__main__":
46-
main()
61+
cli()
62+

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ dependencies = [
4848
darshan = ["darshan>=3.4"]
4949

5050
[project.scripts]
51-
dfanalyzer = "dfanalyzer.__main__:main"
51+
dfanalyzer = "dfanalyzer.__main__:cli"
5252
dfanalyzer-cluster = "dfanalyzer.cluster:main"
5353
dfanalyzer-plot = "dfanalyzer.plots:main"
5454

0 commit comments

Comments
 (0)