-
Notifications
You must be signed in to change notification settings - Fork 6
/
analyses.clj
304 lines (222 loc) · 11.2 KB
/
analyses.clj
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
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
(ns common-swagger-api.schema.analyses
(:use [common-swagger-api.schema :only [describe]]
[common-swagger-api.schema.apps
:only [AppStepResourceRequirements
SystemId]]
[common-swagger-api.schema.common :only [IncludeDeletedParams IncludeHiddenParams]]
[common-swagger-api.schema.containers
:only [coerce-settings-long-values]]
[schema.core
:only [defschema
enum
optional-key
Any
Keyword]])
(:require [clojure.java.io :as io]
[schema-tools.core :as st])
(:import (java.util UUID)))
(defn- coerce-analysis-requirements-long-values
[analysis]
(if (contains? analysis :requirements)
(update analysis :requirements (partial map coerce-settings-long-values))
analysis))
(defn coerce-analysis-submission-requirements
"Middleware that converts any requirements values in the given analysis submission that should be a Long."
[handler]
(fn [request]
(handler (update request :body-params coerce-analysis-requirements-long-values))))
(def AnalysisParametersSummary "Display the parameters used in an analysis.")
(def AnalysisParametersDocs
"This service returns a list of parameter values used in a previously executed analysis.")
(def AnalysisRelaunchSummary "Obtain information to relaunch analysis.")
(def AnalysisRelaunchDocs
"This service allows the Discovery Environment user interface to obtain an app description
that can be used to relaunch a previously submitted job,
possibly with modified parameter values.")
(def AnalysesRelauncherSummary "Auto Relaunch Analyses")
(def AnalysisStopSummary "Stop a running analysis.")
(def AnalysisStopDocs
"This service allows DE users to stop running analyses.")
(def AnalysisIdPathParam (describe UUID "The Analysis UUID"))
(defschema ParameterValue
{:value
(describe Any "The value of the parameter.")})
(defschema AnalysisParameter
{:full_param_id
(describe String "The fully qualified parameter ID.")
:param_id
(describe String "The unqualified parameter ID.")
(optional-key :param_name)
(describe String "The name of the parameter.")
(optional-key :param_value)
(describe ParameterValue "The value of the parameter.")
:param_type
(describe String "The type of the parameter.")
(optional-key :info_type)
(describe String "The type of information associated with an input or output parameter.")
(optional-key :data_format)
(describe String "The data format associated with an input or output parameter.")
(optional-key :is_default_value)
(describe Boolean "Indicates whether the default parameter value was used.")
(optional-key :is_visible)
(describe Boolean "Indicates whether the parameter is visible in the app UI.")})
(defschema AnalysisParameters
{:app_id
(describe String "The ID of the app used to perform the analysis.")
(optional-key :app_version_id)
(describe String "The version ID of the app used to perform the analysis.")
:system_id
SystemId
:parameters
(describe [AnalysisParameter] "The list of parameters.")})
(defschema AnalysesRelauncherRequest
{:analyses (describe [UUID] "The identifiers of the analyses to be relaunched.")})
(defschema AnalysisShredderRequest
{:analyses (describe [UUID] "The identifiers of the analyses to be deleted.")})
(defschema StopAnalysisRequest
{(optional-key :job_status)
(describe (enum "Canceled" "Completed" "Failed") "The job status to set. Defaults to `Canceled`")})
(defschema StopAnalysisResponse
{:id (describe UUID "the ID of the stopped analysis.")})
(defschema FileMetadata
{:attr (describe String "The attribute name.")
:value (describe String "The attribute value.")
:unit (describe String "The attribute unit.")})
(defschema AnalysisSubmissionConfig
{(describe Keyword "The step-ID_param-ID") (describe Any "The param-value")})
(defschema AnalysisStepResourceRequirements
(st/select-keys AppStepResourceRequirements [:min_memory_limit
:min_cpu_cores
:max_cpu_cores
:min_disk_space
:step_number]))
(defschema AnalysisSubmission
{:system_id
SystemId
:app_id
(describe String "The ID of the app used to perform the analysis.")
(optional-key :app_version_id)
(describe
UUID
"The ID of the app version used to perform the analysis.
If not provided, then it is assumed the submission is for the latest version of the app")
(optional-key :job_id)
(describe UUID "The UUID of the job being submitted.")
(optional-key :callback)
(describe String "The callback URL to use for job status updates.")
:config
(describe AnalysisSubmissionConfig "A map from (str step-id \"_\" param-id) to param-value.")
(optional-key :requirements)
(describe [AnalysisStepResourceRequirements] "The list of optional resource requirements requested for any step")
(optional-key :create_output_subdir)
(describe Boolean "Indicates whether a subdirectory should be created beneath the specified output directory.")
:debug
(describe Boolean "A flag indicating whether or not job debugging should be enabled.")
(optional-key :description)
(describe String "An optional description of the analysis.")
:name
(describe String "The name assigned to the analysis by the user.")
:notify
(describe Boolean "Indicates whether the user wants to receive job status update notifications.")
:output_dir
(describe String "The path to the analysis output directory in the data store.")
(optional-key :starting_step)
(describe Long "The ordinal number of the step to start the job with.")
(optional-key :uuid)
(describe UUID "The UUID of the analysis. A random UUID will be assigned if one isn't provided.")
(optional-key :skip-parent-meta)
(describe Boolean "True if metadata should not associate metadata with the parent directory.")
(optional-key :file-metadata)
(describe [FileMetadata] "Custom file attributes to associate with result files.")
(optional-key :archive_logs)
(describe Boolean "True if the job logs should be uploaded to the data store.")})
(defschema AnalysisResponse
{:id (describe UUID "The ID of the submitted analysis.")
:name (describe String "The name of the submitted analysis.")
:status (describe String "The current status of the analysis.")
:start-date (describe String "The analysis start date as milliseconds since the epoch.")
(optional-key :missing-paths)
(describe [String] "Any paths parsed from an HT Analysis Path List that no longer exist.")})
(defschema AnalysisPod
{:name (describe String "The name of a pod in Kubernetes associated with an analysis.")
:external_id (describe UUID "The external ID associated with the pod.")})
(def AnalysisPodListSummary
"List the Kubernetes pods associated with the analysis.")
(def AnalysisPodListDescription
"This endpoint returns a listing of pod objects associated with the analysis. Usually will return a single pod.")
(defschema AnalysisPodList
{:pods (describe [AnalysisPod] "A list of pods in Kubernetes associated with an analysis.")})
(def AnalysisPodLogSummary
"The logs from a pod associated with the analysis")
(def AnalysisPodLogDescription
"This endpoint returns the logs from the provided pod associated with the provided analysis.")
(defschema AnalysisPodLogParameters
{(optional-key :previous)
(describe Boolean "True if the logs of a previously terminated container should be returned")
(optional-key :since)
(describe Long "Number of seconds in the past to start showing logs")
(optional-key :since-time)
(describe String "The time at which to start showing log lines. Expressed as seconds since the epoch.")
(optional-key :tail-lines)
(describe Long "Number of lines from the end of the log to show")
(optional-key :timestamps)
(describe Boolean "True if timestamps should be prepended to the log lines")
(optional-key :container)
(describe String "Name of the container to display logs from. Defaults to 'analysis'")})
(defschema AnalysisPodLogEntry
{:since_time
(describe String "Contains the seconds since the epoch for the time when the log entry was retrieved")
:lines
(describe [String] "The lines that make up the log entry")})
(defschema AnalysisTimeLimit
{:time_limit
(describe String "Contains the seconds since the epoch for the analysis's time limit or the string 'null' if the time limit isn't set.")})
(def ConcurrentJobLimitUsername
(describe String "The username associated with the limit"))
(def ConcurrentJobLimitListingSummary
"List Concurrent Job Limits")
(def ConcurrentJobLimitListingDescription
"Lists the concurrent job limits for all users who have one defined. The record describing the default limit contains
no username. Users without explicit limits defined will use the default limit.")
(def ConcurrentJobLimitRetrievalSummary
"Get a User's Concurrent Job Limit")
(def ConcurrentJobLimitRetrievalDescription
"Gets the concurrent job limit for a user. The limit will either be the limit that was explicitly set for the user
or the default limit. If the default limit is returned then there will be no username in the response body.")
(def ConcurrentJobLimitUpdateSummary
"Update a User's Concurrent Job Limit")
(def ConcurrentJobLimitUpdateDescription
"Updates the concurrent job limit for a user. The user's limit will be set explicitly even if it's equal to the
default limit.")
(def ConcurrentJobLimitRemovalSummary
"Remove a User's Concurrent Job Limit")
(def ConcurrentJobLimitRemovalDescription
"Removes the explicitly configured concurrent job limit for a user. This effectively returns the user's job limit
to whatever the default job limit is.")
(defschema ConcurrentJobLimitListItem
{(optional-key :username)
(describe String "The username of the limited user, omitted for the default setting")
:concurrent_jobs
(describe Long "The maximum number of concurrently running jobs")
:is_default
(describe Boolean "True for the default setting.")})
(defschema ConcurrentJobLimit
(-> ConcurrentJobLimitListItem
(st/dissoc :is_default)
(st/assoc :is_default (describe Boolean "True if the default setting is being used for the user."))))
(defschema ConcurrentJobLimits
{:limits (describe [ConcurrentJobLimitListItem] "The list of concurrent job limits")})
(defschema ConcurrentJobLimitUpdate
(st/dissoc ConcurrentJobLimit :username :is_default))
(def AnalysisStatSummary "List analysis counts by status")
(def AnalysisStatDescription "This service allows users to retrieve the total count of jobs grouped by job status.")
(defschema AnalysisCount
{:count (describe Long "The total number of jobs with the attached job status.")
:status (describe String "The status for the attached job count.")})
(defschema AnalysisStats
{:status-count (describe [AnalysisCount] "List the total number of jobs grouped by job status for a user.")})
(defschema AnalysisStatParams
(merge IncludeHiddenParams
IncludeDeletedParams
{(optional-key :filter)
(describe String (slurp (io/resource "docs/analyses/listing/filter-param.md")))}))