File indexing completed on 2026-04-09 07:58:22
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 """
0013 Test client.
0014 """
0015
0016
0017 from idds.client.clientmanager import ClientManager
0018 from idds.common.utils import get_rest_host
0019
0020
0021 def get_workflow():
0022 from idds.workflowv2.workflow import Workflow
0023 from idds.atlas.workflowv2.atlashpowork import ATLASHPOWork
0024
0025
0026 request_metadata = {'workload_id': '20525135', 'sandbox': None, 'method': 'nevergrad', 'opt_space': {"A": {"type": "Choice", "params": {"choices": [1, 4]}}, "B": {"type": "Scalar", "bounds": [0, 5]}}, 'initial_points': [({'A': 1, 'B': 2}, 0.3), ({'A': 1, 'B': 3}, None)], 'max_points': 20, 'num_points_per_generation': 10}
0027
0028
0029 request_metadata = {'workload_id': '20525134', 'sandbox': 'wguanicedew/idds_hpo_nevergrad', 'workdir': '/data', 'executable': 'docker', 'arguments': 'python /opt/hyperparameteropt_nevergrad.py --max_points=%MAX_POINTS --num_points=%NUM_POINTS --input=/data/%IN --output=/data/%OUT', 'output_json': 'output.json', 'opt_space': {"A": {"type": "Choice", "params": {"choices": [1, 4]}}, "B": {"type": "Scalar", "bounds": [0, 5]}}, 'initial_points': [({'A': 1, 'B': 2}, 0.3), ({'A': 1, 'B': 3}, None)], 'max_points': 20, 'num_points_per_generation': 10}
0030
0031
0032 request_metadata = {'workload_id': '20525147', 'sandbox': 'wguanicedew/idds_hpo_toymc', 'workdir': '/data', 'executable': 'docker', 'arguments': 'python /opt/hyperparameteropt_toymc.py --max_points=%MAX_POINTS --num_points=%NUM_POINTS --input=/data/%IN --output=/data/%OUT', 'output_json': 'output.json', 'opt_space': {"A": {}}, 'initial_points': [], 'max_points': 20, 'num_points_per_generation': 10}
0033
0034 work = ATLASHPOWork(executable=request_metadata.get('executable', None),
0035 arguments=request_metadata.get('arguments', None),
0036 parameters=request_metadata.get('parameters', None),
0037 setup=None, exec_type='local',
0038 sandbox=request_metadata.get('sandbox', None),
0039 method=request_metadata.get('method', None),
0040 container_workdir=request_metadata.get('workdir', None),
0041 output_json=request_metadata.get('output_json', None),
0042 opt_space=request_metadata.get('opt_space', None),
0043 initial_points=request_metadata.get('initial_points', None),
0044 max_points=request_metadata.get('max_points', None),
0045 num_points_per_iteration=request_metadata.get('num_points_per_iteration', 10))
0046 wf = Workflow()
0047 wf.set_workload_id(request_metadata.get('workload_id', None))
0048 wf.add_work(work)
0049 return wf
0050
0051
0052 if __name__ == '__main__':
0053 host = get_rest_host()
0054
0055
0056
0057
0058 workflow = get_workflow()
0059
0060
0061
0062
0063 wm = ClientManager(host=host)
0064 request_id = wm.submit(workflow)
0065 print(request_id)