-
Notifications
You must be signed in to change notification settings - Fork 44
Expand file tree
/
Copy pathtasks.py
More file actions
61 lines (48 loc) · 1.58 KB
/
Copy pathtasks.py
File metadata and controls
61 lines (48 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# -*- coding: utf-8 -*-
#
# This file is part of REANA.
# Copyright (C) 2017, 2018, 2019, 2020, 2021 CERN.
#
# REANA is free software; you can redistribute it and/or modify it
# under the terms of the MIT License; see LICENSE file for more details.
"""REANA Workflow Engine CWL tasks."""
from __future__ import absolute_import, print_function
import logging
from reana_commons.workflow_engine import create_workflow_engine_command
from reana_workflow_engine_cwl import main
from reana_workflow_engine_cwl.config import LOGGING_MODULE
log = logging.getLogger(LOGGING_MODULE)
def rcode_to_workflow_status(response_code):
"""Map the cwl tool exit code to a workflow status."""
rcode_to_workflow_status_mapping = {0: 2, 1: 3}
return rcode_to_workflow_status_mapping[response_code]
def run_cwl_workflow_engine_adapter(
publisher,
rjc_api_client,
workflow_uuid=None,
workflow_workspace=None,
workflow_json=None,
workflow_resources=None,
workflow_parameters=None,
operational_options={},
**kwargs,
):
"""Run cwl workflow."""
log.info(f"running workflow on context: {locals()}")
rcode, logs = main.main(
publisher,
rjc_api_client,
workflow_uuid,
workflow_json,
workflow_resources,
workflow_parameters,
operational_options,
workflow_workspace,
)
log.info("workflow done")
publisher.publish_workflow_status(
workflow_uuid, rcode_to_workflow_status(rcode), logs
)
run_cwl_workflow = create_workflow_engine_command(
run_cwl_workflow_engine_adapter, engine_type="cwl"
)