diff --git a/README.md b/README.md index 4962b15..13f0229 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/environment.yml b/environment.yml index dbe0291..ac6b807 100644 --- a/environment.yml +++ b/environment.yml @@ -9,6 +9,7 @@ dependencies: - conda-verify - libmamba - libarchive + - numpy - pre-commit - psutil - python-build diff --git a/pyproject.toml b/pyproject.toml index 6bb454c..6a096b6 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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" diff --git a/src/mantidprofiler/__main__.py b/src/mantidprofiler/__main__.py new file mode 100644 index 0000000..5f7ff50 --- /dev/null +++ b/src/mantidprofiler/__main__.py @@ -0,0 +1,4 @@ +from mantidprofiler.mantidprofiler import main + +if __name__ == "__main__": + main() diff --git a/src/mantidprofiler/diskrecord.py b/src/mantidprofiler/diskrecord.py index e4da91a..5bfb688 100644 --- a/src/mantidprofiler/diskrecord.py +++ b/src/mantidprofiler/diskrecord.py @@ -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: diff --git a/src/mantidprofiler/mantidprofiler.py b/src/mantidprofiler/mantidprofiler.py index 674e5cf..cf20908 100644 --- a/src/mantidprofiler/mantidprofiler.py +++ b/src/mantidprofiler/mantidprofiler.py @@ -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 diff --git a/src/mantidprofiler/psrecord.py b/src/mantidprofiler/psrecord.py index 6b1fac0..16f54c6 100644 --- a/src/mantidprofiler/psrecord.py +++ b/src/mantidprofiler/psrecord.py @@ -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