forked from reanahub/reana-workflow-controller
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.py
More file actions
224 lines (171 loc) · 7.83 KB
/
config.py
File metadata and controls
224 lines (171 loc) · 7.83 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
# -*- coding: utf-8 -*-
#
# This file is part of REANA.
# Copyright (C) 2017, 2018, 2019, 2020, 2021, 2022, 2023, 2024 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 Controller flask configuration."""
import os
import json
from reana_commons.config import REANA_COMPONENT_PREFIX, SHARED_VOLUME_PATH
from reana_db.models import JobStatus, RunStatus
from reana_workflow_controller.version import __version__
def _env_vars_dict_to_k8s_list(env_vars):
"""Convert env vars stored as a dictionary into a k8s-compatible list."""
return [{"name": name, "value": str(value)} for name, value in env_vars.items()]
SQLALCHEMY_TRACK_MODIFICATIONS = False
"""Track modifications flag."""
DEFAULT_NAME_FOR_WORKFLOWS = "workflow"
"""The default prefix used to name workflow(s): e.g. reana-1, reana-2, etc.
If workflow is manually named by the user that prefix will used instead.
"""
PROGRESS_STATUSES = [
("running", JobStatus.running),
("finished", JobStatus.finished),
("failed", JobStatus.failed),
("total", None),
]
WORKFLOW_QUEUES = {
"cwl": "cwl-default-queue",
"yadage": "yadage-default-queue",
"serial": "serial-default-queue",
}
SHARED_FS_MAPPING = {
"MOUNT_SOURCE_PATH": os.getenv("SHARED_VOLUME_PATH_ROOT", SHARED_VOLUME_PATH),
# Root path in the underlying shared file system to be mounted inside
# workflow engines.
"MOUNT_DEST_PATH": os.getenv("SHARED_VOLUME_PATH", SHARED_VOLUME_PATH),
# Mount path for the shared file system volume inside workflow engines.
}
"""Mapping from the shared file system backend to the job file system."""
PREVIEWABLE_MIME_TYPE_PREFIXES = ["image/", "text/html", "application/pdf"]
"""List of file mime-type prefixes that can be previewed directly from the server."""
REANA_JOB_STATUS_CONSUMER_PREFETCH_COUNT = int(
os.getenv("REANA_JOB_STATUS_CONSUMER_PREFETCH_COUNT", 10)
)
"""The value defines the max number of unacknowledged deliveries that are
permitted on a ``jobs-status`` consumer."""
REANA_WORKFLOW_ENGINE_IMAGE_CWL = os.getenv(
"REANA_WORKFLOW_ENGINE_IMAGE_CWL",
"docker.io/reanahub/reana-workflow-engine-cwl:latest",
)
"""CWL workflow engine version."""
REANA_WORKFLOW_ENGINE_IMAGE_YADAGE = os.getenv(
"REANA_WORKFLOW_ENGINE_IMAGE_YADAGE",
"docker.io/reanahub/reana-workflow-engine-yadage:latest",
)
"""Yadage workflow engine version."""
REANA_WORKFLOW_ENGINE_IMAGE_SERIAL = os.getenv(
"REANA_WORKFLOW_ENGINE_IMAGE_SERIAL",
"docker.io/reanahub/reana-workflow-engine-serial:latest",
)
"""Serial workflow engine version."""
REANA_WORKFLOW_ENGINE_IMAGE_SNAKEMAKE = os.getenv(
"REANA_WORKFLOW_ENGINE_IMAGE_SNAKEMAKE",
"docker.io/reanahub/reana-workflow-engine-snakemake:latest",
)
"""Snakemake workflow engine version."""
REANA_KUBERNETES_JOBS_MEMORY_LIMIT = os.getenv("REANA_KUBERNETES_JOBS_MEMORY_LIMIT")
"""Maximum default memory limit for user job containers. Exceeding this limit will terminate the container.
Please see the following URL for possible values
https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory.
"""
REANA_KUBERNETES_JOBS_MAX_USER_MEMORY_LIMIT = os.getenv(
"REANA_KUBERNETES_JOBS_MAX_USER_MEMORY_LIMIT"
)
"""Maximum custom memory limit that users can assign to their job containers via
``kubernetes_memory_limit`` in reana.yaml. Exceeding this limit will terminate the container.
Please see the following URL for possible values
https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory.
"""
REANA_KUBERNETES_JOBS_TIMEOUT_LIMIT = os.getenv("REANA_KUBERNETES_JOBS_TIMEOUT_LIMIT")
"""Default timeout for user's jobs in seconds. Exceeding this time will terminate the job.
Please see the following URL for more details
https://kubernetes.io/docs/concepts/workloads/controllers/job/#job-termination-and-cleanup.
"""
REANA_KUBERNETES_JOBS_MAX_USER_TIMEOUT_LIMIT = os.getenv(
"REANA_KUBERNETES_JOBS_MAX_USER_TIMEOUT_LIMIT"
)
"""Maximum custom timeout in seconds that users can assign to their jobs.
Please see the following URL for more details
https://kubernetes.io/docs/concepts/workloads/controllers/job/#job-termination-and-cleanup.
"""
WORKFLOW_ENGINE_COMMON_ENV_VARS = [
{"name": "SHARED_VOLUME_PATH", "value": SHARED_VOLUME_PATH}
]
"""Common to all workflow engines environment variables."""
WORKFLOW_ENGINE_CWL_ENV_VARS = _env_vars_dict_to_k8s_list(
json.loads(os.getenv("REANA_WORKFLOW_ENGINE_CWL_ENV_VARS", "{}"))
)
"""Environment variables to be passed to the CWL workflow engine container."""
WORKFLOW_ENGINE_SERIAL_ENV_VARS = _env_vars_dict_to_k8s_list(
json.loads(os.getenv("REANA_WORKFLOW_ENGINE_SERIAL_ENV_VARS", "{}"))
)
"""Environment variables to be passed to the serial workflow engine container."""
WORKFLOW_ENGINE_SNAKEMAKE_ENV_VARS = _env_vars_dict_to_k8s_list(
json.loads(os.getenv("REANA_WORKFLOW_ENGINE_SNAKEMAKE_ENV_VARS", "{}"))
)
"""Environment variables to be passed to the Snakemake workflow engine container."""
WORKFLOW_ENGINE_YADAGE_ENV_VARS = _env_vars_dict_to_k8s_list(
json.loads(os.getenv("REANA_WORKFLOW_ENGINE_YADAGE_ENV_VARS", "{}"))
)
"""Environment variables to be passed to the Yadage workflow engine container."""
DEBUG_ENV_VARS = (
{
"name": "WDB_SOCKET_SERVER",
"value": os.getenv("WDB_SOCKET_SERVER", f"{REANA_COMPONENT_PREFIX}-wdb"),
},
{"name": "WDB_NO_BROWSER_AUTO_OPEN", "value": "True"},
{"name": "FLASK_ENV", "value": "development"},
)
"""Common to all workflow engines environment variables for debug mode."""
JUPYTER_INTERACTIVE_SESSION_DEFAULT_IMAGE = (
"docker.io/jupyter/scipy-notebook:notebook-6.4.5"
)
"""Default image for Jupyter based interactive session deployments."""
JUPYTER_INTERACTIVE_SESSION_DEFAULT_PORT = 8888
"""Default port for Jupyter based interactive session deployments."""
JOB_CONTROLLER_IMAGE = os.getenv(
"REANA_JOB_CONTROLLER_IMAGE", "docker.io/reanahub/reana-job-controller:latest"
)
"""Default image for REANA Job Controller sidecar."""
JOB_CONTROLLER_ENV_VARS = _env_vars_dict_to_k8s_list(
json.loads(os.getenv("REANA_JOB_CONTROLLER_ENV_VARS", "{}"))
)
"""Environment variables to be passed to the job controller container."""
JOB_CONTROLLER_CONTAINER_PORT = 5000
"""Default container port for REANA Job Controller sidecar."""
JOB_CONTROLLER_SHUTDOWN_ENDPOINT = "/shutdown"
"""Endpoint of reana-job-controller used to stop all the jobs."""
JOB_CONTROLLER_NAME = "job-controller"
"""Default job controller container name."""
WORKFLOW_ENGINE_NAME = "workflow-engine"
"""Default workflow engine container name."""
REANA_GITLAB_HOST = os.getenv("REANA_GITLAB_HOST", "CHANGE_ME")
"""GitLab API HOST"""
REANA_GITLAB_URL = "https://{}".format(REANA_GITLAB_HOST)
"""GitLab API URL"""
REANA_HOSTNAME = os.getenv("REANA_HOSTNAME", "CHANGE_ME")
"""REANA URL"""
REANA_INGRESS_ANNOTATIONS = json.loads(os.getenv("REANA_INGRESS_ANNOTATIONS", "{}"))
"""REANA Ingress annotations defined by the administrator."""
REANA_INGRESS_CLASS_NAME = os.getenv("REANA_INGRESS_CLASS_NAME")
"""REANA Ingress class name defined by the administrator to be used for interactive sessions."""
REANA_INGRESS_HOST = os.getenv("REANA_INGRESS_HOST", "")
"""REANA Ingress host defined by the administrator."""
IMAGE_PULL_SECRETS = os.getenv("IMAGE_PULL_SECRETS", "").split(",")
"""Docker image pull secrets which allow the usage of private images."""
ALIVE_STATUSES = [
RunStatus.created,
RunStatus.running,
RunStatus.queued,
RunStatus.pending,
]
"""Alive workflow statuses."""
REANA_RUNTIME_BATCH_TERMINATION_GRACE_PERIOD = int(
os.getenv("REANA_RUNTIME_BATCH_TERMINATION_GRACE_PERIOD", "120")
)
"""Grace period before terminating the job controller and workflow engine pod.
The job controller needs to clean up all the running jobs before the end of the grace period.
"""