Skip to content

Commit eb071af

Browse files
committed
Adds support for --help option. Fixes #165
1 parent e148671 commit eb071af

1 file changed

Lines changed: 42 additions & 0 deletions

File tree

scorep/__main__.py

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
import scorep.instrumenter
55
import scorep.subsystem
6+
import scorep.helper
67
from scorep.helper import print_err
78

89

@@ -11,6 +12,38 @@ def _err_exit(msg):
1112
sys.exit(1)
1213

1314

15+
def print_help():
16+
print("""
17+
Usage: python -m scorep [options] [--] your_program.py [args]
18+
19+
Score-P Python instrumentation wrapper. The following options control how the program is instrumented and executed:
20+
21+
--help Show this help message and exit.
22+
--mpi Enable MPI instrumentation (equivalent to --mpp=mpi).
23+
--keep-files Keep temporary files after execution.
24+
--verbose, -v Enable verbose output for debugging and tracing.
25+
--nopython Disable instrumentation of Python code.
26+
Instrumentation can still be enabled later from within the application's source code.
27+
--noinstrumenter Same as --nopython.
28+
--instrumenter-type=<t> Specify custom instrumenter type (e.g., cProfile).
29+
--instrumenter-file=<f> Path to a Python script that is executed before the application.
30+
Allows instrumentation of specific modules and functions without modifying their source code.
31+
-- Stop parsing Score-P options; pass following args to your script.
32+
33+
Other options starting with '-' are passed directly to 'scorep-config'.
34+
To view all available Score-P configuration options, run: scorep-config --help
35+
36+
Example:
37+
scorep --mpi --thread=pthread -- your_script.py --arg1 --arg2
38+
39+
Note:
40+
If using --noinstrumenter, Score-P will not trace Python code, but it may still collect MPI or threading events
41+
if configured.
42+
You can enable Python instrumentation manually from within your application's source code,
43+
e.g., by calling 'scorep.instrumenter.enable()'.
44+
""")
45+
46+
1447
def scorep_main(argv=None):
1548
if argv is None:
1649
argv = sys.argv
@@ -19,9 +52,11 @@ def scorep_main(argv=None):
1952
prog_argv = []
2053
parse_scorep_commands = True
2154

55+
show_help = False
2256
keep_files = False
2357
verbose = False
2458
no_instrumenter = False
59+
2560
if scorep.instrumenter.has_c_instrumenter():
2661
instrumenter_type = "cProfile"
2762
else:
@@ -32,6 +67,9 @@ def scorep_main(argv=None):
3267
if parse_scorep_commands:
3368
if elem == "--":
3469
parse_scorep_commands = False
70+
if elem == "--help":
71+
show_help = True
72+
break
3573
elif elem == "--mpi":
3674
scorep_config.append("--mpp=mpi")
3775
elif elem == "--keep-files":
@@ -64,6 +102,10 @@ def scorep_main(argv=None):
64102
else:
65103
prog_argv.append(elem)
66104

105+
# fast exit on "--help"
106+
if show_help:
107+
print_help()
108+
sys.exit(0)
67109
if len(prog_argv) == 0:
68110
_err_exit("Did not find a script to run")
69111

0 commit comments

Comments
 (0)