Skip to content

Commit

Permalink
Update to use new UpdateStatusEvent
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Schofield <jack.schofield@answerdigital.com>
  • Loading branch information
jackschofield23 committed May 30, 2022
1 parent 7a78f73 commit adba7ad
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 54 deletions.
7 changes: 0 additions & 7 deletions src/Monai.Deploy.WorkflowManager.sln
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monai.Deploy.WorkflowManage
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monai.Deploy.WorkflowManager.ConditionsResolver.Tests", "..\tests\UnitTests\ConditionsResolver.Tests\Monai.Deploy.WorkflowManager.ConditionsResolver.Tests.csproj", "{918E4DE3-A7BF-4B7F-9B5A-5C36FEFA3C30}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Monai.Deploy.WorkflowManager.TaskManager.API.Tests", "..\tests\UnitTests\TaskManager.API.Tests\Monai.Deploy.WorkflowManager.TaskManager.API.Tests.csproj", "{7AF31246-C97C-4AF5-90C3-422199CF7B4A}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -159,10 +157,6 @@ Global
{918E4DE3-A7BF-4B7F-9B5A-5C36FEFA3C30}.Debug|Any CPU.Build.0 = Debug|Any CPU
{918E4DE3-A7BF-4B7F-9B5A-5C36FEFA3C30}.Release|Any CPU.ActiveCfg = Release|Any CPU
{918E4DE3-A7BF-4B7F-9B5A-5C36FEFA3C30}.Release|Any CPU.Build.0 = Release|Any CPU
{7AF31246-C97C-4AF5-90C3-422199CF7B4A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7AF31246-C97C-4AF5-90C3-422199CF7B4A}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7AF31246-C97C-4AF5-90C3-422199CF7B4A}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7AF31246-C97C-4AF5-90C3-422199CF7B4A}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -182,7 +176,6 @@ Global
{2DA40575-4748-4198-BE57-F4AF070DE8E3} = {71DDEE7B-E213-4E39-A7F4-4646783A27F7}
{89D3D817-CCFE-4933-9089-D1283F2EA1B5} = {71DDEE7B-E213-4E39-A7F4-4646783A27F7}
{918E4DE3-A7BF-4B7F-9B5A-5C36FEFA3C30} = {71DDEE7B-E213-4E39-A7F4-4646783A27F7}
{7AF31246-C97C-4AF5-90C3-422199CF7B4A} = {71DDEE7B-E213-4E39-A7F4-4646783A27F7}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {DC0D56C8-D8CB-45CE-B528-F3DCF86D63ED}
Expand Down
26 changes: 0 additions & 26 deletions src/TaskManager/API/Extensions/StorageListExtensions.cs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SPDX-License-Identifier: Apache License 2.0
</ItemGroup>

<ItemGroup>
<PackageReference Include="Monai.Deploy.Messaging" Version="0.1.0-rc0039" />
<PackageReference Include="Monai.Deploy.Messaging" Version="0.1.0-rc0040" />
<PackageReference Include="Monai.Deploy.Storage" Version="0.1.0-rc0019" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions src/TaskManager/API/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
"net6.0": {
"Monai.Deploy.Messaging": {
"type": "Direct",
"requested": "[0.1.0-rc0039, )",
"resolved": "0.1.0-rc0039",
"contentHash": "407J7x2qWUHd8ByvrWvDf+H9h7DCOmDhcpMh3Zi/1497QEBQX4/jZKEyX5I3Iq9ceDZevf/lssqaLK7DJ3fJaw==",
"requested": "[0.1.0-rc0040, )",
"resolved": "0.1.0-rc0040",
"contentHash": "q5t6h24M+22JQqeBTD9wOOYYAvb1Vk29nkadcOJ05wT569jnF+MGmEherDn1moX45Ehj4TsCvQl3TD4HJlC1mA==",
"dependencies": {
"Ardalis.GuardClauses": "4.0.1",
"Microsoft.Extensions.Configuration": "6.0.1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ SPDX-License-Identifier: Apache License 2.0
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="6.0.0" />
<PackageReference Include="Microsoft.Extensions.Logging.Abstractions" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Options" Version="6.0.0" />
<PackageReference Include="Monai.Deploy.Messaging" Version="0.1.0-rc0039" />
<PackageReference Include="Monai.Deploy.Messaging" Version="0.1.0-rc0040" />
<PackageReference Include="Monai.Deploy.Storage" Version="0.1.0-rc0019" />
</ItemGroup>

Expand Down
3 changes: 1 addition & 2 deletions src/TaskManager/Plug-ins/Argo/ExitHookTemplate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

using Argo;
using Monai.Deploy.Messaging.Events;
using Monai.Deploy.WorkflowManager.TaskManager.API.Extensions;
using Newtonsoft.Json;

namespace Monai.Deploy.WorkflowManager.TaskManager.Argo
Expand Down Expand Up @@ -82,7 +81,7 @@ private TaskCallbackEvent GenerateTaskCallbackEvent() =>
ExecutionId = _taskDispatchEvent.ExecutionId,
CorrelationId = _taskDispatchEvent.CorrelationId,
Identity = "{{workflow.name}}",
OutputArtifacts = _taskDispatchEvent.Outputs?.ToArtifactDictionary() ?? new Dictionary<string, string>()
Outputs = _taskDispatchEvent.Outputs ?? new List<Messaging.Common.Storage>()
};

private object GenerateTaskCallbackMessage() =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ SPDX-License-Identifier: Apache License 2.0
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Monai.Deploy.Messaging" Version="0.1.0-rc0039" />
<PackageReference Include="Monai.Deploy.Messaging" Version="0.1.0-rc0040" />
<PackageReference Include="Monai.Deploy.Storage" Version="0.1.0-rc0019" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.1" />
</ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/TaskManager/Plug-ins/Argo/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
},
"Monai.Deploy.Messaging": {
"type": "Direct",
"requested": "[0.1.0-rc0039, )",
"resolved": "0.1.0-rc0039",
"contentHash": "407J7x2qWUHd8ByvrWvDf+H9h7DCOmDhcpMh3Zi/1497QEBQX4/jZKEyX5I3Iq9ceDZevf/lssqaLK7DJ3fJaw==",
"requested": "[0.1.0-rc0040, )",
"resolved": "0.1.0-rc0040",
"contentHash": "q5t6h24M+22JQqeBTD9wOOYYAvb1Vk29nkadcOJ05wT569jnF+MGmEherDn1moX45Ehj4TsCvQl3TD4HJlC1mA==",
"dependencies": {
"Ardalis.GuardClauses": "4.0.1",
"Microsoft.Extensions.Configuration": "6.0.1",
Expand Down Expand Up @@ -628,7 +628,7 @@
"monai.deploy.workflowmanager.taskmanager.api": {
"type": "Project",
"dependencies": {
"Monai.Deploy.Messaging": "0.1.0-rc0039",
"Monai.Deploy.Messaging": "0.1.0-rc0040",
"Monai.Deploy.Storage": "0.1.0-rc0019"
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/TaskManager/TaskManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ private async Task HandleTaskCallback(JsonMessage<TaskCallbackEvent> message)
{
var executionStatus = await runner.Runner.GetStatus(message.Body.Identity, _cancellationTokenSource.Token).ConfigureAwait(false);
AcknowledgeMessage(message);
var updateMessage = GenerateUpdateEventMessage(message, message.Body.ExecutionId, message.Body.WorkflowInstanceId, message.Body.TaskId, executionStatus, message.Body.OutputArtifacts);
var updateMessage = GenerateUpdateEventMessage(message, message.Body.ExecutionId, message.Body.WorkflowInstanceId, message.Body.TaskId, executionStatus, message.Body.Outputs);
updateMessage.Body.Metadata.Add(Strings.JobIdentity, message.Body.Identity);
await SendUpdateEvent(updateMessage).ConfigureAwait(false);
}
Expand Down Expand Up @@ -276,7 +276,7 @@ private void AcknowledgeMessage<T>(JsonMessage<T> message)
}
}

private static JsonMessage<TaskUpdateEvent> GenerateUpdateEventMessage<T>(JsonMessage<T> message, string executionId, string WorkflowInstanceId, string taskId, ExecutionStatus executionStatus, Dictionary<string, string> outputArtifacts = null)
private static JsonMessage<TaskUpdateEvent> GenerateUpdateEventMessage<T>(JsonMessage<T> message, string executionId, string WorkflowInstanceId, string taskId, ExecutionStatus executionStatus, List<Messaging.Common.Storage> outputs = null)
{
Guard.Against.Null(message, nameof(message));
Guard.Against.Null(executionStatus, nameof(executionStatus));
Expand All @@ -290,7 +290,7 @@ private static JsonMessage<TaskUpdateEvent> GenerateUpdateEventMessage<T>(JsonMe
WorkflowInstanceId = WorkflowInstanceId,
TaskId = taskId,
Message = executionStatus.Errors,
OutputArtifacts = outputArtifacts ?? new Dictionary<string, string>(),
Outputs = outputs ?? new List<Messaging.Common.Storage>(),
}, TaskManagerApplicationId, message.CorrelationId);
}

Expand Down
8 changes: 4 additions & 4 deletions src/TaskManager/packages.lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@
},
"Monai.Deploy.Messaging": {
"type": "Direct",
"requested": "[0.1.0-rc0039, )",
"resolved": "0.1.0-rc0039",
"contentHash": "407J7x2qWUHd8ByvrWvDf+H9h7DCOmDhcpMh3Zi/1497QEBQX4/jZKEyX5I3Iq9ceDZevf/lssqaLK7DJ3fJaw==",
"requested": "[0.1.0-rc0040, )",
"resolved": "0.1.0-rc0040",
"contentHash": "q5t6h24M+22JQqeBTD9wOOYYAvb1Vk29nkadcOJ05wT569jnF+MGmEherDn1moX45Ehj4TsCvQl3TD4HJlC1mA==",
"dependencies": {
"Ardalis.GuardClauses": "4.0.1",
"Microsoft.Extensions.Configuration": "6.0.1",
Expand Down Expand Up @@ -600,7 +600,7 @@
"monai.deploy.workflowmanager.taskmanager.api": {
"type": "Project",
"dependencies": {
"Monai.Deploy.Messaging": "0.1.0-rc0039",
"Monai.Deploy.Messaging": "0.1.0-rc0040",
"Monai.Deploy.Storage": "0.1.0-rc0019"
}
}
Expand Down
10 changes: 9 additions & 1 deletion src/WorkflowExecuter/Common/EventMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,15 @@ public static TaskDispatchEvent ToTaskDispatchEvent(TaskExecution task, string w
TaskPluginArguments = task.TaskPluginArguments,
Inputs = inputs,
TaskPluginType = task.TaskType,
Metadata = task.Metadata
Metadata = task.Metadata,
IntermediateStorage = new Messaging.Common.Storage
{
Bucket = configuration.Settings["bucket"],
RelativeRootPath = $"{task.OutputDirectory}/tmp",
Endpoint = configuration.Settings["endpoint"],
Name = task.TaskId,
SecuredConnection = bool.Parse(configuration.Settings["securedConnection"])
}
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,14 @@ public void ToTaskDispatchEvent_ValidAeTitleWorkflowRequest_ReturnesTrue()
TaskPluginArguments = new Dictionary<string, string>
{
{ "key", "value" }
},
IntermediateStorage = new Messaging.Common.Storage
{
Bucket = configuration.Settings["bucket"],
Endpoint = configuration.Settings["endpoint"],
Name = task.TaskId,
RelativeRootPath = "minio/workflowid/taskid/tmp",
SecuredConnection = bool.Parse(configuration.Settings["securedConnection"])
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public WorkflowExecuterServiceTests()
_workflowInstanceRepository = new Mock<IWorkflowInstanceRepository>();
_messageBrokerPublisherService = new Mock<IMessageBrokerPublisherService>();
_configuration = Options.Create(new WorkflowManagerOptions() { Messaging = new MessageBrokerConfiguration { Topics = new MessageBrokerConfigurationKeys { TaskDispatchRequest = "md.task.dispatch" } } });
_storageConfiguration = Options.Create(new StorageServiceConfiguration());
_storageConfiguration = Options.Create(new StorageServiceConfiguration() { Settings = new Dictionary<string, string> { { "bucket", "testbucket" }, { "endpoint", "localhost" }, { "securedConnection", "False" } } });

WorkflowExecuterService = new WorkflowExecuterService(_logger.Object, _configuration, _storageConfiguration, _workflowRepository.Object, _workflowInstanceRepository.Object, _messageBrokerPublisherService.Object);
}
Expand Down

0 comments on commit adba7ad

Please sign in to comment.