|
|
|||
File indexing completed on 2026-04-10 08:39:08
0001 import argparse 0002 import sys 0003 0004 from pandacommon.pandautils.thread_utils import GenericThread 0005 0006 from pandaserver.config import panda_config 0007 from pandaserver.taskbuffer.TaskBuffer import taskBuffer 0008 0009 0010 def parse_args(): 0011 parser = argparse.ArgumentParser(description="Workflow core smoke test helper") 0012 parser.add_argument("action", choices=["cancel_workflow"], help="Action to perform in the smoke test") 0013 parser.add_argument("--force", action="store_true", help="Force into cancelled status") 0014 parser.add_argument("workflow_id", help="Workflow ID to use in commented smoke test calls") 0015 return parser.parse_args() 0016 0017 0018 # parameters for the workflow 0019 # prodsourcelabel = "user" 0020 # username = "testuser" 0021 # workflow_name = "test_workflow_bg_comb_00" 0022 0023 # workflow definition json 0024 # wfd_json = json.dumps( 0025 # json.loads( 0026 # """ 0027 # { 0028 # "root_inputs": { 0029 # "sig_bg_comb.cwl#background": "mc16_5TeV.361238.Pythia8EvtGen_A3NNPDF23LO_minbias_inelastic_low.merge.HITS.e6446_s3238_s3250/", 0030 # "sig_bg_comb.cwl#signal": "mc16_valid:mc16_valid.900248.PG_singlepion_flatPt2to50.simul.HITS.e8312_s3238_tid26378578_00" 0031 # }, 0032 # "root_outputs": {"sig_bg_comb.cwl#combine/outDS": {"value": "user.me.my_outDS_005_combine"}}, 0033 # "nodes": [ 0034 # { 0035 # "condition": null, 0036 # "data": null, 0037 # "id": 1, 0038 # "in_loop": false, 0039 # "inputs": { 0040 # "sig_bg_comb.cwl#make_signal/opt_args": { 0041 # "default": "--outputs abc.dat,def.zip --nFilesPerJob 5", 0042 # "source": null 0043 # }, 0044 # "sig_bg_comb.cwl#make_signal/opt_containerImage": { 0045 # "default": "docker://busybox", 0046 # "source": null 0047 # }, 0048 # "sig_bg_comb.cwl#make_signal/opt_exec": { 0049 # "default": "echo %IN > abc.dat; echo 123 > def.zip", 0050 # "source": null 0051 # }, 0052 # "sig_bg_comb.cwl#make_signal/opt_inDS": { 0053 # "default": null, 0054 # "source": "sig_bg_comb.cwl#signal" 0055 # } 0056 # }, 0057 # "is_head": false, 0058 # "is_leaf": true, 0059 # "is_tail": false, 0060 # "is_workflow_output": false, 0061 # "loop": false, 0062 # "name": "make_signal", 0063 # "output_types": [], 0064 # "outputs": { 0065 # "sig_bg_comb.cwl#make_signal/outDS": {} 0066 # }, 0067 # "parents": [], 0068 # "root_inputs": null, 0069 # "scatter": null, 0070 # "sub_nodes": [], 0071 # "task_params": null, 0072 # "type": "prun", 0073 # "upper_root_inputs": null 0074 # }, 0075 # { 0076 # "condition": null, 0077 # "data": null, 0078 # "id": 2, 0079 # "in_loop": false, 0080 # "inputs": { 0081 # "sig_bg_comb.cwl#make_background_1/opt_args": { 0082 # "default": "--outputs opq.root,xyz.pool --nGBPerJob 10", 0083 # "source": null 0084 # }, 0085 # "sig_bg_comb.cwl#make_background_1/opt_exec": { 0086 # "default": "echo %IN > opq.root; echo %IN > xyz.pool", 0087 # "source": null 0088 # }, 0089 # "sig_bg_comb.cwl#make_background_1/opt_inDS": { 0090 # "default": null, 0091 # "source": "sig_bg_comb.cwl#background" 0092 # } 0093 # }, 0094 # "is_head": false, 0095 # "is_leaf": true, 0096 # "is_tail": false, 0097 # "is_workflow_output": false, 0098 # "loop": false, 0099 # "name": "make_background_1", 0100 # "output_types": [], 0101 # "outputs": { 0102 # "sig_bg_comb.cwl#make_background_1/outDS": {} 0103 # }, 0104 # "parents": [], 0105 # "root_inputs": null, 0106 # "scatter": null, 0107 # "sub_nodes": [], 0108 # "task_params": null, 0109 # "type": "prun", 0110 # "upper_root_inputs": null 0111 # }, 0112 # { 0113 # "condition": null, 0114 # "data": null, 0115 # "id": 3, 0116 # "in_loop": false, 0117 # "inputs": { 0118 # "sig_bg_comb.cwl#premix/opt_args": { 0119 # "default": "--outputs klm.root --secondaryDSs IN2:2:%{SECDS1}", 0120 # "source": null 0121 # }, 0122 # "sig_bg_comb.cwl#premix/opt_exec": { 0123 # "default": "echo %IN %IN2 > klm.root", 0124 # "source": null 0125 # }, 0126 # "sig_bg_comb.cwl#premix/opt_inDS": { 0127 # "default": null, 0128 # "parent_id": 1, 0129 # "source": "sig_bg_comb.cwl#make_signal/outDS" 0130 # }, 0131 # "sig_bg_comb.cwl#premix/opt_inDsType": { 0132 # "default": "def.zip", 0133 # "source": null 0134 # }, 0135 # "sig_bg_comb.cwl#premix/opt_secondaryDSs": { 0136 # "default": null, 0137 # "parent_id": [ 0138 # 2 0139 # ], 0140 # "source": [ 0141 # "sig_bg_comb.cwl#make_background_1/outDS" 0142 # ] 0143 # }, 0144 # "sig_bg_comb.cwl#premix/opt_secondaryDsTypes": { 0145 # "default": [ 0146 # "xyz.pool" 0147 # ], 0148 # "source": null 0149 # } 0150 # }, 0151 # "is_head": false, 0152 # "is_leaf": true, 0153 # "is_tail": false, 0154 # "is_workflow_output": false, 0155 # "loop": false, 0156 # "name": "premix", 0157 # "output_types": [], 0158 # "outputs": { 0159 # "sig_bg_comb.cwl#premix/outDS": {} 0160 # }, 0161 # "parents": [ 0162 # 1, 0163 # 2 0164 # ], 0165 # "root_inputs": null, 0166 # "scatter": null, 0167 # "sub_nodes": [], 0168 # "task_params": null, 0169 # "type": "prun", 0170 # "upper_root_inputs": null 0171 # }, 0172 # { 0173 # "condition": null, 0174 # "data": null, 0175 # "id": 4, 0176 # "in_loop": false, 0177 # "inputs": { 0178 # "sig_bg_comb.cwl#generate_some/opt_args": { 0179 # "default": "--outputs gen.root --nJobs 10", 0180 # "source": null 0181 # }, 0182 # "sig_bg_comb.cwl#generate_some/opt_exec": { 0183 # "default": "echo %RNDM:10 > gen.root", 0184 # "source": null 0185 # } 0186 # }, 0187 # "is_head": false, 0188 # "is_leaf": true, 0189 # "is_tail": false, 0190 # "is_workflow_output": false, 0191 # "loop": false, 0192 # "name": "generate_some", 0193 # "output_types": [], 0194 # "outputs": { 0195 # "sig_bg_comb.cwl#generate_some/outDS": {} 0196 # }, 0197 # "parents": [], 0198 # "root_inputs": null, 0199 # "scatter": null, 0200 # "sub_nodes": [], 0201 # "task_params": null, 0202 # "type": "prun", 0203 # "upper_root_inputs": null 0204 # }, 0205 # { 0206 # "condition": null, 0207 # "data": null, 0208 # "id": 5, 0209 # "in_loop": false, 0210 # "inputs": { 0211 # "sig_bg_comb.cwl#make_background_2/opt_args": { 0212 # "default": "--outputs ooo.root,jjj.txt --secondaryDSs IN2:2:%{SECDS1}", 0213 # "source": null 0214 # }, 0215 # "sig_bg_comb.cwl#make_background_2/opt_containerImage": { 0216 # "default": "docker://alpine", 0217 # "source": null 0218 # }, 0219 # "sig_bg_comb.cwl#make_background_2/opt_exec": { 0220 # "default": "echo %IN > ooo.root; echo %IN2 > jjj.txt", 0221 # "source": null 0222 # }, 0223 # "sig_bg_comb.cwl#make_background_2/opt_inDS": { 0224 # "default": null, 0225 # "source": "sig_bg_comb.cwl#background" 0226 # }, 0227 # "sig_bg_comb.cwl#make_background_2/opt_secondaryDSs": { 0228 # "default": null, 0229 # "parent_id": [ 0230 # 4 0231 # ], 0232 # "source": [ 0233 # "sig_bg_comb.cwl#generate_some/outDS" 0234 # ] 0235 # }, 0236 # "sig_bg_comb.cwl#make_background_2/opt_secondaryDsTypes": { 0237 # "default": [ 0238 # "gen.root" 0239 # ], 0240 # "source": null 0241 # } 0242 # }, 0243 # "is_head": false, 0244 # "is_leaf": true, 0245 # "is_tail": false, 0246 # "is_workflow_output": false, 0247 # "loop": false, 0248 # "name": "make_background_2", 0249 # "output_types": [], 0250 # "outputs": { 0251 # "sig_bg_comb.cwl#make_background_2/outDS": {} 0252 # }, 0253 # "parents": [ 0254 # 4 0255 # ], 0256 # "root_inputs": null, 0257 # "scatter": null, 0258 # "sub_nodes": [], 0259 # "task_params": null, 0260 # "type": "prun", 0261 # "upper_root_inputs": null 0262 # }, 0263 # { 0264 # "condition": null, 0265 # "data": null, 0266 # "id": 6, 0267 # "in_loop": false, 0268 # "inputs": { 0269 # "sig_bg_comb.cwl#combine/opt_args": { 0270 # "default": "--outputs aaa.root --secondaryDSs IN2:2:%{SECDS1},IN3:5:%{SECDS2}", 0271 # "source": null 0272 # }, 0273 # "sig_bg_comb.cwl#combine/opt_exec": { 0274 # "default": "echo %IN %IN2 %IN3 > aaa.root", 0275 # "source": null 0276 # }, 0277 # "sig_bg_comb.cwl#combine/opt_inDS": { 0278 # "default": null, 0279 # "parent_id": 1, 0280 # "source": "sig_bg_comb.cwl#make_signal/outDS" 0281 # }, 0282 # "sig_bg_comb.cwl#combine/opt_inDsType": { 0283 # "default": "abc.dat", 0284 # "source": null 0285 # }, 0286 # "sig_bg_comb.cwl#combine/opt_secondaryDSs": { 0287 # "default": null, 0288 # "parent_id": [ 0289 # 3, 0290 # 5 0291 # ], 0292 # "source": [ 0293 # "sig_bg_comb.cwl#premix/outDS", 0294 # "sig_bg_comb.cwl#make_background_2/outDS" 0295 # ] 0296 # }, 0297 # "sig_bg_comb.cwl#combine/opt_secondaryDsTypes": { 0298 # "default": [ 0299 # "klm.root", 0300 # "ooo.root" 0301 # ], 0302 # "source": null 0303 # } 0304 # }, 0305 # "is_head": false, 0306 # "is_leaf": true, 0307 # "is_tail": true, 0308 # "is_workflow_output": false, 0309 # "loop": false, 0310 # "name": "combine", 0311 # "output_types": [], 0312 # "outputs": { 0313 # "sig_bg_comb.cwl#combine/outDS": {} 0314 # }, 0315 # "parents": [ 0316 # 1, 0317 # 3, 0318 # 5 0319 # ], 0320 # "root_inputs": null, 0321 # "scatter": null, 0322 # "sub_nodes": [], 0323 # "task_params": null, 0324 # "type": "prun", 0325 # "upper_root_inputs": null 0326 # } 0327 # ] 0328 # } 0329 # """ 0330 # ) 0331 # ) 0332 0333 0334 def main(): 0335 args = parse_args() 0336 WFID = args.workflow_id 0337 action = args.action 0338 force = args.force 0339 0340 from pandaserver.workflow.workflow_core import WorkflowInterface 0341 0342 # interface for workflow operations 0343 requester_id = GenericThread().get_full_id(__name__, sys.modules[__name__].__file__) 0344 taskBuffer.init( 0345 panda_config.dbhost, 0346 panda_config.dbpasswd, 0347 nDBConnection=panda_config.nDBConnection, 0348 useTimeout=True, 0349 requester=requester_id, 0350 ) 0351 0352 wfif = WorkflowInterface(taskBuffer) 0353 0354 # Test cases for workflow core 0355 0356 # Register the workflow 0357 # print("Registering workflow...") 0358 # wf_spec = wfif.register_workflow( 0359 # prodsourcelabel=prodsourcelabel, 0360 # username=username, 0361 # workflow_name=workflow_name, 0362 # workflow_definition_json=wfd_json, 0363 # ) 0364 0365 # Process the registered workflow 0366 # wf_spec = taskBuffer.get_workflow(workflow_id=WFID) 0367 # print("Processing registered workflow...") 0368 # wfif.process_workflow_registered(wf_spec) 0369 0370 # wf_spec = taskBuffer.get_workflow(workflow_id=WFID) 0371 # print("Processing checked workflow...") 0372 # wfif.process_workflow_checked(wf_spec) 0373 0374 # wf_spec = taskBuffer.get_workflow(workflow_id=WFID) 0375 # print("Processing starting workflow...") 0376 # wfif.process_workflow_starting(wf_spec) 0377 0378 if args.action == "cancel_workflow": 0379 print(f"Cancelling workflow_id={WFID} ...") 0380 res = wfif.cancel_workflow(workflow_id=WFID, force=args.force) 0381 if res: 0382 print(f"Cancelled workflow_id={WFID} successfully.") 0383 else: 0384 print(f"Failed to cancel workflow_id={WFID}.") 0385 0386 0387 if __name__ == "__main__": 0388 main()
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|