From 802553269a79d88a7f5610f08bb9dd3e49b2cf4b Mon Sep 17 00:00:00 2001 From: andrew Date: Wed, 21 Jun 2023 00:25:23 -0400 Subject: [PATCH] Allow -I or --identity= to pass a nickname for a machine Display this information on machines list, individual machine page, and on the error log --- Client/Client.py | 6 ++++++ OpenBench/templatetags/mytags.py | 7 +++++++ Templates/OpenBench/errors.html | 4 +++- Templates/OpenBench/machine.html | 1 + Templates/OpenBench/machines.html | 2 ++ 5 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Client/Client.py b/Client/Client.py index 1122604..323768b 100644 --- a/Client/Client.py +++ b/Client/Client.py @@ -87,6 +87,7 @@ SYSTEM_MAC_ADDRESS = hex(uuid.getnode()).upper()[2:] SYSTEM_LOGICAL_CORES = psutil.cpu_count(logical=True) SYSTEM_PHYSICAL_CORES = psutil.cpu_count(logical=False) SYSTEM_RAM_TOTAL_MB = psutil.virtual_memory().total // (1024 ** 2) +SYSTEM_MACHINE_NAME = 'None' SYSTEM_MACHINE_ID = 'None' SYSTEM_SECRET_TOKEN = 'None' @@ -520,6 +521,7 @@ def server_configure_worker(arguments): 'physical_cores' : SYSTEM_PHYSICAL_CORES, # Physical cores, to differentiate hyperthreads 'ram_total_mb' : SYSTEM_RAM_TOTAL_MB, # Total RAM on the system, to avoid over assigning 'machine_id' : SYSTEM_MACHINE_ID, # Assigned value, or None. Will be replaced if wrong + 'machine_name' : SYSTEM_MACHINE_NAME, # Optional pseudonym for the machine, otherwise None 'concurrency' : arguments.threads, # Threads to use to play games 'ncutechesses' : arguments.ncutechess, # Cutechess copies, usually equal to Socket count 'client_ver' : CLIENT_VERSION, # Version of the Client, which the server may reject @@ -1060,6 +1062,7 @@ if __name__ == '__main__': p.add_argument('-S', '--server' , help='Webserver Address' , required=True) p.add_argument('-T', '--threads' , help='Total Threads' , required=True) p.add_argument('-N', '--ncutechess' , help='Cutechess Copies' , required=True) + p.add_argument('-I', '--identity' , help='Machine pseudonym' , required=False) # Optional arguments p.add_argument('--syzygy', help='Syzygy WDL' , required=False) @@ -1083,6 +1086,9 @@ if __name__ == '__main__': if arguments.password is None: arguments.password = os.environ['OPENBENCH_PASSWORD'] + if arguments.identity: + SYSTEM_MACHINE_NAME = arguments.identity + if arguments.syzygy is not None: SYZYGY_WDL_PATH = arguments.syzygy diff --git a/OpenBench/templatetags/mytags.py b/OpenBench/templatetags/mytags.py index f78b1e3..cf06f95 100644 --- a/OpenBench/templatetags/mytags.py +++ b/OpenBench/templatetags/mytags.py @@ -201,6 +201,12 @@ def compilerBlock(machine): def removePrefix(value, prefix): return value.removeprefix(prefix) +def machine_name(machine_id): + try: + machine = OpenBench.models.Machine.objects.get(id=machine_id) + return machine.info['machine_name'] + except: return 'None' + register = django.template.Library() register.filter('oneDigitPrecision', oneDigitPrecision) register.filter('twoDigitPrecision', twoDigitPrecision) @@ -219,3 +225,4 @@ register.filter('testIdToTimeControl', testIdToTimeControl) register.filter('cpuflagsBlock', cpuflagsBlock) register.filter('compilerBlock', compilerBlock) register.filter('removePrefix', removePrefix) +register.filter('machine_name', machine_name) diff --git a/Templates/OpenBench/errors.html b/Templates/OpenBench/errors.html index 5a23ac0..3f5e542 100644 --- a/Templates/OpenBench/errors.html +++ b/Templates/OpenBench/errors.html @@ -8,8 +8,9 @@ Date - Worker + # User + Name Test Summary Logs @@ -20,6 +21,7 @@ {{event.created|date:'U'}} {{event.machine_id}} {{event.author|capfirst}} + {{event.machine_id|machine_name}} {{event.test_id|testIdToPrettyName}} {{event.summary}} diff --git a/Templates/OpenBench/machine.html b/Templates/OpenBench/machine.html index 86cf537..e8c1583 100644 --- a/Templates/OpenBench/machine.html +++ b/Templates/OpenBench/machine.html @@ -13,6 +13,7 @@ + diff --git a/Templates/OpenBench/machines.html b/Templates/OpenBench/machines.html index 0de806c..deaa22a 100644 --- a/Templates/OpenBench/machines.html +++ b/Templates/OpenBench/machines.html @@ -9,6 +9,7 @@ + @@ -20,6 +21,7 @@ +
User{{machine.user.username}}
Machine Name{{machine.info.machine_name}}
Client Version{{machine.info.client_ver}}
Python Version{{machine.info.python_ver}}
System Version{{machine.info.os_name}} {{machine.info.os_ver}}
# UserName System CPU Workload
{{machine.id}} {{machine.user.username|capfirst}}{{machine.info.machine_name}} {{machine.info.os_name}} {{machine.info.cpu_name}}