1
1
"""Custom app config models."""
2
2
3
3
from typing import Optional
4
- from pathlib import Path
5
-
6
4
from pydantic import BaseModel # pylint: disable=no-name-in-module
7
5
from typing import List
8
6
from pro_wes .ga4gh .wes .models import ServiceInfoBase as ServiceInfo
7
+ import string
8
+
9
9
10
10
# pragma pylint: disable=too-few-public-methods
11
11
12
+
12
13
class DB (BaseModel ):
13
14
"""DB config for post_task.
14
15
@@ -18,6 +19,7 @@ class DB(BaseModel):
18
19
Attributes:
19
20
insert_attempts: Number of attempts to insert a new task in DB.
20
21
"""
22
+
21
23
insert_attempts : int = 10
22
24
23
25
@@ -32,6 +34,7 @@ class TaskID(BaseModel):
32
34
charset: Characters to use when generating task IDs.
33
35
length: Length of the generated task ID.
34
36
"""
37
+
35
38
charset : str = string .ascii_uppercase + string .digits
36
39
length : int = 6
37
40
@@ -49,6 +52,7 @@ class Timeout(BaseModel):
49
52
poll: Timeout for polling.
50
53
job: Timeout for job execution (None disables timeout).
51
54
"""
55
+
52
56
post : Optional [int ] = None
53
57
poll : int = 2
54
58
job : Optional [int ] = None
@@ -65,6 +69,7 @@ class Polling(BaseModel):
65
69
wait: Wait time between polling attempts.
66
70
attempts: Max polling attempts before failure.
67
71
"""
72
+
68
73
wait : int = 3
69
74
attempts : int = 100
70
75
@@ -84,6 +89,7 @@ class PostTask(BaseModel):
84
89
timeout: Timeout settings.
85
90
polling: Polling behavior.
86
91
"""
92
+
87
93
db : DB = DB ()
88
94
task_id : TaskID = TaskID ()
89
95
timeout : Timeout = Timeout ()
@@ -99,6 +105,7 @@ class ListTasks(BaseModel):
99
105
Attributes:
100
106
default_page_size: Default pagination size.
101
107
"""
108
+
102
109
default_page_size : int = 5
103
110
104
111
@@ -111,6 +118,7 @@ class Monitor(BaseModel):
111
118
Attributes:
112
119
timeout: Timeout to wait for Celery monitoring.
113
120
"""
121
+
114
122
timeout : float = 0.1
115
123
116
124
@@ -125,6 +133,7 @@ class Celery(BaseModel):
125
133
monitor: Monitor settings.
126
134
message_maxsize: Maximum allowed message size.
127
135
"""
136
+
128
137
monitor : Monitor = Monitor ()
129
138
message_maxsize : int = 16777216
130
139
@@ -142,12 +151,14 @@ class Controllers(BaseModel):
142
151
list_tasks: Settings for GET /tasks.
143
152
celery: Celery background task settings.
144
153
"""
154
+
145
155
post_task : PostTask = PostTask ()
146
156
list_tasks : ListTasks = ListTasks ()
147
157
celery : Celery = Celery ()
148
158
159
+
149
160
class Tes (BaseModel ):
150
- """TES backend configuration.
161
+ """TES backend configuration.
151
162
152
163
Args:
153
164
service_list: List of available TES services.
@@ -156,35 +167,45 @@ class Tes(BaseModel):
156
167
service_list: List of available TES services.
157
168
"""
158
169
159
- service_list : List [str ] = [
160
- "https://csc-tesk-noauth.rahtiapp.fi" ,
161
- "https://funnel.cloud.e-infra.cz/" ,
162
- "https://tesk-eu.hypatia-comp.athenarc.gr" ,
163
- "https://tesk-na.cloud.e-infra.cz" ,
164
- "https://vm4816.kaj.pouta.csc.fi/" ,
165
- ]
170
+ service_list : List [str ] = [
171
+ "https://csc-tesk-noauth.rahtiapp.fi" ,
172
+ "https://funnel.cloud.e-infra.cz/" ,
173
+ "https://tesk-eu.hypatia-comp.athenarc.gr" ,
174
+ "https://tesk-na.cloud.e-infra.cz" ,
175
+ "https://vm4816.kaj.pouta.csc.fi/" ,
176
+ ]
177
+
166
178
167
179
class StoreLogs (BaseModel ):
168
- """Logging configuration.
180
+ """Logging configuration.
169
181
170
182
Args:
171
183
execution_trace: Whether to store execution trace logs.
172
184
173
185
Attributes:
174
186
execution_trace: Whether to store execution trace logs.
175
187
"""
176
- execution_trace : True
188
+
189
+ execution_trace : bool = True
190
+
177
191
178
192
class Middlewares (BaseModel ):
179
193
middlewares : List [List [str ]] = [
180
194
[
181
- "pro_tes.plugins.middlewares.task_distribution.distance.TaskDistributionDistance" ,
182
- "pro_tes.plugins.middlewares.task_distribution.random.TaskDistributionRandom" ,
195
+ (
196
+ "pro_tes.plugins.middlewares.task_distribution.distance."
197
+ "TaskDistributionDistance"
198
+ ),
199
+ (
200
+ "pro_tes.plugins.middlewares.task_distribution.random."
201
+ "TaskDistributionRandom"
202
+ ),
183
203
]
184
204
]
185
205
206
+
186
207
class CustomConfig (BaseModel ):
187
- """Custom app configuration.
208
+ """Custom app configuration.
188
209
189
210
Args:
190
211
controllers: All controller-related config.
@@ -200,9 +221,9 @@ class CustomConfig(BaseModel):
200
221
middlewares: Middleware class paths.
201
222
service_info: Metadata about the service.
202
223
"""
224
+
203
225
controllers : Controllers = Controllers ()
204
226
tes : Tes = Tes ()
205
227
storeLogs : StoreLogs = StoreLogs ()
206
228
middlewares : Middlewares = Middlewares ()
207
229
service_info : ServiceInfo
208
-
0 commit comments