From 1b6c66e7cbf95c7b95d5f062dabfd866e229cf4a Mon Sep 17 00:00:00 2001 From: Victor Chang Date: Thu, 24 Aug 2023 08:48:05 -0700 Subject: [PATCH 1/5] Release/0.2.1 (#218) +semver: patch * Add ACR enum in DataService (#217) Signed-off-by: Victor Chang --- src/Messaging/Common/BlockStorageInfo.cs | 5 +- src/Messaging/Common/Credentials.cs | 6 ++- src/Messaging/Common/Storage.cs | 9 +++- src/Messaging/Events/EmailRequestEvent.cs | 10 +++- src/Messaging/Events/ExportCompleteEvent.cs | 16 +++++-- src/Messaging/Events/ExportRequestEvent.cs | 17 ++++++- src/Messaging/Events/TaskCallbackEvent.cs | 10 +++- src/Messaging/Events/TaskCancellationEvent.cs | 12 ++++- src/Messaging/Events/TaskDispatchEvent.cs | 18 +++++++- src/Messaging/Events/TaskUpdateEvent.cs | 19 ++++++-- src/Messaging/Events/WorkflowRequestEvent.cs | 46 +++++++++++++++++-- src/Messaging/Monai.Deploy.Messaging.csproj | 1 + .../Tests/WorkflowRequestMessageTest.cs | 10 ++-- .../Monai.Deploy.Messaging.RabbitMQ.csproj | 1 + 14 files changed, 153 insertions(+), 27 deletions(-) diff --git a/src/Messaging/Common/BlockStorageInfo.cs b/src/Messaging/Common/BlockStorageInfo.cs index 4fed0e3..67645f3 100644 --- a/src/Messaging/Common/BlockStorageInfo.cs +++ b/src/Messaging/Common/BlockStorageInfo.cs @@ -1,5 +1,5 @@ /* - * Copyright 2021-2022 MONAI Consortium + * Copyright 2021-2023 MONAI Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -14,6 +14,7 @@ * limitations under the License. */ +using System.Text.Json.Serialization; using Newtonsoft.Json; namespace Monai.Deploy.Messaging.Common @@ -24,12 +25,14 @@ public class BlockStorageInfo /// Gets or sets the root path to the file. /// [JsonProperty(PropertyName = "path")] + [JsonPropertyName("path")] public string Path { get; set; } = default!; /// /// Gets or sets the root path to the metadata file. /// [JsonProperty(PropertyName = "metadata")] + [JsonPropertyName("metadata")] public string Metadata { get; set; } = default!; } } diff --git a/src/Messaging/Common/Credentials.cs b/src/Messaging/Common/Credentials.cs index de0bdb5..4a9fc16 100644 --- a/src/Messaging/Common/Credentials.cs +++ b/src/Messaging/Common/Credentials.cs @@ -1,5 +1,5 @@ /* - * Copyright 2022 MONAI Consortium + * Copyright 2022-2023 MONAI Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; using Newtonsoft.Json; namespace Monai.Deploy.Messaging.Common @@ -25,6 +26,7 @@ public class Credentials /// Gets or sets the access key or user name of the credentials pair. /// [JsonProperty(PropertyName = "access_key")] + [JsonPropertyName("access_key")] [Required] public string AccessKey { get; set; } @@ -32,6 +34,7 @@ public class Credentials /// Gets or sets the access token or password of the credentials pair. /// [JsonProperty(PropertyName = "access_token")] + [JsonPropertyName("access_token")] [Required] public string AccessToken { get; set; } @@ -39,6 +42,7 @@ public class Credentials /// Gets or sets the session token of the credentials pair. /// [JsonProperty(PropertyName = "session_token")] + [JsonPropertyName("session_token")] public string SessionToken { get; set; } public Credentials() diff --git a/src/Messaging/Common/Storage.cs b/src/Messaging/Common/Storage.cs index 3d71135..3c6ea74 100644 --- a/src/Messaging/Common/Storage.cs +++ b/src/Messaging/Common/Storage.cs @@ -1,5 +1,5 @@ /* - * Copyright 2022 MONAI Consortium + * Copyright 2022-2023 MONAI Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; using Newtonsoft.Json; namespace Monai.Deploy.Messaging.Common @@ -26,6 +27,7 @@ public class Storage : ICloneable /// For Argo, name of the artifact used in the template. /// [JsonProperty(PropertyName = "name")] + [JsonPropertyName("name")] [Required] public string Name { get; set; } @@ -33,6 +35,7 @@ public class Storage : ICloneable /// Gets or sets the endpoint of the storage service. /// [JsonProperty(PropertyName = "endpoint")] + [JsonPropertyName("endpoint")] [Required] public string Endpoint { get; set; } @@ -40,12 +43,14 @@ public class Storage : ICloneable /// Gets or sets credentials for accessing the storage service. /// [JsonProperty(PropertyName = "credentials")] + [JsonPropertyName("credentials")] public Credentials? Credentials { get; set; } /// /// Gets or sets name of the bucket. /// [JsonProperty(PropertyName = "bucket")] + [JsonPropertyName("bucket")] [Required] public string Bucket { get; set; } @@ -53,12 +58,14 @@ public class Storage : ICloneable /// Gets or sets whether the connection should be secured or not. /// [JsonProperty(PropertyName = "secured_connection")] + [JsonPropertyName("secured_connection")] public bool SecuredConnection { get; set; } /// /// Gets or sets the optional relative root path to the data. /// [JsonProperty(PropertyName = "relative_root_path")] + [JsonPropertyName("relative_root_path")] [Required] public string RelativeRootPath { get; set; } diff --git a/src/Messaging/Events/EmailRequestEvent.cs b/src/Messaging/Events/EmailRequestEvent.cs index 195eb37..4ffb2a7 100644 --- a/src/Messaging/Events/EmailRequestEvent.cs +++ b/src/Messaging/Events/EmailRequestEvent.cs @@ -1,5 +1,5 @@ /* - * Copyright 2022 MONAI Consortium + * Copyright 2022-2023 MONAI Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; using Newtonsoft.Json; namespace Monai.Deploy.Messaging.Events @@ -22,29 +23,36 @@ namespace Monai.Deploy.Messaging.Events public class EmailRequestEvent : EventBase { [JsonProperty(PropertyName = "id")] + [JsonPropertyName("id")] [Required] public Guid Id { get; set; } [JsonProperty(PropertyName = "workflow_instance_id")] + [JsonPropertyName("workflow_instance_id")] [Required] public string WorkflowInstanceId { get; set; } [JsonProperty(PropertyName = "workflow_name")] + [JsonPropertyName("workflow_name")] [Required] public string WorkflowName { get; set; } [JsonProperty(PropertyName = "task_id")] + [JsonPropertyName("task_id")] [Required] public string TaskId { get; set; } [JsonProperty(PropertyName = "roles")] + [JsonPropertyName("roles")] public string Roles { get; set; } [JsonProperty(PropertyName = "emails")] + [JsonPropertyName("emails")] public string Emails { get; set; } [Required] [JsonProperty(PropertyName = "metadata")] + [JsonPropertyName("metadata")] public Dictionary Metadata { get; set; } public EmailRequestEvent() diff --git a/src/Messaging/Events/ExportCompleteEvent.cs b/src/Messaging/Events/ExportCompleteEvent.cs index 7893189..ac3de11 100755 --- a/src/Messaging/Events/ExportCompleteEvent.cs +++ b/src/Messaging/Events/ExportCompleteEvent.cs @@ -1,5 +1,5 @@ /* - * Copyright 2021-2022 MONAI Consortium + * Copyright 2021-2023 MONAI Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,8 +15,8 @@ */ using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; using Ardalis.GuardClauses; -using Monai.Deploy.Messaging.Common; using Newtonsoft.Json; using Newtonsoft.Json.Converters; @@ -28,6 +28,7 @@ public class ExportCompleteEvent : EventBase /// Gets or sets the workflow instanceID generated by the Workflow Manager. /// [JsonProperty(PropertyName = "workflow_instance_id")] + [JsonPropertyName("workflow_instance_id")] [Required] public string WorkflowInstanceId { get; set; } = default!; @@ -35,6 +36,7 @@ public class ExportCompleteEvent : EventBase /// Gets or sets the export task ID generated by the Workflow Manager. /// [JsonProperty(PropertyName = "export_task_id")] + [JsonPropertyName("export_task_id")] [Required] public string ExportTaskId { get; set; } = default!; @@ -42,7 +44,9 @@ public class ExportCompleteEvent : EventBase /// Gets or sets the state of the export task. /// [JsonProperty(PropertyName = "status")] - [JsonConverter(typeof(StringEnumConverter))] + [JsonPropertyName("status")] + [Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))] + [System.Text.Json.Serialization.JsonConverter(typeof(JsonStringEnumConverter))] [Required] public ExportStatus Status { get; set; } @@ -50,15 +54,19 @@ public class ExportCompleteEvent : EventBase /// Gets or sets error messages, if any, when exporting. /// [JsonProperty(PropertyName = "message")] + [JsonPropertyName("message")] public string Message { get; set; } = default!; /// /// Gets or sets files exported with its status /// [JsonProperty(PropertyName = "file_statuses")] + [JsonPropertyName("file_statuses")] public Dictionary FileStatuses { get; set; } - [JsonConstructor] + [Newtonsoft.Json.JsonConstructor] + [System.Text.Json.Serialization.JsonConstructor] + public ExportCompleteEvent() { Status = ExportStatus.Unknown; diff --git a/src/Messaging/Events/ExportRequestEvent.cs b/src/Messaging/Events/ExportRequestEvent.cs index 2d6c89e..b5fd258 100755 --- a/src/Messaging/Events/ExportRequestEvent.cs +++ b/src/Messaging/Events/ExportRequestEvent.cs @@ -1,5 +1,5 @@ /* - * Copyright 2021-2022 MONAI Consortium + * Copyright 2021-2023 MONAI Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ using System.ComponentModel.DataAnnotations; -using Monai.Deploy.Messaging.Common; +using System.Text.Json.Serialization; using Newtonsoft.Json; namespace Monai.Deploy.Messaging.Events @@ -26,6 +26,7 @@ public class ExportRequestEvent : EventBase /// Gets or sets the workflow instance ID generated by the Workflow Manager. /// [JsonProperty(PropertyName = "workflow_instance_id")] + [JsonPropertyName("workflow_instance_id")] [Required] public string WorkflowInstanceId { get; set; } = default!; @@ -33,6 +34,7 @@ public class ExportRequestEvent : EventBase /// Gets or sets the export task ID generated by the Workflow Manager. /// [JsonProperty(PropertyName = "export_task_id")] + [JsonPropertyName("export_task_id")] [Required] public string ExportTaskId { get; set; } = default!; @@ -40,6 +42,7 @@ public class ExportRequestEvent : EventBase /// Gets or sets a list of files to be exported. /// [JsonProperty(PropertyName = "files")] + [JsonPropertyName("files")] [Required, MinLength(1)] public IEnumerable Files { get; set; } = default!; @@ -49,6 +52,7 @@ public class ExportRequestEvent : EventBase /// For ACR, the Transaction ID in the original inference request. /// [JsonProperty(PropertyName = "destinations")] + [JsonPropertyName("destinations")] [Required] public string[] Destinations { get; set; } = default!; @@ -58,22 +62,29 @@ public class ExportRequestEvent : EventBase /// For ACR, use the Transaction ID in the original request. /// [JsonProperty(PropertyName = "correlation_id")] + [JsonPropertyName("correlation_id")] [Required] public string CorrelationId { get; set; } = default!; /// /// Gets or sets the delivery tag or acknowledge token for the task. /// + [JsonProperty(PropertyName = "delivery_tag")] + [JsonPropertyName("delivery_tag")] public string DeliveryTag { get; set; } = default!; /// /// Gets or sets the message ID set by the message broker. /// + [JsonProperty(PropertyName = "message_id")] + [JsonPropertyName("message_id")] public string MessageId { get; set; } = default!; /// /// Gets or sets error messages related to this export task. /// + [JsonProperty(PropertyName = "error_messages")] + [JsonPropertyName("error_messages")] public List ErrorMessages { get; private set; } /// @@ -82,6 +93,8 @@ public class ExportRequestEvent : EventBase /// E.g. MyCompnay.MyProject.MyNamepsace.MyPlugin, MyCompnay.MyProject.MyNamepsace where /// MyCompnay.MyProject.MyNamepsace is the name of the assembly (DLL). /// + [JsonProperty(PropertyName = "plug_in_assemblies")] + [JsonPropertyName("plug_in_assemblies")] public List PluginAssemblies { get; private set; } public ExportRequestEvent() diff --git a/src/Messaging/Events/TaskCallbackEvent.cs b/src/Messaging/Events/TaskCallbackEvent.cs index 0601b88..c088910 100644 --- a/src/Messaging/Events/TaskCallbackEvent.cs +++ b/src/Messaging/Events/TaskCallbackEvent.cs @@ -1,5 +1,5 @@ /* - * Copyright 2022 MONAI Consortium + * Copyright 2022-2023 MONAI Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; using Monai.Deploy.Messaging.Common; using Newtonsoft.Json; @@ -26,6 +27,7 @@ public class TaskCallbackEvent : EventBase /// Gets or sets the ID representing the instance of the workflow. /// [JsonProperty(PropertyName = "workflow_instance_id")] + [JsonPropertyName("workflow_instance_id")] [Required] public string WorkflowInstanceId { get; set; } @@ -34,12 +36,14 @@ public class TaskCallbackEvent : EventBase /// [Required] [JsonProperty(PropertyName = "task_id")] + [JsonPropertyName("task_id")] public string TaskId { get; set; } /// /// Gets or sets the execution ID representing the instance of the task. /// [JsonProperty(PropertyName = "execution_id")] + [JsonPropertyName("execution_id")] [Required] public string ExecutionId { get; set; } @@ -47,6 +51,7 @@ public class TaskCallbackEvent : EventBase /// Gets or sets the correlation ID. /// [JsonProperty(PropertyName = "correlation_id")] + [JsonPropertyName("correlation_id")] [Required] public string CorrelationId { get; set; } @@ -54,6 +59,7 @@ public class TaskCallbackEvent : EventBase /// Gets or sets the identity provided by the external service. /// [JsonProperty(PropertyName = "identity")] + [JsonPropertyName("identity")] [Required] public string Identity { get; set; } @@ -61,12 +67,14 @@ public class TaskCallbackEvent : EventBase /// Gets or sets any metadata generated by the task, including any output generated. /// [JsonProperty(PropertyName = "metadata")] + [JsonPropertyName("metadata")] public Dictionary Metadata { get; set; } /// /// Gets or sets the output storage information. /// [JsonProperty(PropertyName = "outputs")] + [JsonPropertyName("outputs")] public List Outputs { get; set; } public TaskCallbackEvent() diff --git a/src/Messaging/Events/TaskCancellationEvent.cs b/src/Messaging/Events/TaskCancellationEvent.cs index 8498384..aae9879 100644 --- a/src/Messaging/Events/TaskCancellationEvent.cs +++ b/src/Messaging/Events/TaskCancellationEvent.cs @@ -1,5 +1,5 @@ /* - * Copyright 2022 MONAI Consortium + * Copyright 2022-2023 MONAI Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,9 @@ */ using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; using Newtonsoft.Json; +using Newtonsoft.Json.Converters; namespace Monai.Deploy.Messaging.Events { @@ -25,6 +27,7 @@ public class TaskCancellationEvent : EventBase /// Gets or sets the ID representing the instance of the workflow. /// [JsonProperty(PropertyName = "workflow_instance_id")] + [JsonPropertyName("workflow_instance_id")] [Required] public string WorkflowInstanceId { get; set; } = string.Empty; @@ -32,6 +35,7 @@ public class TaskCancellationEvent : EventBase /// Gets or sets the execution ID representing the instance of the task. /// [JsonProperty(PropertyName = "execution_id")] + [JsonPropertyName("execution_id")] [Required] public string ExecutionId { get; set; } = string.Empty; @@ -40,12 +44,14 @@ public class TaskCancellationEvent : EventBase /// [Required] [JsonProperty(PropertyName = "task_id")] + [JsonPropertyName("task_id")] public string TaskId { get; set; } = string.Empty; /// /// Gets or sets the identity provided by the external service. /// [JsonProperty(PropertyName = "identity")] + [JsonPropertyName("identity")] [Required, MaxLength(63)] public string Identity { get; set; } = string.Empty; @@ -53,6 +59,9 @@ public class TaskCancellationEvent : EventBase /// Gets or sets the reason for the cancellation. /// [JsonProperty(PropertyName = "reason")] + [JsonPropertyName("reason")] + [Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))] + [System.Text.Json.Serialization.JsonConverter(typeof(JsonStringEnumConverter))] [Required] public FailureReason Reason { get; set; } = FailureReason.Unknown; @@ -60,6 +69,7 @@ public class TaskCancellationEvent : EventBase /// Gets or sets a message relating to the cancellation. /// [JsonProperty(PropertyName = "message")] + [JsonPropertyName("message")] [Required, MaxLength(63)] public string Message { get; set; } = string.Empty; } diff --git a/src/Messaging/Events/TaskDispatchEvent.cs b/src/Messaging/Events/TaskDispatchEvent.cs index 726f7c3..c1aa168 100644 --- a/src/Messaging/Events/TaskDispatchEvent.cs +++ b/src/Messaging/Events/TaskDispatchEvent.cs @@ -1,5 +1,5 @@ /* - * Copyright 2022 MONAI Consortium + * Copyright 2022-2023 MONAI Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; using Monai.Deploy.Messaging.Common; using Newtonsoft.Json; using Newtonsoft.Json.Converters; @@ -27,6 +28,7 @@ public class TaskDispatchEvent : EventBase /// Gets or sets the ID representing the instance of the workflow. /// [JsonProperty(PropertyName = "workflow_instance_id")] + [JsonPropertyName("workflow_instance_id")] [Required] public string WorkflowInstanceId { get; set; } @@ -35,12 +37,14 @@ public class TaskDispatchEvent : EventBase /// [Required] [JsonProperty(PropertyName = "task_id")] + [JsonPropertyName("task_id")] public string TaskId { get; set; } /// /// Gets or sets the execution ID representing the instance of the task. /// [JsonProperty(PropertyName = "execution_id")] + [JsonPropertyName("execution_id")] [Required] public string ExecutionId { get; set; } @@ -48,6 +52,7 @@ public class TaskDispatchEvent : EventBase /// Gets or sets the payload ID of the current workflow instance. /// [JsonProperty(PropertyName = "payload_id")] + [JsonPropertyName("payload_id")] [Required] public string PayloadId { get; set; } @@ -55,6 +60,7 @@ public class TaskDispatchEvent : EventBase /// Gets or sets the correlation ID. /// [JsonProperty(PropertyName = "correlation_id")] + [JsonPropertyName("correlation_id")] [Required] public string CorrelationId { get; set; } @@ -62,6 +68,7 @@ public class TaskDispatchEvent : EventBase /// Gets or sets the type of plug-in the task is associated with. /// [JsonProperty(PropertyName = "type")] + [JsonPropertyName("type")] [Required] public string TaskPluginType { get; set; } @@ -69,13 +76,16 @@ public class TaskDispatchEvent : EventBase /// Gets or sets the task execution arguments. /// [JsonProperty(PropertyName = "task_plugin_arguments")] + [JsonPropertyName("task_plugin_arguments")] public Dictionary TaskPluginArguments { get; set; } /// /// Gets or set the status of the task. /// [JsonProperty(PropertyName = "status")] - [JsonConverter(typeof(StringEnumConverter))] + [JsonPropertyName("status")] + [Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))] + [System.Text.Json.Serialization.JsonConverter(typeof(JsonStringEnumConverter))] [Required] public TaskExecutionStatus Status { get; set; } @@ -83,6 +93,7 @@ public class TaskDispatchEvent : EventBase /// Gets or sets the input storage information. /// [JsonProperty(PropertyName = "inputs")] + [JsonPropertyName("inputs")] [Required, MinLength(1, ErrorMessage = "At least input is required.")] public List Inputs { get; set; } @@ -90,6 +101,7 @@ public class TaskDispatchEvent : EventBase /// Gets or sets the output storage information. /// [JsonProperty(PropertyName = "outputs")] + [JsonPropertyName("outputs")] [Required] public List Outputs { get; set; } @@ -97,6 +109,7 @@ public class TaskDispatchEvent : EventBase /// Gets or sets the intermediate storage information. /// [JsonProperty(PropertyName = "intermediate_storage")] + [JsonPropertyName("intermediate_storage")] [Required] public Storage IntermediateStorage { get; set; } @@ -104,6 +117,7 @@ public class TaskDispatchEvent : EventBase /// Gets or sets any metadata relevant to the task. /// [JsonProperty(PropertyName = "metadata")] + [JsonPropertyName("metadata")] public Dictionary Metadata { get; set; } public TaskDispatchEvent() diff --git a/src/Messaging/Events/TaskUpdateEvent.cs b/src/Messaging/Events/TaskUpdateEvent.cs index 2c2c9fb..b9ea839 100644 --- a/src/Messaging/Events/TaskUpdateEvent.cs +++ b/src/Messaging/Events/TaskUpdateEvent.cs @@ -1,5 +1,5 @@ /* - * Copyright 2022 MONAI Consortium + * Copyright 2022-2023 MONAI Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; using Monai.Deploy.Messaging.Common; using Newtonsoft.Json; using Newtonsoft.Json.Converters; @@ -27,6 +28,7 @@ public class TaskUpdateEvent : EventBase /// Gets or sets the ID representing the instance of the workflow. /// [JsonProperty(PropertyName = "workflow_instance_id")] + [JsonPropertyName("workflow_instance_id")] [Required] public string WorkflowInstanceId { get; set; } @@ -35,12 +37,14 @@ public class TaskUpdateEvent : EventBase /// [Required] [JsonProperty(PropertyName = "task_id")] + [JsonPropertyName("task_id")] public string TaskId { get; set; } /// /// Gets or sets the execution ID representing the instance of the task. /// [JsonProperty(PropertyName = "execution_id")] + [JsonPropertyName("execution_id")] [Required] public string ExecutionId { get; set; } @@ -48,6 +52,7 @@ public class TaskUpdateEvent : EventBase /// Gets or sets the correlation ID. /// [JsonProperty(PropertyName = "correlation_id")] + [JsonPropertyName("correlation_id")] [Required] public string CorrelationId { get; set; } @@ -55,7 +60,9 @@ public class TaskUpdateEvent : EventBase /// Gets or set the status of the task. /// [JsonProperty(PropertyName = "status")] - [JsonConverter(typeof(StringEnumConverter))] + [JsonPropertyName("status")] + [Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))] + [System.Text.Json.Serialization.JsonConverter(typeof(JsonStringEnumConverter))] [Required] public TaskExecutionStatus Status { get; set; } @@ -63,13 +70,16 @@ public class TaskUpdateEvent : EventBase /// Gets or set the execution stats of the task. /// [JsonProperty(PropertyName = "taskStats")] + [JsonPropertyName("taskStats")] public Dictionary ExecutionStats { get; set; } /// /// Gets or set the failure reason of the task. /// [JsonProperty(PropertyName = "reason")] - [JsonConverter(typeof(StringEnumConverter))] + [JsonPropertyName("reason")] + [Newtonsoft.Json.JsonConverter(typeof(StringEnumConverter))] + [System.Text.Json.Serialization.JsonConverter(typeof(JsonStringEnumConverter))] [Required] public FailureReason Reason { get; set; } @@ -77,18 +87,21 @@ public class TaskUpdateEvent : EventBase /// Gets or set any additional (error) message related to the task. /// [JsonProperty(PropertyName = "message")] + [JsonPropertyName("message")] public string Message { get; set; } /// /// Gets or sets any output artifacts relevent to the output of the task. /// [JsonProperty(PropertyName = "outputs")] + [JsonPropertyName("outputs")] public List Outputs { get; set; } /// /// Gets or sets any metadata relevant to the output of the task. /// [JsonProperty(PropertyName = "metadata")] + [JsonPropertyName("metadata")] public Dictionary Metadata { get; set; } public TaskUpdateEvent() diff --git a/src/Messaging/Events/WorkflowRequestEvent.cs b/src/Messaging/Events/WorkflowRequestEvent.cs index 3438f69..982b430 100755 --- a/src/Messaging/Events/WorkflowRequestEvent.cs +++ b/src/Messaging/Events/WorkflowRequestEvent.cs @@ -1,5 +1,5 @@ /* - * Copyright 2021-2022 MONAI Consortium + * Copyright 2021-2023 MONAI Consortium * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,6 +15,7 @@ */ using System.ComponentModel.DataAnnotations; +using System.Text.Json.Serialization; using Monai.Deploy.Messaging.Common; using Newtonsoft.Json; @@ -22,8 +23,9 @@ namespace Monai.Deploy.Messaging.Events { public class DataOrigin { - [JsonProperty(PropertyName = "type")] - public DataType DataType { get; set; } + [JsonProperty(PropertyName = "dataService")] + [JsonPropertyName("dataService")] + public DataService DataService { get; set; } = DataService.Unknown; /// /// Gets or sets the source of the data: @@ -35,6 +37,7 @@ public class DataOrigin /// /// [JsonProperty(PropertyName = "source")] + [JsonPropertyName("source")] [Required] public string Source { get; set; } = default!; @@ -48,10 +51,28 @@ public class DataOrigin /// /// [JsonProperty(PropertyName = "destination")] + [JsonPropertyName("destination")] public string Destination { get; set; } = default!; + + public override int GetHashCode() + { + return HashCode.Combine(Source, Destination, DataService); + } + + public override bool Equals(object? obj) + { + return obj is DataOrigin dataOrigin && + Source.Equals(dataOrigin.Source, StringComparison.Ordinal) && + Destination.Equals(dataOrigin.Destination, StringComparison.Ordinal) && + DataService.Equals(dataOrigin.DataService); + } } - public enum DataType + public enum DataService { + /// + /// Unknown data service + /// + Unknown, /// /// Data received via DIMSE services /// @@ -59,7 +80,7 @@ public enum DataType /// /// Data received via DICOMWeb services /// - DICOMWEB, + DicomWeb, /// /// Data received via FHIR services /// @@ -68,6 +89,10 @@ public enum DataType /// Data received via HL7 services /// HL7, + /// + /// Data received via ACR API call + /// + ACR, } public class WorkflowRequestEvent : EventBase @@ -78,6 +103,7 @@ public class WorkflowRequestEvent : EventBase /// Gets or sets the ID of the payload which is also used as the root path of the payload. /// [JsonProperty(PropertyName = "payload_id")] + [JsonPropertyName("payload_id")] [Required] public Guid PayloadId { get; set; } @@ -85,12 +111,14 @@ public class WorkflowRequestEvent : EventBase /// Gets or sets the associated workflows to be launched. /// [JsonProperty(PropertyName = "workflows")] + [JsonPropertyName("workflows")] public IEnumerable Workflows { get; set; } /// /// Gets or sets number of files in the payload. /// [JsonProperty(PropertyName = "file_count")] + [JsonPropertyName("file_count")] [Required] public int FileCount { get; set; } @@ -99,6 +127,7 @@ public class WorkflowRequestEvent : EventBase /// For an ACR inference request, the correlation ID is the Transaction ID in the original request. /// [JsonProperty(PropertyName = "correlation_id")] + [JsonPropertyName("correlation_id")] [Required] public string CorrelationId { get; set; } = default!; @@ -106,6 +135,7 @@ public class WorkflowRequestEvent : EventBase /// Gets or set the name of the bucket where the files in are stored. /// [JsonProperty(PropertyName = "bucket")] + [JsonPropertyName("bucket")] [Required] public string Bucket { get; set; } = default!; @@ -113,18 +143,21 @@ public class WorkflowRequestEvent : EventBase /// Gets or sets the service that received the original request. /// [JsonProperty(PropertyName = "trigger")] + [JsonPropertyName("trigger")] public DataOrigin DataTrigger { get; set; } = default!; /// /// Gets or sets the data origins that were involved in triggering this workflow request. /// [JsonProperty(PropertyName = "data_origins")] + [JsonPropertyName("data_origins")] public List DataOrigins { get; private set; } /// /// Gets or sets the time the data was received. /// [JsonProperty(PropertyName = "timestamp")] + [JsonPropertyName("timestamp")] [Required] public DateTime Timestamp { get; set; } @@ -134,6 +167,7 @@ public class WorkflowRequestEvent : EventBase /// In standard workflows this will not be set /// [JsonProperty(PropertyName = "workflow_instance_id")] + [JsonPropertyName("workflow_instance_id")] public string? WorkflowInstanceId { get; set; } = default; /// @@ -142,6 +176,7 @@ public class WorkflowRequestEvent : EventBase /// In standard workflows this will not be set /// [JsonProperty(PropertyName = "task_id")] + [JsonPropertyName("task_id")] public string? TaskId { get; set; } = default; /// @@ -149,6 +184,7 @@ public class WorkflowRequestEvent : EventBase /// [JsonProperty(PropertyName = "payload")] [Required, MinLength(1, ErrorMessage = "At least one file is required.")] + [JsonPropertyName("payload")] public IReadOnlyList Payload { get => _payload; } public WorkflowRequestEvent() diff --git a/src/Messaging/Monai.Deploy.Messaging.csproj b/src/Messaging/Monai.Deploy.Messaging.csproj index 4c5df90..3d8f483 100644 --- a/src/Messaging/Monai.Deploy.Messaging.csproj +++ b/src/Messaging/Monai.Deploy.Messaging.csproj @@ -22,6 +22,7 @@ enable false ..\.sonarlint\project-monai_monai-deploy-messagingcsharp.ruleset + true diff --git a/src/Messaging/Tests/WorkflowRequestMessageTest.cs b/src/Messaging/Tests/WorkflowRequestMessageTest.cs index 517d478..22a3553 100644 --- a/src/Messaging/Tests/WorkflowRequestMessageTest.cs +++ b/src/Messaging/Tests/WorkflowRequestMessageTest.cs @@ -32,7 +32,7 @@ public void ConvertsJsonMessageToMessage() Bucket = Guid.NewGuid().ToString(), DataTrigger = new DataOrigin { - DataType = DataType.DIMSE, + DataService = DataService.DIMSE, Source = Guid.NewGuid().ToString(), Destination = Guid.NewGuid().ToString(), }, @@ -46,28 +46,28 @@ public void ConvertsJsonMessageToMessage() }; input.DataOrigins.Add(new DataOrigin { - DataType = DataType.DICOMWEB, + DataService = DataService.DicomWeb, Source = Guid.NewGuid().ToString(), Destination = Guid.NewGuid().ToString(), }); input.DataOrigins.Add(new DataOrigin { - DataType = DataType.FHIR, + DataService = DataService.FHIR, Source = Guid.NewGuid().ToString(), Destination = Guid.NewGuid().ToString(), }); input.DataOrigins.Add(new DataOrigin { - DataType = DataType.DIMSE, + DataService = DataService.DIMSE, Source = Guid.NewGuid().ToString(), Destination = Guid.NewGuid().ToString(), }); input.DataOrigins.Add(new DataOrigin { - DataType = DataType.HL7, + DataService = DataService.HL7, Source = Guid.NewGuid().ToString(), Destination = Guid.NewGuid().ToString(), diff --git a/src/Plugins/RabbitMQ/Monai.Deploy.Messaging.RabbitMQ.csproj b/src/Plugins/RabbitMQ/Monai.Deploy.Messaging.RabbitMQ.csproj index 4628a97..a8b20e4 100644 --- a/src/Plugins/RabbitMQ/Monai.Deploy.Messaging.RabbitMQ.csproj +++ b/src/Plugins/RabbitMQ/Monai.Deploy.Messaging.RabbitMQ.csproj @@ -23,6 +23,7 @@ Monai.Deploy.Messaging.RabbitMQ false $(AllowedOutputExtensionsInPackageBuildOutputFolder);.pdb + true From 12cd750f35edcf7e9e06f7fbee7c43e6337a8e0b Mon Sep 17 00:00:00 2001 From: Victor Chang Date: Thu, 24 Aug 2023 08:50:56 -0700 Subject: [PATCH 2/5] Update GitVersion.yml Signed-off-by: Victor Chang --- GitVersion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GitVersion.yml b/GitVersion.yml index 77eb439..0bf6cdb 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -56,4 +56,4 @@ branches: ignore: sha: [] merge-message-formats: {} -next-version: 0.1.19 +next-version: 0.2.0 From 1f1c13f41cf95a47227d69031fa1afd1f0bff89a Mon Sep 17 00:00:00 2001 From: Victor Chang Date: Thu, 24 Aug 2023 08:52:49 -0700 Subject: [PATCH 3/5] Update GitVersion.yml Signed-off-by: Victor Chang --- GitVersion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GitVersion.yml b/GitVersion.yml index 0bf6cdb..f60383e 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -56,4 +56,4 @@ branches: ignore: sha: [] merge-message-formats: {} -next-version: 0.2.0 +next-version: 0.2.1 From 01cecc80d08f71a4e9b6c03c86c768781d249d0d Mon Sep 17 00:00:00 2001 From: Victor Chang Date: Thu, 24 Aug 2023 08:54:21 -0700 Subject: [PATCH 4/5] Update GitVersion.yml +semver: patch Signed-off-by: Victor Chang --- GitVersion.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GitVersion.yml b/GitVersion.yml index f60383e..0bf6cdb 100644 --- a/GitVersion.yml +++ b/GitVersion.yml @@ -56,4 +56,4 @@ branches: ignore: sha: [] merge-message-formats: {} -next-version: 0.2.1 +next-version: 0.2.0 From 3e31a26af6b2f7d5578a0111dac6c011be46306d Mon Sep 17 00:00:00 2001 From: Victor Chang Date: Thu, 24 Aug 2023 08:56:26 -0700 Subject: [PATCH 5/5] Release/0.2.1 (#219) +semver: patch