Skip to content
63 changes: 6 additions & 57 deletions compliance/sources_checksums.json
Original file line number Diff line number Diff line change
@@ -1,70 +1,19 @@
[
{
"__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"client.py": "33ca4f26368777ac06e01f9567b714a4b8063886",
"lib/__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"lib/client.py": "4c2b78fb4849a7e5b584ef792d82aaed20b17f57",
"lib/common.py": "624d0c0acc7c39aaff3674f0b99d6a09da53d1dc",
"lib/external/__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"lib/external/ntplib.py": "4da8f970656505a40483206ef2b5d3dd5e81711d",
"lib/server.py": "24ae49fb193809cf47f2c18b1c9c7c866244be4d",
"lib/source_hashes.py": "60a2e02193209e8d392803326208d5466342da18",
"lib/summary.py": "aa92f0a3f975eecd44d3c0cd0236342ccc9f941d",
"lib/time_sync.py": "3210db56eb0ff0df57bf4293dc4d4b03fffd46f1",
"server.py": "c3f90f2f7eeb4db30727556d0c815ebc89b3d28b",
"tests/unit/__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"tests/unit/test_server.py": "99ae15aef722f2000ee6ed1ae1523637bf1ae42b",
"tests/unit/test_source_hashes.py": "00468a2907583c593e6574a1f6b404e4651c221a"
},
{
"__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"client.py": "33ca4f26368777ac06e01f9567b714a4b8063886",
"lib/__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"lib/client.py": "4c2b78fb4849a7e5b584ef792d82aaed20b17f57",
"lib/common.py": "624d0c0acc7c39aaff3674f0b99d6a09da53d1dc",
"lib/external/__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"lib/external/ntplib.py": "4da8f970656505a40483206ef2b5d3dd5e81711d",
"lib/server.py": "24ae49fb193809cf47f2c18b1c9c7c866244be4d",
"lib/source_hashes.py": "60a2e02193209e8d392803326208d5466342da18",
"lib/summary.py": "aa92f0a3f975eecd44d3c0cd0236342ccc9f941d",
"lib/time_sync.py": "3210db56eb0ff0df57bf4293dc4d4b03fffd46f1",
"server.py": "c3f90f2f7eeb4db30727556d0c815ebc89b3d28b",
"tests/unit/__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"tests/unit/test_server.py": "99ae15aef722f2000ee6ed1ae1523637bf1ae42b",
"tests/unit/test_source_hashes.py": "00468a2907583c593e6574a1f6b404e4651c221a"
},
{
"client.py": "33ca4f26368777ac06e01f9567b714a4b8063886",
"server.py": "c3f90f2f7eeb4db30727556d0c815ebc89b3d28b",
"__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"lib/summary.py": "aa92f0a3f975eecd44d3c0cd0236342ccc9f941d",
"lib/client.py": "4c2b78fb4849a7e5b584ef792d82aaed20b17f57",
"lib/server.py": "59c9fb92908260d3e9f81a895c7aa009742275e4",
"lib/source_hashes.py": "60a2e02193209e8d392803326208d5466342da18",
"lib/__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"lib/common.py": "624d0c0acc7c39aaff3674f0b99d6a09da53d1dc",
"lib/time_sync.py": "3210db56eb0ff0df57bf4293dc4d4b03fffd46f1",
"lib/external/ntplib.py": "4da8f970656505a40483206ef2b5d3dd5e81711d",
"lib/external/__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"tests/unit/test_server.py": "99ae15aef722f2000ee6ed1ae1523637bf1ae42b",
"tests/unit/test_source_hashes.py": "00468a2907583c593e6574a1f6b404e4651c221a",
"tests/unit/__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
},
{
"server.py": "c3f90f2f7eeb4db30727556d0c815ebc89b3d28b",
"client.py": "33ca4f26368777ac06e01f9567b714a4b8063886",
"__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"tests/unit/test_source_hashes.py": "00468a2907583c593e6574a1f6b404e4651c221a",
"tests/unit/__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"tests/unit/test_server.py": "99ae15aef722f2000ee6ed1ae1523637bf1ae42b",
"tests/unit/test_server.py": "948c1995d4008bc2aa6c4046a34ffa3858d6d671",
"lib/time_sync.py": "3210db56eb0ff0df57bf4293dc4d4b03fffd46f1",
"lib/source_hashes.py": "60a2e02193209e8d392803326208d5466342da18",
"lib/server.py": "cda0cdfaee9bfa1249c64a7dd4f89b7bf1b279f0",
"lib/client.py": "4c2b78fb4849a7e5b584ef792d82aaed20b17f57",
"lib/common.py": "611d8b29633d331eb19c9455ea3b5fa3284ed6df",
"lib/server.py": "8054263a14dedddcf8e1c01adc19596c21bad591",
"lib/__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709",
"lib/summary.py": "aa92f0a3f975eecd44d3c0cd0236342ccc9f941d",
"lib/time_sync.py": "3210db56eb0ff0df57bf4293dc4d4b03fffd46f1",
"lib/common.py": "624d0c0acc7c39aaff3674f0b99d6a09da53d1dc",
"lib/client.py": "c146491755e219a28d440b31f83998dbd5532483",
"lib/external/ntplib.py": "4da8f970656505a40483206ef2b5d3dd5e81711d",
"lib/external/__init__.py": "da39a3ee5e6b4b0d3255bfef95601890afd80709"
}
]
]
26 changes: 24 additions & 2 deletions ptd_client_server/lib/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,12 @@ def main() -> None:
parser.add_argument(
"-S", "--stop-server", action="store_true",
help="stop the server after processing this client")
parser.add_argument(
"-A", "--max-amps", type=float, default=0,
help="Use the given current value (in Amperes) as the max limit (Experimental)")
parser.add_argument(
"-V", "--max-volts", type=float, default=0,
help="Use the given current voltage (in Volts) as the max limit (Experimental)")
# fmt: on
common.log_redirect.start()

Expand Down Expand Up @@ -281,14 +287,28 @@ def sync_check() -> None:
power_dir = os.path.join(args.output, session, "power")
os.mkdir(power_dir)

for mode in ["ranging", "testing"]:
if args.max_amps > 0 and args.max_volts > 0:
logging.warning(
f"Providing manual ranges are only for experimental purpose and the produced results won't be valid for submission"
)
needed_modes = ["testing"]
else:
needed_modes = ["ranging", "testing"]

for mode in needed_modes:
logging.info(f"Running workload in {mode} mode")
out = os.path.join(out_dir, "run_1" if mode == "testing" else mode)

sync_check()

summary.phase(mode, 0)
command(f"session,{session},start,{mode}", check=True)
if args.max_amps > 0 and args.max_volts > 0:
command(
f"session,{session},start,{mode},{args.max_volts},{args.max_amps}",
check=True,
)
else:
command(f"session,{session},start,{mode}", check=True)

summary.phase(mode, 1)
logging.info(f"Running the workload {args.run_workload!r}")
Expand Down Expand Up @@ -332,6 +352,8 @@ def sync_check() -> None:
command(f"session,{session},done", check=True)

for fname in common.FETCH_FILES_LIST:
if "ranging" in fname and args.max_amps > 0 and args.max_volts > 0:
continue
command.download(f"download,{session},{fname}", os.path.join(out_dir, fname))

command(f"cleanup,{session}", check=True)
Expand Down
1 change: 1 addition & 0 deletions ptd_client_server/lib/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"power/server.json",
"power/server.log",
"run_1/spl.txt",
"run_1/ptd_out.txt",
]


Expand Down
46 changes: 36 additions & 10 deletions ptd_client_server/lib/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from decimal import Decimal
from enum import Enum
from ipaddress import ip_address
from typing import Any, Callable, Optional, Dict, Tuple, List, Set, NoReturn
from typing import Any, Callable, Optional, Dict, Tuple, List, Set, NoReturn, Union
import argparse
import atexit
import builtins
Expand Down Expand Up @@ -697,14 +697,19 @@ def _handle_cmd(self, cmd: str, p: common.Proto) -> Optional[str]:
unbool = ["Error", "OK"]

if cmd == ["start", "ranging"]:
return unbool[self.session.start(Mode.RANGING)]
elif cmd == ["start", "testing"]:
return unbool[self.session.start(Mode.TESTING)]
return unbool[int(self.session.start(Mode.RANGING))]
elif cmd[0] == "start" and cmd[1] == "testing" and len(cmd) == 2:
return unbool[int(self.session.start(Mode.TESTING))]
elif cmd[0] == "start" and cmd[1] == "testing" and len(cmd) == 4:
self.session._maxVolts = cmd[2]
self.session._maxAmps = cmd[3]
r = self.session.start(Mode.TESTING)
return unbool[int(r)] if type(r) == bool else str(r)

if cmd == ["stop", "ranging"]:
return unbool[self.session.stop(Mode.RANGING)]
return unbool[int(self.session.stop(Mode.RANGING))]
if cmd == ["stop", "testing"]:
return unbool[self.session.stop(Mode.TESTING)]
return unbool[int(self.session.stop(Mode.TESTING))]

if cmd == ["done"]:
self._drop_session()
Expand Down Expand Up @@ -826,7 +831,7 @@ def __init__(self, server: Server, label: str) -> None:
self._avgWatts: Optional[str] = None
self._desirableCurrentRange: Optional[str] = None

def start(self, mode: Mode) -> bool:
def start(self, mode: Mode) -> Union[bool, str]:
if mode == Mode.RANGING and self._state == SessionState.RANGING:
return True
if mode == Mode.TESTING and self._state == SessionState.TESTING:
Expand Down Expand Up @@ -864,14 +869,31 @@ def start(self, mode: Mode) -> bool:
self._server._summary.phase("ranging", 1)
return True

if mode == Mode.TESTING and self._state == SessionState.RANGING_DONE:
if mode == Mode.TESTING and (
(self._state == SessionState.INITIAL and self._maxVolts and self._maxAmps)
or self._state == SessionState.RANGING_DONE
):
self._server._summary.phase("testing", 0)
self._ptd.start()
self._ptd.cmd(f"SR,V,{self._maxVolts}")
self._ptd.cmd(f"SR,A,{self._desirableCurrentRange}")

r = self._ptd.cmd(f"SR,V,{self._maxVolts}")
if r and "Error" in r:
error = f"Error setting voltage range: {self._maxVolts}"
logging.error(error)
self.drop()
return error

r = self._ptd.cmd(f"SR,A,{self._desirableCurrentRange}")
if r and "Error" in r:
error = f"Error setting current range: {self._desirableCurrentRange}"
logging.error(error)
self.drop()
return error

with common.sig:
time.sleep(ANALYZER_SLEEP_SECONDS)
logging.info("Starting testing mode")
logging.info(f"maxAmps: {self._maxAmps}, maxVolts: {self._maxVolts}")
self._ptd.cmd(f"Go,1000,0,{self._id}_testing")

self._state = SessionState.TESTING
Expand Down Expand Up @@ -963,6 +985,8 @@ def stop(self, mode: Mode) -> bool:

if mode == Mode.TESTING and self._state == SessionState.TESTING:
self._state = SessionState.TESTING_DONE
watts = self._ptd.cmd("Watts")
uncertainty = self._ptd.cmd("Uncertainty")
self._ptd.stop()
dirname = os.path.join(self.log_dir_path, "run_1")
os.mkdir(dirname)
Expand All @@ -973,6 +997,8 @@ def stop(self, mode: Mode) -> bool:
) # honoring format of legacy spl.txt
with open(os.path.join(dirname, "spl.txt"), "w") as f:
f.write(formatted_log_data)
with open(os.path.join(dirname, "ptd_out.txt"), "w") as f:
f.write(f"Power: {watts} \nUncertainty: {uncertainty}")
self._server._summary.phase("testing", 3)
return True

Expand Down