5
5
# SPDX-License-Identifier: Apache-2.0
6
6
7
7
from .service import Service
8
+ from ..utils .decorators import experimental
8
9
9
10
class ModelManagement (Service ):
10
11
"""The Model Management API provides basic resources for monitoring
@@ -19,7 +20,8 @@ class ModelManagement(Service):
19
20
'performance tasks' )
20
21
21
22
# TODO: set ds2MultiType
22
- def publish_model (self ,
23
+ @classmethod
24
+ def publish_model (cls ,
23
25
model ,
24
26
destination ,
25
27
name = None ,
@@ -79,15 +81,16 @@ def publish_model(self,
79
81
# Publishes a model that has already been registered in the model
80
82
# repository.
81
83
# Unlike model_publish service, does not require Code to be specified.
82
- r = self .post ('/publish' ,
83
- json = request ,
84
- params = dict (force = force ,
84
+ r = cls .post ('/publish' ,
85
+ json = request ,
86
+ params = dict (force = force ,
85
87
reloadModelTable = reload_model_table ),
86
- headers = {'Content-Type' :
88
+ headers = {'Content-Type' :
87
89
'application/vnd.sas.models.publishing.request.asynchronous+json' })
88
90
return r
89
91
90
- def create_performance_definition (self ,
92
+ @classmethod
93
+ def create_performance_definition (cls ,
91
94
model ,
92
95
library_name ,
93
96
table_prefix ,
@@ -209,11 +212,12 @@ def create_performance_definition(self,
209
212
project .get ('variables' , []) if
210
213
v .get ('role' ) == 'output' ]
211
214
212
- return self .post ('/performanceTasks' , json = request ,
213
- headers = {
215
+ return cls .post ('/performanceTasks' , json = request ,
216
+ headers = {
214
217
'Content-Type' : 'application/vnd.sas.models.performance.task+json' })
215
218
216
- def execute_performance_definition (self , definition ):
219
+ @classmethod
220
+ def execute_performance_definition (cls , definition ):
217
221
"""Launches a job to run a performance definition.
218
222
219
223
Parameters
@@ -227,11 +231,13 @@ def execute_performance_definition(self, definition):
227
231
The executing job
228
232
229
233
"""
230
- definition = self .get_performance_definition (definition )
234
+ definition = cls .get_performance_definition (definition )
231
235
232
- return self .post ('/performanceTasks/%s' % definition .id )
236
+ return cls .post ('/performanceTasks/%s' % definition .id )
233
237
234
- def list_model_workflow_definition (self ):
238
+ @classmethod
239
+ @experimental
240
+ def list_model_workflow_definition (cls ):
235
241
"""List all enabled Workflow Processes to execute on Model Project.
236
242
237
243
Returns
@@ -245,7 +251,9 @@ def list_model_workflow_definition(self):
245
251
246
252
return wf .list_enabled_definitions ()
247
253
248
- def list_model_workflow_prompt (self , workflowName ):
254
+ @classmethod
255
+ @experimental
256
+ def list_model_workflow_prompt (cls , workflowName ):
249
257
"""List prompt Workflow Processes Definitions.
250
258
251
259
Parameters
@@ -264,16 +272,16 @@ def list_model_workflow_prompt(self, workflowName):
264
272
265
273
return wf .list_workflow_prompt (workflowName )
266
274
267
-
268
- def list_model_workflow_executed (self , projectName ):
275
+ @classmethod
276
+ @experimental
277
+ def list_model_workflow_executed (cls , projectName ):
269
278
"""List prompt Workflow Processes Definitions.
270
279
271
280
Parameters
272
281
----------
273
282
projectName : str
274
283
Name of the Project list executed workflow
275
284
276
-
277
285
Returns
278
286
-------
279
287
RestObj
@@ -285,17 +293,18 @@ def list_model_workflow_executed(self, projectName):
285
293
286
294
project = mr .get_project (projectName )
287
295
288
- return self .get ('/workflowProcesses?filter=eq(associations.solutionObjectId,%22' + project ['id' ]+ '%22)' )
289
-
296
+ return cls .get ('/workflowProcesses?filter=eq(associations.solutionObjectId,%22' + project ['id' ] + '%22)' )
290
297
291
- def execute_model_workflow_definition (self , projectName , workflowName , input = None ):
298
+ @classmethod
299
+ @experimental
300
+ def execute_model_workflow_definition (cls , project_name , workflow_name , input = None ):
292
301
"""Runs specific Workflow Processes Definitions.
293
302
294
303
Parameters
295
304
----------
296
- projectName : str
305
+ project_name : str
297
306
Name of the Project that will execute workflow
298
- workflowName : str
307
+ workflow_name : str
299
308
Name or ID of an enabled workflow to execute
300
309
input : dict, optional
301
310
Input values for the workflow for initial workflow prompt
@@ -312,17 +321,17 @@ def execute_model_workflow_definition(self, projectName, workflowName, input=Non
312
321
mr = ModelRepository ()
313
322
wf = Workflow ()
314
323
315
- project = mr .get_project (projectName )
324
+ project = mr .get_project (project_name )
316
325
317
- workflow = wf .run_workflow_definition (workflowName , input = input )
326
+ workflow = wf .run_workflow_definition (workflow_name , input = input )
318
327
319
- #Associations running workflow to model project, note workflow has to be running
328
+ # Associations running workflow to model project, note workflow has to be running
320
329
# THINK ABOUT: do we do a check on status of the workflow to determine if it is still running before associating?
321
330
322
331
input = {"processName" : workflow ['name' ],
323
332
"processId" : workflow ['id' ],
324
333
"objectType" : "MM_Project" ,
325
- "solutionObjectName" : projectName ,
334
+ "solutionObjectName" : project_name ,
326
335
"solutionObjectId" : project ['id' ],
327
336
"solutionObjectUri" : "/modelRepository/projects/" + project ['id' ],
328
337
"solutionObjectMediaType" : "application/vnd.sas.models.project+json" }
@@ -332,8 +341,8 @@ def execute_model_workflow_definition(self, projectName, workflowName, input=Non
332
341
# e62c5562-2b11-45db-bcb7-933200cb0f0a","traceId: 3118c0fb1eb9702d","path:
333
342
# /modelManagement/workflowAssociations"],"links":[],"version":2,"httpStatusCode":404}
334
343
# Which is fine and expected like the Visual Experience.
335
- return self .post ('/workflowAssociations' ,
336
- json = input ,
337
- headers = {'Content-Type' : 'application/vnd.sas.workflow.object.association+json' })
344
+ return cls .post ('/workflowAssociations' ,
345
+ json = input ,
346
+ headers = {'Content-Type' : 'application/vnd.sas.workflow.object.association+json' })
338
347
339
348
0 commit comments