-
Notifications
You must be signed in to change notification settings - Fork 24
workflows4: PanDA native workflow engine first merge #672
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
mightqxc
wants to merge
185
commits into
master
Choose a base branch
from
workflows4
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
185 commits
Select commit
Hold shift + click to select a range
a0d72ac
workflow: regain changes
mightqxc f79ba0b
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc abadf0e
workflow: temp func
mightqxc b2b3925
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc f8cda98
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc c4dcd68
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 1206334
preliminary workflow core
mightqxc c3d78a1
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 95ea64b
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 17d8128
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc b0dd610
workflow: preliminary dbproxy methods
mightqxc 53d6126
fix
mightqxc 25a59db
workflow: add test register
mightqxc 730f36c
workflow: update taskbuffer
mightqxc 7bc10bd
workflow: add insert functions
mightqxc 2976f4a
fixes
mightqxc 204a61a
workflow: add process registered workflow
mightqxc da06be0
fix
mightqxc 4edf1f7
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 2cb0860
workflow: update schema, preliminary handlers
mightqxc 4927322
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 3a9b210
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 0974cc9
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 7d90a5e
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc ffc8f03
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc ef30129
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 574507e
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 51f5591
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 222bab5
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 0f01c99
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc f35473a
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 0f22282
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 84693b7
add workflow api
mightqxc 7d22bdd
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 4ad2ba5
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 34db560
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc b958b53
workflows4: allow to submit raw request
mightqxc 17d333e
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc deefcc3
workflows4: parse workflow
mightqxc 4c253af
workflows4: fix
mightqxc e013b08
workflows4: parsed to starting
mightqxc 05b68ee
workflows4: workflow starting
mightqxc 017f9e5
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 26c9fe6
fix
mightqxc 3616531
fix
mightqxc 418968d
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc d22b754
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 66aba52
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 16bccf7
workflows4: step submit target
mightqxc 24d9029
workflows4: fix submit task
mightqxc 78c9b04
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 937fb57
workflows4: reuse plugin instance
mightqxc f23c17b
workflows4: add check step and result obj
mightqxc 23df71e
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 0296e16
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc bf69565
workflows4: process running workflow
mightqxc cb26be4
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc e52b64a
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 4df06c1
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 858fa64
workflows4: more status transition, add ddm data handler
mightqxc 06c05fc
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 09ff0fb
workflows4: add data process methods and ddm_collection data handler
mightqxc 7a48337
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc e25637f
workflows4: add native workflow watchdog
mightqxc f954b66
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc fa60a58
workflows4: fix
mightqxc 9070f7b
workflows4: fix
mightqxc 189f08a
workflows4: fix
mightqxc 3065119
workflows4: fix data handler and data check status
mightqxc ec247ee
workflows4: fix mid data
mightqxc 119b01f
workflows4: fix
mightqxc 0796dc9
workflows4: fix, add data step_source_id
mightqxc c65995f
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 2f9423c
workflows4: pretty
mightqxc 10dfc8e
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 528a75c
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc db321c2
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc c6a0379
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 131a0f6
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 5de0932
workflows4: fix by test
mightqxc afc6e93
workflows4: data target suffix about output_types
mightqxc 9f14ecc
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc a200c8c
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc d59339b
workflows4: fix data status
mightqxc 2152dca
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc c45228d
workflows4: add panda task data handler, rename data status
mightqxc 9678ec4
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 7fe46da
workflows4: fixes
mightqxc b74c6ee
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 602c3a7
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 1f29d5a
workflows4: fix
mightqxc 7b056f4
workflows4: fixes
mightqxc 7630d70
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 9bd6f8e
workflows4: fix about data status
mightqxc 393c9c3
workflows4: fix step start_time and end_time
mightqxc 4ee9eaf
workflows4: rename step status submitted to starting
mightqxc 01c06ad
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 421900f
workflows4: log
mightqxc c16e559
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 088d504
workflows4: check step output during checking
mightqxc dd5617d
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 7faa455
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 6dc443d
workflows4: introduce data status binding
mightqxc 5faeffc
workflows4: fix binding
mightqxc acb96f3
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc e145f56
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 6281fbc
workflows4: rename statuses
mightqxc 568f4df
workflows4: status pretty
mightqxc ba79dc3
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 02f428f
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 4359e3a
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc b4cd251
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 8e5a3c1
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc c061194
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 3366682
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 766ec5f
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc cc0098c
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc cc485c9
workflows4: add workflowHoldup task param
mightqxc a9fab09
workflows4: fix for workflowHoldup
mightqxc 4c4000e
workflows4: fix test mutable for workflowholdup
mightqxc e2b227d
workflows4: fix
mightqxc 2bb5f44
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 7420a02
workflows4: fix
mightqxc 84cb281
tmp fix
mightqxc 94413de
workflows4: fix for holdup by nReady
mightqxc 7ed55dc
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 6dbee69
workflows4: fix
mightqxc 672caeb
workflows4: improve hook to release task
mightqxc 391d178
workflows4: fix
mightqxc 6d9d25f
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc b29aa28
workflows4: rename watchdog to be workflow manager
mightqxc dc90947
workflows4: add messaging for fast forward transient status
mightqxc ec662de
workflows4: fixes
mightqxc 51837c8
workflows4: break down processing methods
mightqxc b198f3e
workflows4: fix step and data lock for messaging
mightqxc dfcd9b0
workflows4: pretty log
mightqxc 256eeb1
pretty
mightqxc 0165649
workflows4: log
mightqxc 5723ff4
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 1d341bb
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 3f876b0
Merge remote-tracking branch 'origin/master' into workflows4
b27df67
Merge remote-tracking branch 'origin/master' into workflows4
b2034d5
workflows4: improve step status map for pending task
mightqxc 8a1be88
test
mightqxc 2b0d14e
test
mightqxc 17248f6
test
mightqxc d8aab08
workflows4: improve step status mapping with task superstatus
mightqxc 409d95b
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc e5be752
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc a934a65
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 8d98105
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc fcbebd1
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 173e246
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 5f2ecbb
workflows4: fixes by copilot
mightqxc 2e48f5f
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc b6b59b1
Update pandaserver/workflow/workflow_utils.py
mightqxc bb50773
Update pandaserver/workflow/workflow_parser.py
mightqxc 1bae97a
Update pandaserver/workflow/workflow_parser.py
mightqxc 31bd56b
typo in pandaserver/taskbuffer/db_proxy_mods/workflow_module.py
mightqxc 209c393
typo pandaserver/workflow/workflow_utils.py
mightqxc 8e8a66a
Update pandaserver/workflow/workflow_parser.py
mightqxc 6cc92f6
workflows4: fix parser to guarantee chdir to original dir
mightqxc f97ac89
workflows4: use tarfile instead of tar command
mightqxc b9eb181
workflows4: fix utils according to copilot
mightqxc d2433da
workflows4: improve test script
mightqxc 9dcb224
workflows4: fix stats of status change of entities
mightqxc 2d2d2bf
Update pandaserver/workflow/workflow_core_smoketest.py
mightqxc 812cfaf
Update pandaserver/workflow/step_handler_plugins/panda_task_step_hand…
mightqxc c498fac
Update pandajedi/jedidog/AtlasWorkflowManagerWatchDog.py
mightqxc e8fd04f
Update pandaserver/workflow/step_handler_plugins/base_step_handler.py
mightqxc 7b3f568
workflows4: update workflow checktime
mightqxc 178455e
workflows4: fix resolve_nodes
mightqxc 38135ba
Merge remote-tracking branch 'origin/workflows4' into workflows4
mightqxc 18a5fd7
workflows4: default lock time
mightqxc a5a7e97
v0.7.2
mightqxc cf5eba8
v0.8.0; update DB schema version
mightqxc 86f76fe
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc fc3636e
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 4f7da4e
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc ab70b08
Merge remote-tracking branch 'origin/master' into workflows4
mightqxc 00086db
update dependency
mightqxc ff8c93a
workflows4: add cancel_workflow
mightqxc d5b6f1d
workflows4: fixes
mightqxc c0f77c9
log pretty
mightqxc 388667c
workflows4: reuse DDM interface
mightqxc File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| release_version = "0.7.2" | ||
| release_version = "0.8.0" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| import sys | ||
| import traceback | ||
|
|
||
| # logger | ||
| from pandacommon.pandalogger.PandaLogger import PandaLogger | ||
|
|
||
| from pandajedi.jedicore.MsgWrapper import MsgWrapper | ||
| from pandaserver.workflow.workflow_core import WorkflowInterface | ||
|
|
||
| from .WatchDogBase import WatchDogBase | ||
|
|
||
| logger = PandaLogger().getLogger(__name__.split(".")[-1]) | ||
|
|
||
|
|
||
| class AtlasWorkflowManagerWatchDog(WatchDogBase): | ||
| """ | ||
| Workflow manager watchdog for ATLAS | ||
| """ | ||
|
|
||
| # constructor | ||
| def __init__(self, taskBufferIF, ddmIF): | ||
| WatchDogBase.__init__(self, taskBufferIF, ddmIF) | ||
| self.vo = "atlas" | ||
| self.workflow_interface = WorkflowInterface(taskBufferIF) | ||
|
|
||
| def doProcessWorkflows(self): | ||
| """ | ||
| Action to process active workflows | ||
| """ | ||
| tmpLog = MsgWrapper(logger, " #ATM #KV doProcessWorkflows") | ||
| tmpLog.debug("start") | ||
| try: | ||
| # watchdog lock | ||
| got_lock = self.get_process_lock("AtlasWFManagerDog.doProcessWorkflows", timeLimit=5) | ||
| if not got_lock: | ||
| tmpLog.debug("locked by another watchdog process. Skipped") | ||
| return | ||
| tmpLog.debug("got watchdog lock") | ||
| # process active workflows | ||
| stats = self.workflow_interface.process_active_workflows() | ||
| tmpLog.info(f"processed workflows: {stats}") | ||
| # done | ||
| tmpLog.debug("done") | ||
| except Exception: | ||
| errtype, errvalue = sys.exc_info()[:2] | ||
| tmpLog.error(f"failed with {errtype} {errvalue} {traceback.format_exc()}") | ||
|
|
||
| # main | ||
| def doAction(self): | ||
| try: | ||
| # get logger | ||
| origTmpLog = MsgWrapper(logger) | ||
| origTmpLog.debug("start") | ||
| # clean up | ||
| # check | ||
| # process workflows | ||
| self.doProcessWorkflows() | ||
| except Exception: | ||
| errtype, errvalue = sys.exc_info()[:2] | ||
| origTmpLog.error(f"failed with {errtype} {errvalue}") | ||
| # return | ||
| origTmpLog.debug("done") | ||
| return self.SC_SUCCEEDED |
89 changes: 89 additions & 0 deletions
89
pandajedi/jedimsgprocessor/workflow_manager_msg_processor.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| import json | ||
|
|
||
| from pandacommon.pandalogger import logger_utils | ||
|
|
||
| from pandajedi.jedimsgprocessor.base_msg_processor import BaseMsgProcPlugin | ||
| from pandaserver.workflow.workflow_core import WorkflowInterface | ||
|
|
||
| base_logger = logger_utils.setup_logger(__name__.split(".")[-1]) | ||
|
|
||
|
|
||
| # Workflow manager message processor plugin | ||
| class WorkflowManagerMsgProcPlugin(BaseMsgProcPlugin): | ||
| """ | ||
| Message-driven workflow manager | ||
| """ | ||
|
|
||
| def initialize(self): | ||
| """ | ||
| Initialize the plugin | ||
| """ | ||
| BaseMsgProcPlugin.initialize(self) | ||
| self.workflow_interface = WorkflowInterface(self.tbIF) | ||
|
|
||
| def process(self, msg_obj): | ||
| """ | ||
| Process the message | ||
| Typical message data looks like: | ||
| {"msg_type":"workflow", "workflow_id": 123, "timestamp": 987654321} | ||
| {"msg_type":"wfstep", "step_id": 456, "timestamp": 987654321} | ||
| {"msg_type":"wfdata", "data_id": 789, "timestamp": 987654321} | ||
|
|
||
| Args: | ||
| msg_obj: message object | ||
| """ | ||
| tmp_log = logger_utils.make_logger(base_logger, token=self.get_pid(), method_name="process") | ||
| # start | ||
| tmp_log.info("start") | ||
| tmp_log.debug(f"sub_id={msg_obj.sub_id} ; msg_id={msg_obj.msg_id}") | ||
| # parse json | ||
| try: | ||
| msg_dict = json.loads(msg_obj.data) | ||
| except Exception as e: | ||
| err_str = f"failed to parse message json {msg_obj.data} , skipped. {e.__class__.__name__} : {e}" | ||
| tmp_log.error(err_str) | ||
| raise | ||
| # sanity check | ||
| try: | ||
| msg_type = msg_dict["msg_type"] | ||
| except Exception as e: | ||
| err_str = f"failed to parse message object dict {msg_dict} , skipped. {e.__class__.__name__} : {e}" | ||
| tmp_log.error(err_str) | ||
| raise | ||
| if msg_type not in ("workflow", "wfstep", "wfdata"): | ||
| err_str = f"got unknown msg_type {msg_type} , skipped " | ||
| tmp_log.error(err_str) | ||
| raise | ||
| # run | ||
| try: | ||
| tmp_log.info(f"got message {msg_dict}") | ||
| if msg_type == "workflow": | ||
| workflow_id = msg_dict["workflow_id"] | ||
| workflow_spec = self.tbIF.get_workflow(workflow_id) | ||
| if workflow_spec is None: | ||
| tmp_log.warning(f"workflow_id={workflow_id} not found; skipped") | ||
| return | ||
| stats, workflow_spec = self.workflow_interface.process_workflow(workflow_spec, by="msg") | ||
| tmp_log.info(f"processed workflow_id={workflow_id}") | ||
| elif msg_type == "wfstep": | ||
| step_id = msg_dict["step_id"] | ||
| step_spec = self.tbIF.get_workflow_step(step_id) | ||
| if step_spec is None: | ||
| tmp_log.warning(f"step_id={step_id} not found; skipped") | ||
| return | ||
| stats, step_spec = self.workflow_interface.process_step(step_spec, by="msg") | ||
| tmp_log.info(f"processed step_id={step_id}") | ||
| elif msg_type == "wfdata": | ||
| data_id = msg_dict["data_id"] | ||
| data_spec = self.tbIF.get_workflow_data(data_id) | ||
| if data_spec is None: | ||
| tmp_log.warning(f"data_id={data_id} not found; skipped") | ||
| return | ||
| stats, data_spec = self.workflow_interface.process_data(data_spec, by="msg") | ||
| tmp_log.info(f"processed data_id={data_id}") | ||
| except Exception as e: | ||
| err_str = f"failed to run, skipped. {e.__class__.__name__} : {e}" | ||
| tmp_log.error(err_str) | ||
| raise | ||
| # done | ||
| tmp_log.info("done") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,136 @@ | ||
| import datetime | ||
| import json | ||
| from concurrent.futures import ThreadPoolExecutor | ||
| from threading import Lock | ||
| from typing import Any, Dict, List | ||
|
|
||
| from pandacommon.pandalogger.LogWrapper import LogWrapper | ||
| from pandacommon.pandalogger.PandaLogger import PandaLogger | ||
| from pandacommon.pandautils.PandaUtils import naive_utcnow | ||
|
|
||
| from pandaserver.api.v1.common import ( | ||
| MESSAGE_DATABASE, | ||
| TIME_OUT, | ||
| TimedMethod, | ||
| generate_response, | ||
| get_dn, | ||
| has_production_role, | ||
| request_validation, | ||
| ) | ||
| from pandaserver.srvcore.panda_request import PandaRequest | ||
| from pandaserver.taskbuffer.TaskBuffer import TaskBuffer | ||
| from pandaserver.workflow.workflow_core import WorkflowInterface | ||
|
|
||
| _logger = PandaLogger().getLogger("api_workflow") | ||
|
|
||
| # These global variables are initialized in the init_task_buffer method | ||
| global_task_buffer = None | ||
| global_wfif = None | ||
|
|
||
| # These global variables don't depend on DB access and can be initialized here | ||
| # global_proxy_cache = panda_proxy_cache.MyProxyInterface() | ||
| # global_token_cache = token_cache.TokenCache() | ||
|
|
||
|
|
||
| def init_task_buffer(task_buffer: TaskBuffer) -> None: | ||
| """ | ||
| Initialize the task buffer and other interfaces. This method needs to be called before any other method in this module. | ||
| """ | ||
| global global_task_buffer | ||
| global_task_buffer = task_buffer | ||
|
|
||
| global global_wfif | ||
| global_wfif = WorkflowInterface(global_task_buffer) | ||
|
|
||
|
|
||
| @request_validation(_logger, secure=True, production=False, request_method="POST") | ||
| def submit_workflow_raw_request(req: PandaRequest, params: dict | str) -> dict: | ||
| """ | ||
| Submit raw request of PanDA native workflow. | ||
|
|
||
| API details: | ||
| HTTP Method: POST | ||
| Path: /v1/workflow/submit_workflow_raw_request | ||
|
|
||
| Args: | ||
| req(PandaRequest): internally generated request object containing the env variables | ||
| params (dict|str): dictionary or JSON of parameters of the raw request | ||
|
|
||
| Returns: | ||
| dict: dictionary `{'success': True/False, 'message': 'Description of error', 'data': <requested data>}` | ||
| """ | ||
|
|
||
| user_dn = get_dn(req) | ||
| prodsourcelabel = "user" | ||
|
|
||
| # FIXME: only for analysis temporarily | ||
| # if has_production_role(req): | ||
| # prodsourcelabel = "managed" | ||
|
|
||
| tmp_logger = LogWrapper(_logger, f'submit_workflow_raw_request prodsourcelabel={prodsourcelabel} user_dn="{user_dn}" ') | ||
| tmp_logger.debug("Start") | ||
| success, message, data = False, "", None | ||
| time_start = naive_utcnow() | ||
|
|
||
| if isinstance(params, str): | ||
| try: | ||
| params = json.loads(params) | ||
| except Exception as exc: | ||
| message = f"Failed to parse params: {params} {str(exc)}" | ||
| tmp_logger.error(message) | ||
| return generate_response(success, message, data) | ||
|
|
||
| workflow_id = global_wfif.register_workflow(prodsourcelabel, user_dn, raw_request_params=params) | ||
|
|
||
| if workflow_id is not None: | ||
| success = True | ||
| data = {"workflow_id": workflow_id} | ||
| else: | ||
| message = "Failed to submit raw workflow request" | ||
|
|
||
| time_delta = naive_utcnow() - time_start | ||
| tmp_logger.debug(f"Done. Took {time_delta.seconds}.{time_delta.microseconds // 1000:03d} sec") | ||
|
|
||
| return generate_response(success, message, data) | ||
|
|
||
|
|
||
| @request_validation(_logger, secure=True, production=False, request_method="POST") | ||
| def submit_workflow(req: PandaRequest, workflow_definition: dict) -> dict: | ||
| """ | ||
| Submit a PanDA native workflow. | ||
|
|
||
| API details: | ||
| HTTP Method: POST | ||
| Path: /v1/workflow/submit_workflow | ||
|
|
||
| Args: | ||
| req(PandaRequest): internally generated request object containing the env variables | ||
| workflow_definition (dict): dictionary of workflow definition | ||
|
|
||
| Returns: | ||
| dict: dictionary `{'success': True/False, 'message': 'Description of error', 'data': <requested data>}` | ||
| """ | ||
|
|
||
| user_dn = get_dn(req) | ||
| prodsourcelabel = "user" | ||
| if has_production_role(req): | ||
| prodsourcelabel = "managed" | ||
| workflow_name = workflow_definition.get("workflow_name", None) | ||
|
|
||
| tmp_logger = LogWrapper(_logger, f'submit_workflow prodsourcelabel={prodsourcelabel} user_dn="{user_dn}" workflow_name={workflow_name}') | ||
| tmp_logger.debug("Start") | ||
| success, message, data = False, "", None | ||
| time_start = naive_utcnow() | ||
|
|
||
| workflow_id = global_wfif.register_workflow(prodsourcelabel, user_dn, workflow_name, workflow_definition) | ||
|
|
||
| if workflow_id is not None: | ||
| success = True | ||
| data = {"workflow_id": workflow_id} | ||
| else: | ||
| message = "Failed to submit workflow" | ||
|
|
||
| time_delta = naive_utcnow() - time_start | ||
| tmp_logger.debug(f"Done. Took {time_delta.seconds}.{time_delta.microseconds // 1000:03d} sec") | ||
|
|
||
| return generate_response(success, message, data) | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.