|
6 | 6 |
|
7 | 7 | from .service import Service
|
8 | 8 |
|
9 |
| - |
10 | 9 | class ModelManagement(Service):
|
11 | 10 | """The Model Management API provides basic resources for monitoring
|
12 | 11 | performance, comparing models, and running workflow processes.
|
@@ -232,3 +231,104 @@ def execute_performance_definition(self, definition):
|
232 | 231 |
|
233 | 232 | return self.post('/performanceTasks/%s' % definition.id)
|
234 | 233 |
|
| 234 | + def list_model_workflow_definition(self): |
| 235 | + """List all enabled Workflow Processes to execute on Model Project. |
| 236 | +
|
| 237 | + Returns |
| 238 | + ------- |
| 239 | + RestObj |
| 240 | + The list of workflows |
| 241 | +
|
| 242 | + """ |
| 243 | + from .workflow import Workflow |
| 244 | + wf = Workflow() |
| 245 | + |
| 246 | + return wf.list_workflow_enableddefinitions() |
| 247 | + |
| 248 | + def list_model_workflow_prompt(self, workflowName): |
| 249 | + """List prompt Workflow Processes Definitions. |
| 250 | +
|
| 251 | + Parameters |
| 252 | + ---------- |
| 253 | + workflowName : str |
| 254 | + Name or ID of an enabled workflow to retrieve inputs |
| 255 | +
|
| 256 | + Returns |
| 257 | + ------- |
| 258 | + list |
| 259 | + The list of prompts for specific workflow |
| 260 | + |
| 261 | + """ |
| 262 | + from .workflow import Workflow |
| 263 | + wf = Workflow() |
| 264 | + |
| 265 | + return wf.list_workflow_prompt(workflowName) |
| 266 | + |
| 267 | + |
| 268 | + def list_model_workflow_executed(self, projectName): |
| 269 | + """List prompt Workflow Processes Definitions. |
| 270 | +
|
| 271 | + Parameters |
| 272 | + ---------- |
| 273 | + projectName : str |
| 274 | + Name of the Project list executed workflow |
| 275 | +
|
| 276 | +
|
| 277 | + Returns |
| 278 | + ------- |
| 279 | + RestObj |
| 280 | + List of workflows associated to project |
| 281 | +
|
| 282 | + """ |
| 283 | + from .model_repository import ModelRepository |
| 284 | + mr = ModelRepository() |
| 285 | + |
| 286 | + project = mr.get_project(projectName) |
| 287 | + |
| 288 | + return self.get('/workflowProcesses?filter=eq(associations.solutionObjectId,%22'+project['id']+'%22)') |
| 289 | + |
| 290 | + |
| 291 | + def execute_model_workflow_definition(self, projectName, workflowName, input=None): |
| 292 | + """Runs specific Workflow Processes Definitions. |
| 293 | +
|
| 294 | + Parameters |
| 295 | + ---------- |
| 296 | + projectName : str |
| 297 | + Name of the Project that will execute workflow |
| 298 | + workflowName : str |
| 299 | + Name or ID of an enabled workflow to execute |
| 300 | + input : dict, optional |
| 301 | + Input values for the workflow for initial workflow prompt |
| 302 | +
|
| 303 | + Returns |
| 304 | + ------- |
| 305 | + RestObj |
| 306 | + The executing workflow |
| 307 | + |
| 308 | + """ |
| 309 | + from .model_repository import ModelRepository |
| 310 | + from .workflow import Workflow |
| 311 | + mr = ModelRepository() |
| 312 | + wf = Workflow() |
| 313 | + |
| 314 | + project = mr.get_project(projectName) |
| 315 | + |
| 316 | + workflow = wf.run_workflow_definition(workflowName, input=input) |
| 317 | + |
| 318 | + #Associations running workflow to model project, note workflow has to be running |
| 319 | + # THINK ABOUT: do we do a check on status of the workflow to determine if it is still running before associating? |
| 320 | + |
| 321 | + input={"processName":workflow['name'],"processId":workflow['id'],"objectType":"MM_Project", |
| 322 | + "solutionObjectName":projectName,"solutionObjectId":project['id'], |
| 323 | + "solutionObjectUri":"/modelRepository/projects/"+project['id'], |
| 324 | + "solutionObjectMediaType":"application/vnd.sas.models.project+json"} |
| 325 | + |
| 326 | + #Note, you can get a HTTP Error 404: {"errorCode":74052,"message":"The workflow process for id <> cannot be found. |
| 327 | + # Associations can only be made to running processes.","details":["correlator: |
| 328 | + # e62c5562-2b11-45db-bcb7-933200cb0f0a","traceId: 3118c0fb1eb9702d","path: |
| 329 | + # /modelManagement/workflowAssociations"],"links":[],"version":2,"httpStatusCode":404} |
| 330 | + # Which is fine and expected like the Visual Experience. |
| 331 | + return self.post('/workflowAssociations', json=input, |
| 332 | + headers={'Content-Type': 'application/vnd.sas.workflow.object.association+json'}) |
| 333 | + |
| 334 | + |
0 commit comments