Skip to content

Commit 5520bdb

Browse files
committed
moving execution stats to WorkflowManager
Signed-off-by: Neil South <[email protected]>
1 parent 9ce57b6 commit 5520bdb

File tree

100 files changed

+2288
-1723
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

100 files changed

+2288
-1723
lines changed

.github/.gitversion.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
next-version: 0.1.2
15+
next-version: 0.1.5
1616
assembly-versioning-scheme: MajorMinorPatchTag
1717
mode: ContinuousDelivery
1818
branches:

docs/setup/mwm-workflow-spec.md

Lines changed: 21 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ A workflow is a standard template that contains a list of tasks that can be ran
2424

2525
The first task to be ran, will always be the first task in the list. The next task/tasks to be ran must be listed in the [Task Destinations](#task-destinations) of the task. A workflow requires at least one task.
2626

27-
Workflows can be created or updated via the [Workflow API](https://github.com/Project-MONAI/monai-deploy-workflow-manager/blob/develop/docs/api/rest/workflow.md).
27+
Workflows can be created or updated via the [Workflow API](https://github.com/Project-MONAI/monai-deploy-workflow-manager/blob/develop/docs/api/rest/workflow.md).
2828

2929
# Contents
3030

@@ -142,7 +142,7 @@ The following is an example of the structure of a workflow.
142142
The following is an example of a complete workflow:
143143
![scenario1](../images/workflow_examples/scenario1.png)
144144

145-
An example of a workflow with two tasks:
145+
An example of a workflow with two tasks:
146146

147147
1. Argo task
148148
2. Export Task
@@ -240,7 +240,7 @@ It also defines the "PROD_PACS" output destination, meaning that it can be used:
240240
Tasks are the basic building block of a workflow. They are provided as a list - the first Task in the list is executed when the workflow is triggered.
241241
Subsequent tasks are triggered by the `task_destinations` specified by previous tasks.
242242

243-
# Task Object
243+
# Task Object
244244

245245
### Task Types
246246
These tasks are borken down into different types:
@@ -292,8 +292,8 @@ The following are examples of the task json structure including required args fo
292292
]
293293
},
294294
"task_destinations": [
295-
{
296-
"name": "export-task-id"
295+
{
296+
"name": "export-task-id"
297297
}
298298
]
299299
}
@@ -364,7 +364,7 @@ Depending of the type of task, the task object may contain additional fields.
364364
Router tasks don't have additional fields. They are used to contain `task_destinations` so that workflow processing can be directed to the desired next step.
365365

366366
#### Export
367-
These are task types that allow for artifacts to be exported based on the input artifacts list. This task type should not have Out artifacts listed.
367+
These are task types that allow for artifacts to be exported based on the input artifacts list. This task type should not have Out artifacts listed.
368368
The task also requires these extra attributes:-
369369

370370
| Property | Type | Description |
@@ -403,7 +403,7 @@ Example (output sent to another task if the patient is female, otherwise to PACS
403403
Export destinations define an external location to which the output of the task can be sent. This will take the form of an event published to a pub/sub service notifying of an available export to a specific destination reference. Most commonly, the export location will be a PACs system and the notification will be picked up by the Monai Informatics Gateway.
404404

405405
#### Plugin
406-
These are tasks are Named the same as the installed Pluging.
406+
These are tasks are Named the same as the installed Pluging.
407407
The task also requires these extra attributes:-
408408

409409
| Property | Type | Description |
@@ -414,7 +414,7 @@ The task also requires these extra attributes:-
414414
The args requirements for argo plugin can be found [here](#argo).
415415

416416
### Task Arguments
417-
Each task plugin requires specific arguments to be provided in the args dictionary. This allows all task types to support as many additional values as necessary without the need to bloat the workflow spec.
417+
Each task plugin requires specific arguments to be provided in the args dictionary. This allows all task types to support as many additional values as necessary without the need to bloat the workflow spec.
418418

419419
#### Argo
420420
The Argo plugin triggers workflows pre-deployed onto an [Argo workflow server](https://argoproj.github.io/argo-events/).
@@ -425,25 +425,11 @@ The Task's "args" object should contain the following fields:
425425

426426
| Property | Type | Required | Description |
427427
|------|------|------|------|
428-
|workflow_template_name|str|Yes|The ID of this workflow as registered on the Argo server.|
429-
|namespace|str|Yes|The namespace of the argo workflow.|
430-
|server_url|url|Yes|The URL of the Argo server.|
431-
|allow_insecure|bool|No|Allow insecure connections to argo from the plug-in.|
432-
|parameters|dictionary|No|Key value pairs, Argo parameters that will be passed on to the Argo workflow.|
433-
|priority_class|string|No|The name of a valid Kubernetes priority class to be assigned to the Argo workflow pods|
434-
|resources|dictionary|No|A resource requests & limits object (see below). These will be applied to the Argo workflow pods|
435-
436-
##### Resource Request Object
437-
438-
Resource request parameters should be included in the task args object dictionary, as a string dictionary. The resources dictionary and all included values below are optional.
439-
440-
| Property | Type | Description |
441-
|------|------|------|
442-
|memory_reservation|str|A valid [Kubernetes memory request value](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-memory).|
443-
|cpu_reservation|url|A valid [Kubernetes CPU request value](https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu).|
444-
|gpu_limit|dictionary|The number of GPUs to be used by this task.|
445-
|memory_limit|string|The maximum amount of memory this task may use|
446-
|cpu_limit|object|The maximum amount of CPU this task may use. See |
428+
|workflow_template_name|string|Yes|The ID of this workflow as registered on the Argo server.|
429+
|priority_class|string|No|The name of a valid Kubernetes priority class to be assigned to the Argo workflow pods.|
430+
|gpu_required|string|No|Whether a GPU is to be used by this task.|
431+
|memory_gb|string|No|The maximum amount of memory in gigabytes this task may use.|
432+
|cpu|string|No|The maximum amount of CPU this task may use.|
447433

448434
For more information about Kubernetes requests & limits, see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/.
449435

@@ -501,7 +487,7 @@ As you can see in the example below, input artifacts require a _value_. This is
501487

502488
#### DICOM Input
503489

504-
If payload DICOM inputs are to be used in a given task, the value of the input must be `context.input.dicom`. This will to resolve to the `{payloadId}/dcm` folder within Minio / S3.
490+
If payload DICOM inputs are to be used in a given task, the value of the input must be `context.input.dicom`. This will to resolve to the `{payloadId}/dcm` folder within Minio / S3.
505491

506492
Example:
507493
```json
@@ -700,11 +686,11 @@ The following examples both function the same and act as an AND condition.
700686
## Evaluators
701687
Conditional evaluators are logical statement strings that may be used to determine which tasks are executed. They can make use of the execution context _metadata_ and dicom tags. All conditions must evaluate to true in order for the task to be triggered.
702688

703-
[A detailed breakdown of conditional logic can be found here.](https://github.com/Project-MONAI/monai-deploy-workflow-manager/blob/develop/guidelines/mwm-conditionals.md)
689+
[A detailed breakdown of conditional logic can be found here.](https://github.com/Project-MONAI/monai-deploy-workflow-manager/blob/develop/guidelines/mwm-conditionals.md)
704690

705691
### Supported Evaulators
706692

707-
693+
708694
Conditional evaluators should support evaluating workflow variables against predefined values with the following operators:
709695

710696
< (Valid for integers)
@@ -765,9 +751,9 @@ Example (status):
765751

766752
#### Result Metadata & Execution Stats - Using Dictionary Values
767753

768-
The Result Metadata and Execution Stats are populated by the plugin and are added to the workflow instance once a task is completed to provide some output of a task. Each plugin will have its own implementation to populate the result metadata.
754+
The Result Metadata and Execution Stats are populated by the plugin and are added to the workflow instance once a task is completed to provide some output of a task. Each plugin will have its own implementation to populate the result metadata.
769755

770-
Because `result` and `execution_stats` are a dictionary, the section after `context.executions.task_id.result` or `context.executions.task_id.execution_stats` is the key to be checked in the result/execution_stats dictionary.
756+
Because `result` and `execution_stats` are a dictionary, the section after `context.executions.task_id.result` or `context.executions.task_id.execution_stats` is the key to be checked in the result/execution_stats dictionary.
771757

772758
For conditional statements, the key specified is case sensitive and must match exactly to the key which has been output by the model and saved in the result/execution_stats dictionary.
773759

@@ -807,9 +793,9 @@ The result metadata for an Argo task is populated by a `metadata.json` that is i
807793
}
808794
```
809795

810-
If metadata is to be used in a conditional the `metadata.json` must be present somewhere in the output directory and a valid JSON dictionary. It will automatically be imported if it is in the directory.
796+
If metadata is to be used in a conditional the `metadata.json` must be present somewhere in the output directory and a valid JSON dictionary. It will automatically be imported if it is in the directory.
811797

812-
An example format of the metadata.json can be found below:
798+
An example format of the metadata.json can be found below:
813799

814800
execution stats are populated from the argo execution values returned automatically.
815801

@@ -916,4 +902,4 @@ Name:
916902
Description:
917903
```python
918904
{{context.workflow.description}} == 'This workflow is a valid workflow'
919-
```
905+
```

src/AssemblyInfo.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@
1818

1919
[assembly: AssemblyFileVersion("0.0.0.0")]
2020
[assembly: AssemblyVersion("0.0.0.0")]
21-
[assembly: AssemblyInformationalVersion("0.0.0-development")]
21+
[assembly: AssemblyInformationalVersion("0.0.0-development")]

src/Monai.Deploy.WorkflowManager.sln

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,10 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monai.Deploy.WorkflowManage
8282
EndProject
8383
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monai.Deploy.WorkflowManager.Common.Tests", "..\tests\UnitTests\Common.Tests\Monai.Deploy.WorkflowManager.Common.Tests.csproj", "{75A4AEDA-0386-4B2D-9DBA-BC9AE733660E}"
8484
EndProject
85+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monai.Deploy.WorkflowManager.Services", "WorkflowManager\Monai.Deploy.WorkflowManager.Services\Monai.Deploy.WorkflowManager.Services.csproj", "{526FF10C-1C7F-4C26-8E8A-D7ACD65F5467}"
86+
EndProject
87+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Monai.Deploy.WorkflowManager.Services.Tests", "..\tests\UnitTests\WorkflowManager.Services.Tests\Monai.Deploy.WorkflowManager.Services.Tests.csproj", "{0D40F7D6-3747-4280-8EB3-9F3A18AC1125}"
88+
EndProject
8589
Global
8690
GlobalSection(SolutionConfigurationPlatforms) = preSolution
8791
Debug|Any CPU = Debug|Any CPU
@@ -228,6 +232,14 @@ Global
228232
{75A4AEDA-0386-4B2D-9DBA-BC9AE733660E}.Debug|Any CPU.Build.0 = Debug|Any CPU
229233
{75A4AEDA-0386-4B2D-9DBA-BC9AE733660E}.Release|Any CPU.ActiveCfg = Release|Any CPU
230234
{75A4AEDA-0386-4B2D-9DBA-BC9AE733660E}.Release|Any CPU.Build.0 = Release|Any CPU
235+
{526FF10C-1C7F-4C26-8E8A-D7ACD65F5467}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
236+
{526FF10C-1C7F-4C26-8E8A-D7ACD65F5467}.Debug|Any CPU.Build.0 = Debug|Any CPU
237+
{526FF10C-1C7F-4C26-8E8A-D7ACD65F5467}.Release|Any CPU.ActiveCfg = Release|Any CPU
238+
{526FF10C-1C7F-4C26-8E8A-D7ACD65F5467}.Release|Any CPU.Build.0 = Release|Any CPU
239+
{0D40F7D6-3747-4280-8EB3-9F3A18AC1125}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
240+
{0D40F7D6-3747-4280-8EB3-9F3A18AC1125}.Debug|Any CPU.Build.0 = Debug|Any CPU
241+
{0D40F7D6-3747-4280-8EB3-9F3A18AC1125}.Release|Any CPU.ActiveCfg = Release|Any CPU
242+
{0D40F7D6-3747-4280-8EB3-9F3A18AC1125}.Release|Any CPU.Build.0 = Release|Any CPU
231243
EndGlobalSection
232244
GlobalSection(SolutionProperties) = preSolution
233245
HideSolutionNode = FALSE
@@ -269,6 +281,8 @@ Global
269281
{81E3F943-B992-4C81-AA09-A17C05081236} = {37A19144-CEA5-47A2-9FFD-22C522E8B895}
270282
{C853A9E3-C53D-4B1A-BFDA-228689A8C94C} = {71DDEE7B-E213-4E39-A7F4-4646783A27F7}
271283
{75A4AEDA-0386-4B2D-9DBA-BC9AE733660E} = {71DDEE7B-E213-4E39-A7F4-4646783A27F7}
284+
{526FF10C-1C7F-4C26-8E8A-D7ACD65F5467} = {AC5B198A-C3F2-4AD2-B532-E71B4630BDD5}
285+
{0D40F7D6-3747-4280-8EB3-9F3A18AC1125} = {71DDEE7B-E213-4E39-A7F4-4646783A27F7}
272286
EndGlobalSection
273287
GlobalSection(ExtensibilityGlobals) = postSolution
274288
SolutionGuid = {DC0D56C8-D8CB-45CE-B528-F3DCF86D63ED}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright 2022 MONAI Consortium
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
using Microsoft.Extensions.Configuration;
18+
19+
namespace Monai.Deploy.WorkflowManager.Configuration
20+
{
21+
public class InformaticsGatewayConfiguration
22+
{
23+
[ConfigurationKeyName("apiHost")]
24+
public string ApiHost { get; set; }
25+
}
26+
}

src/Shared/Shared/ApiControllerBase.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
using Monai.Deploy.WorkflowManager.Shared.Filter;
2323
using Monai.Deploy.WorkflowManager.Shared.Wrappers;
2424
using Monai.Deploy.WorkflowManager.Shared.Services;
25-
using Microsoft.AspNetCore.Routing;
2625

2726
namespace Monai.Deploy.WorkflowManager.ControllersShared
2827
{
@@ -85,7 +84,7 @@ public PagedResponse<IEnumerable<T>> CreatePagedReponse<T>(IEnumerable<T> pagedD
8584

8685
public StatsPagedResponse<IEnumerable<T>> CreateStatsPagedReponse<T>(IEnumerable<T> pagedData, PaginationFilter validFilter, long totalRecords, IUriService uriService, string route)
8786
{
88-
var response = new StatsPagedResponse<IEnumerable<T>>(pagedData, validFilter.PageNumber, validFilter.PageSize.Value);
87+
var response = new StatsPagedResponse<IEnumerable<T>>(pagedData, validFilter.PageNumber, validFilter.PageSize ?? 10);
8988
response.SetUp(validFilter, totalRecords, uriService, route);
9089
return response;
9190
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* Copyright 2023 MONAI Consortium
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
namespace Monai.Deploy.WorkflowManager.Shared.Filter
18+
{
19+
public class TimeFilter : PaginationFilter
20+
{
21+
public DateTime StartTime { get; set; }
22+
23+
public DateTime EndTime { get; set; }
24+
}
25+
}

src/Shared/Shared/MonaiServiceLocator.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public Dictionary<string, ServiceStatus> GetServiceStatus()
4141
return _runningServices.ToDictionary(k => k.ServiceName, v => v.Status);
4242
}
4343

44-
private IMonaiService GetService(Type type)
44+
private IMonaiService? GetService(Type type)
4545
{
4646
Guard.Against.Null(type, nameof(type));
4747

@@ -58,7 +58,7 @@ private static List<Type> LocateTypes()
5858
serviceType.IsAssignableFrom(p) &&
5959
p != serviceType &&
6060
!p.IsAbstract &&
61-
p.FullName.StartsWith("Monai", StringComparison.InvariantCulture));
61+
p.FullName is not null && p.FullName.StartsWith("Monai", StringComparison.InvariantCulture));
6262
return services.Distinct().ToList();
6363
}
6464

src/Shared/Shared/ValidationConstants.cs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,21 @@ public static class ValidationConstants
5353
/// </summary>
5454
public static readonly string Notifications = "notifications";
5555

56+
/// <summary>
57+
/// Key for the CPU.
58+
/// </summary>
59+
public static readonly string Cpu = "cpu";
60+
61+
/// <summary>
62+
/// Key for the memory.
63+
/// </summary>
64+
public static readonly string Memory = "memory_gb";
65+
66+
/// <summary>
67+
/// Key for the GPU.
68+
/// </summary>
69+
public static readonly string GpuRequired = "gpu_required";
70+
5671
public enum ModeValues
5772
{
5873
QA,

0 commit comments

Comments
 (0)