Skip to content

Commit

Permalink
Create entry point
Browse files Browse the repository at this point in the history
  • Loading branch information
ktactac-ornl authored Oct 25, 2024
1 parent 0d0cd87 commit 8a54fb6
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 11 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ It monitors CPU and RAM usage, and reports the time span of each algorithm (curr

To profile the `SNSPowderReduction.py` workflow:
```
python SNSPowderReduction.py & python path/to/mantid-profiler/src/mantidprofiler/mantidprofiler.py $!
python SNSPowderReduction.py & mantidprofiler $!
```
The script attaches to the last spawned process, so you can also use the profiler if you are working with `MantidPlot`:
```
./MantidPlot & python path/to/mantid-profiler/mantid-profiler.py $!
./MantidPlot & mantidprofiler $!
```

## Requires
Expand Down
1 change: 1 addition & 0 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ dependencies:
- conda-verify
- libmamba
- libarchive
- numpy
- pre-commit
- psutil
- python-build
Expand Down
4 changes: 4 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@ homepage = "https://github.com/mantidproject/mantid-profiler/"
repository = "https://github.com/mantidproject/mantid-profiler/"
issues = "https://github.com/mantidproject/mantid-profiler/issues"

[project.scripts]
mantidprofiler = "mantidprofiler.mantidprofiler:main"


[build-system]
requires = ["setuptools", "wheel", "toml", "versioningit"]
build-backend = "setuptools.build_meta"
Expand Down
4 changes: 4 additions & 0 deletions src/mantidprofiler/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
from mantidprofiler.mantidprofiler import main

if __name__ == "__main__":
main()
5 changes: 3 additions & 2 deletions src/mantidprofiler/diskrecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

import numpy as np
import psutil
from children_util import all_children
from time_util import get_current_time, get_start_time

from mantidprofiler.children_util import all_children
from mantidprofiler.time_util import get_current_time, get_start_time


def monitor(pid: int, logfile: Path, interval: Optional[float], show_bytes: bool = False) -> None:
Expand Down
11 changes: 6 additions & 5 deletions src/mantidprofiler/mantidprofiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,13 @@
from pathlib import Path
from threading import Thread

import algorithm_tree as at
import numpy as np
from diskrecord import monitor as diskmonitor
from diskrecord import parse_log as parse_disk_log
from psrecord import monitor as cpumonitor
from psrecord import parse_log as parse_cpu_log

import mantidprofiler.algorithm_tree as at
from mantidprofiler.diskrecord import monitor as diskmonitor
from mantidprofiler.diskrecord import parse_log as parse_disk_log
from mantidprofiler.psrecord import monitor as cpumonitor
from mantidprofiler.psrecord import parse_log as parse_cpu_log


# Convert string to RGB color
Expand Down
5 changes: 3 additions & 2 deletions src/mantidprofiler/psrecord.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@

import numpy as np
import psutil
from children_util import all_children, update_children
from time_util import get_current_time, get_start_time

from mantidprofiler.children_util import all_children, update_children
from mantidprofiler.time_util import get_current_time, get_start_time


# returns percentage for system + user time
Expand Down

0 comments on commit 8a54fb6

Please sign in to comment.