-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotify_phase_start.py
More file actions
executable file
·26 lines (22 loc) · 1.02 KB
/
notify_phase_start.py
File metadata and controls
executable file
·26 lines (22 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3
"""
This script is used by various workloads to notify DSI that a phase within a workload started.
The messages from this script are parsed by DSI's PortForwardedEventQueue in events.py.
If profiling is enabled, this will trigger DSI to stop any profilers that are currently running.
"""
import socket
from argparse import ArgumentParser
import json
parser = ArgumentParser()
parser.add_argument("phase_name", type=str, help="Name of the phase that started")
parser.add_argument("-i", "--ip", type=str, default="0.0.0.0", help="Target ip for the notification")
parser.add_argument("-p", "--port", type=int, default=4400, help="Target port for the notification")
args = parser.parse_args()
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s:
s.connect((args.ip, args.port))
message = {"message": "Beginning phase"}
message["phase"] = args.phase_name
message["request"] = 1
s.send((json.dumps(message) + "\n").encode())
# Wait until DSI finishes responding to phase changes
s.recv(1024)