Skip to content

Commit ed13e9e

Browse files
authored
Merge pull request #401 from GaneshPatil7517/fix/measurement-undefined-ports
fix: prevent undefined port variable errors in measurement scripts (fixes #345)
2 parents edaac35 + 82de837 commit ed13e9e

4 files changed

Lines changed: 63 additions & 1 deletion

File tree

measurements/A.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@
55
import psutil
66
import sys
77

8+
# --- Fallback Definitions for Direct Execution ---
9+
# These values are normally injected by copy_with_port_portname.py during study generation.
10+
# When running this script directly, safe defaults are used instead.
11+
_STANDALONE_MODE = False
12+
13+
if 'PORT_NAME_F1_F2' not in globals():
14+
PORT_NAME_F1_F2 = "F1_F2"
15+
_STANDALONE_MODE = True
16+
17+
if 'PORT_F1_F2' not in globals():
18+
PORT_F1_F2 = "5555"
19+
_STANDALONE_MODE = True
20+
21+
if _STANDALONE_MODE:
22+
print("Warning: Port variables not injected. Running in standalone mode with default values.")
23+
print(" For full study behavior, run via study generation (makestudy).")
24+
825
# --- ZMQ Initialization ---
926
# This REQ socket connects to Node B
1027
concore.init_zmq_port(

measurements/B.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,31 @@
22
import concore
33
import time
44

5+
# --- Fallback Definitions for Direct Execution ---
6+
# These values are normally injected by copy_with_port_portname.py during study generation.
7+
# When running this script directly, safe defaults are used instead.
8+
_STANDALONE_MODE = False
9+
10+
if 'PORT_NAME_F1_F2' not in globals():
11+
PORT_NAME_F1_F2 = "F1_F2"
12+
_STANDALONE_MODE = True
13+
14+
if 'PORT_F1_F2' not in globals():
15+
PORT_F1_F2 = "5555"
16+
_STANDALONE_MODE = True
17+
18+
if 'PORT_NAME_F2_F3' not in globals():
19+
PORT_NAME_F2_F3 = "F2_F3"
20+
_STANDALONE_MODE = True
21+
22+
if 'PORT_F2_F3' not in globals():
23+
PORT_F2_F3 = "5556"
24+
_STANDALONE_MODE = True
25+
26+
if _STANDALONE_MODE:
27+
print("Warning: Port variables not injected. Running in standalone mode with default values.")
28+
print(" For full study behavior, run via study generation (makestudy).")
29+
530
# --- ZMQ Initialization ---
631
# This REP socket binds and waits for requests from Node A
732
concore.init_zmq_port(

measurements/C.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,23 @@
55
import os
66
import sys
77

8+
# --- Fallback Definitions for Direct Execution ---
9+
# These values are normally injected by copy_with_port_portname.py during study generation.
10+
# When running this script directly, safe defaults are used instead.
11+
_STANDALONE_MODE = False
12+
13+
if 'PORT_NAME_F2_F3' not in globals():
14+
PORT_NAME_F2_F3 = "F2_F3"
15+
_STANDALONE_MODE = True
16+
17+
if 'PORT_F2_F3' not in globals():
18+
PORT_F2_F3 = "5556"
19+
_STANDALONE_MODE = True
20+
21+
if _STANDALONE_MODE:
22+
print("Warning: Port variables not injected. Running in standalone mode with default values.")
23+
print(" For full study behavior, run via study generation (makestudy).")
24+
825
# --- ZMQ Initialization ---
926
# This REP socket binds and waits for requests from Node B
1027
concore.init_zmq_port(

measurements/readme.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,4 +32,7 @@ This folder contains studies and source code specifically for measuring communic
3232
Here you will find studies and source code focused on measuring communication times using ZeroMQ within a single system setup.
3333

3434
# Network Communication Measurements (Two Systems Required)
35-
For the Latency, Throughput, and CPU Usage measurements, two different systems are required. These systems should be connected over the same network to ensure efficient and accurate communication measurements between them. This setup is crucial for evaluating network-dependent performance metrics effectively.
35+
For the Latency, Throughput, and CPU Usage measurements, two different systems are required. These systems should be connected to the same network to ensure efficient, accurate communication between them. This setup is crucial for effectively evaluating network-dependent performance metrics.
36+
37+
# Important Note on Port Variables
38+
The measurement benchmark scripts (A.py, B.py, C.py) expect port variables such as `PORT_NAME_F1_F2`, `PORT_F1_F2`, `PORT_NAME_F2_F3`, and `PORT_F2_F3` to be injected by `copy_with_port_portname.py` during study generation. Running these scripts directly will use safe fallback defaults and may not reflect full study behavior. For accurate results, always run measurements through the study generation workflow (e.g., `makestudy`).

0 commit comments

Comments
 (0)