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

Create package entrypoint #6

Merged
merged 1 commit into from
Oct 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading