Skip to content

Commit 8159854

Browse files
authored
[PROTON] Enable the default session_id for activate and deactivate interfaces (#3771)
1 parent 270e7b9 commit 8159854

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

third_party/proton/proton/profile.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,27 @@ def start(
5454
return libproton.start(name, backend, context, data)
5555

5656

57-
def activate(session: int) -> None:
57+
def activate(session: Optional[int] = 0) -> None:
5858
"""
5959
Activate the specified session.
6060
The profiling session will be active and data will be recorded.
6161
6262
Args:
63-
session (int): The session ID of the profiling session.
63+
session (int): The session ID of the profiling session. Defaults to 0 (the first session started.)
6464
6565
Returns:
6666
None
6767
"""
6868
libproton.activate(session)
6969

7070

71-
def deactivate(session: int) -> None:
71+
def deactivate(session: Optional[int] = 0) -> None:
7272
"""
7373
Stop the specified session.
7474
The profiling session's data will still be in the memory, but no more data will be recorded.
7575
7676
Args:
77-
session (int): The session ID of the profiling session.
77+
session (int): The session ID of the profiling session. Defaults to 0 (the first session started.)
7878
7979
Returns:
8080
None

third_party/proton/test/test_api.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
def test_profile():
88
with tempfile.NamedTemporaryFile(delete=True, suffix=".hatchet") as f:
99
session_id0 = proton.start(f.name.split(".")[0])
10-
proton.activate(session_id0)
11-
proton.deactivate(session_id0)
10+
proton.activate()
11+
proton.deactivate()
1212
proton.finalize()
13+
assert session_id0 == 0
1314

1415
with tempfile.NamedTemporaryFile(delete=True, suffix=".hatchet") as f:
1516
session_id1 = proton.start(f.name.split(".")[0])
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
import triton.profiler as proton
21
import subprocess
32

43

54
def test_help():
65
# Only check if the viewer can be invoked
7-
ret = subprocess.check_call(["proton-viewer", "-h"])
6+
ret = subprocess.check_call(["proton-viewer", "-h"], stdout=subprocess.DEVNULL)
87
assert ret == 0

0 commit comments

Comments
 (0)