Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-09 07:58:21

0001 #!/usr/bin/env python
0002 #
0003 # Licensed under the Apache License, Version 2.0 (the "License");
0004 # You may not use this file except in compliance with the License.
0005 # You may obtain a copy of the License at
0006 # http://www.apache.org/licenses/LICENSE-2.0OA
0007 #
0008 # Authors:
0009 # - Wen Guan, <wen.guan@cern.ch>, 2020
0010 
0011 
0012 """
0013 Test hyper parameter optimization test  client.
0014 """
0015 
0016 import sys
0017 
0018 from idds.client.client import Client
0019 from idds.common.utils import get_rest_host
0020 
0021 if len(sys.argv) == 2:
0022     workload_id = sys.argv[1]
0023     request_id = None
0024 elif len(sys.argv) == 3:
0025     workload_id = sys.argv[1]
0026     request_id = sys.argv[2]
0027 
0028 # host = "https://aipanda181.cern.ch:443/idds"
0029 host = get_rest_host()
0030 
0031 client = Client(host=host)
0032 # props['request_metadata']['result_parser'] = 'default'
0033 
0034 params = client.get_hyperparameters(workload_id=workload_id, request_id=request_id)
0035 print(params)
0036 if not params:
0037     print("No parameters")
0038 else:
0039     param_0 = client.get_hyperparameters(workload_id=workload_id, request_id=request_id, id=0)
0040     print(param_0)
0041     if not param_0:
0042         print("failed to get param 0")
0043     for param in params:
0044         id = param['id']
0045         if param['loss'] is None:
0046             print("updating %s" % id)
0047             ret = client.update_hyperparameter(workload_id=workload_id, request_id=request_id, id=id, loss=0.3)
0048             print(ret)
0049             break