Skip to content

Commit ccaef5e

Browse files
authored
Merge pull request #956 from Project-MONAI/AI-275
Ai 275
2 parents 69385b4 + f305fec commit ccaef5e

File tree

17 files changed

+298
-117
lines changed

17 files changed

+298
-117
lines changed

src/TaskManager/TaskManager/appsettings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,8 @@
108108
"deadLetterExchange": "monaideploy-dead-letter",
109109
"exportRequestQueue": "export_tasks",
110110
"deliveryLimit": 3,
111-
"requeueDelay": 30
111+
"requeueDelay": 3,
112+
"prefetchCount": "5"
112113
}
113114
},
114115
"storage": {

src/WorkflowManager/Common/Services/PayloadService.cs

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
* limitations under the License.
1515
*/
1616

17-
using Ardalis.GuardClauses;
1817
using Microsoft.Extensions.DependencyInjection;
1918
using Microsoft.Extensions.Logging;
2019
using Monai.Deploy.Messaging.Events;
@@ -83,6 +82,7 @@ public PayloadService(
8382
}
8483

8584
var patientDetails = await _dicomService.GetPayloadPatientDetailsAsync(eventPayload.PayloadId.ToString(), eventPayload.Bucket);
85+
var dict = await _dicomService.GetMetaData(eventPayload.PayloadId.ToString(), eventPayload.Bucket).ConfigureAwait(false);
8686

8787
var payload = new Payload
8888
{
@@ -96,7 +96,8 @@ public PayloadService(
9696
Timestamp = eventPayload.Timestamp,
9797
PatientDetails = patientDetails,
9898
PayloadDeleted = PayloadDeleted.No,
99-
Expires = await GetExpiry(DateTime.UtcNow, eventPayload.WorkflowInstanceId)
99+
Expires = await GetExpiry(DateTime.UtcNow, eventPayload.WorkflowInstanceId),
100+
SeriesInstanceUid = _dicomService.GetSeriesInstanceUID(dict)
100101
};
101102

102103
if (await _payloadRepository.CreateAsync(payload))
@@ -197,13 +198,7 @@ public async Task<bool> DeletePayloadFromStorageAsync(string payloadId)
197198
{
198199
ArgumentNullException.ThrowIfNullOrWhiteSpace(payloadId, nameof(payloadId));
199200

200-
var payload = await GetByIdAsync(payloadId);
201-
202-
if (payload is null)
203-
{
204-
throw new MonaiNotFoundException($"Payload with ID: {payloadId} not found");
205-
}
206-
201+
var payload = await GetByIdAsync(payloadId) ?? throw new MonaiNotFoundException($"Payload with ID: {payloadId} not found");
207202
if (payload.PayloadDeleted == PayloadDeleted.InProgress || payload.PayloadDeleted == PayloadDeleted.Yes)
208203
{
209204
throw new MonaiBadRequestException($"Deletion of files for payload ID: {payloadId} already in progress or already deleted");

src/WorkflowManager/Contracts/Migrations/M001_Payload_addVerion.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace Monai.Deploy.WorkflowManager.Common.Contracts.Migrations
2121
{
2222
public class M001_Payload_addVerion : DocumentMigration<Payload>
2323
{
24-
public M001_Payload_addVerion() : base("1.0.0") { }
24+
public M001_Payload_addVerion() : base("1.0.1") { }
2525

2626
public override void Up(BsonDocument document)
2727
{

src/WorkflowManager/Contracts/Migrations/M002_Payload_addPayloadDeleted.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace Monai.Deploy.WorkflowManager.Common.Contracts.Migrations
2121
{
2222
public class M002_Payload_addPayloadDeleted : DocumentMigration<Payload>
2323
{
24-
public M002_Payload_addPayloadDeleted() : base("1.0.1") { }
24+
public M002_Payload_addPayloadDeleted() : base("1.0.2") { }
2525

2626
public override void Up(BsonDocument document)
2727
{
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
//
2+
// Copyright 2023 Guy’s and St Thomas’ NHS Foundation Trust
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+
using Monai.Deploy.WorkflowManager.Common.Contracts.Models;
17+
using Mongo.Migration.Migrations.Document;
18+
using MongoDB.Bson;
19+
20+
namespace Monai.Deploy.WorkflowManager.Common.Contracts.Migrations
21+
{
22+
public class M005_Payload_seriesUid : DocumentMigration<Payload>
23+
{
24+
public M005_Payload_seriesUid() : base("1.0.5") { }
25+
26+
public override void Up(BsonDocument document)
27+
{
28+
document.Add("SeriesInstanceUid", BsonNull.Create(null).ToJson(), true);
29+
}
30+
31+
public override void Down(BsonDocument document)
32+
{
33+
try
34+
{
35+
document.Remove("SeriesInstanceUid");
36+
}
37+
catch
38+
{ // can ignore we dont want failures stopping startup !
39+
}
40+
}
41+
}
42+
}

src/WorkflowManager/Contracts/Models/Payload.cs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,11 @@
2727

2828
namespace Monai.Deploy.WorkflowManager.Common.Contracts.Models
2929
{
30-
[CollectionLocation("Payloads"), RuntimeVersion("1.0.4")]
30+
[CollectionLocation("Payloads"), RuntimeVersion("1.0.5")]
3131
public class Payload : IDocument
3232
{
3333
[JsonConverter(typeof(DocumentVersionConvert)), BsonSerializer(typeof(DocumentVersionConverBson))]
34-
public DocumentVersion Version { get; set; } = new DocumentVersion(1, 0, 4);
34+
public DocumentVersion Version { get; set; } = new DocumentVersion(1, 0, 5);
3535

3636
[JsonProperty(PropertyName = "id")]
3737
public string Id { get; set; } = string.Empty;
@@ -71,6 +71,9 @@ public class Payload : IDocument
7171
[JsonProperty(PropertyName = "expires")]
7272
public DateTime? Expires { get; set; }
7373

74+
[JsonProperty(PropertyName = "series_instance_uid")]
75+
public string? SeriesInstanceUid { get; set; }
76+
7477
}
7578

7679
public enum PayloadDeleted

src/WorkflowManager/Contracts/Models/PayloadDto.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public PayloadDto(Payload payload)
3636
Files = payload.Files;
3737
PatientDetails = payload.PatientDetails;
3838
PayloadDeleted = payload.PayloadDeleted;
39+
SeriesInstanceUid = payload.SeriesInstanceUid;
3940
}
4041

4142
[JsonProperty(PropertyName = "payload_status")]

src/WorkflowManager/Logging/Log.200000.Workflow.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,5 +111,8 @@ public static partial class Log
111111

112112
[LoggerMessage(EventId = 210018, Level = LogLevel.Error, Message = "ExportList or Artifacts are empty! workflowInstanceId {workflowInstanceId} TaskId {taskId}")]
113113
public static partial void ExportListOrArtifactsAreEmpty(this ILogger logger, string taskId, string workflowInstanceId);
114+
115+
[LoggerMessage(EventId = 210019, Level = LogLevel.Error, Message = "Task is missing required input artifacts {taskId} Artifacts {ArtifactsJson}")]
116+
public static partial void TaskIsMissingRequiredInputArtifacts(this ILogger logger, string taskId, string ArtifactsJson);
114117
}
115118
}

src/WorkflowManager/Logging/Log.600000.Dicom.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,5 +40,11 @@ public static partial class Log
4040

4141
[LoggerMessage(EventId = 600006, Level = LogLevel.Debug, Message = "Dicom export marked as failed with {fileStatusCount} files marked as exported.")]
4242
public static partial void DicomExportFailed(this ILogger logger, string fileStatusCount);
43+
44+
[LoggerMessage(EventId = 600007, Level = LogLevel.Error, Message = "Failed to get DICOM metadata from bucket {bucketId}. Payload: {payloadId}")]
45+
public static partial void FailedToGetDicomMetadataFromBucket(this ILogger logger, string payloadId, string bucketId, Exception ex);
46+
47+
[LoggerMessage(EventId = 600008, Level = LogLevel.Error, Message = "Failed to get DICOM tag {dicomTag} from dictionary")]
48+
public static partial void FailedToGetDicomTagFromDictoionary(this ILogger logger, string dicomTag, Exception ex);
4349
}
4450
}

src/WorkflowManager/Logging/Log.700000.Artifact.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,15 @@ public static partial class Log
5757
[LoggerMessage(EventId = 700011, Level = LogLevel.Debug, Message = "adding files to workflowInstance {workflowInstanceId} :Task {taskId} : {artifactList}")]
5858
public static partial void AddingFilesToWorkflowInstance(this ILogger logger, string workflowInstanceId, string taskId, string artifactList);
5959

60+
[LoggerMessage(EventId = 700012, Level = LogLevel.Error, Message = "Error finding Task :{taskId}")]
61+
public static partial void ErrorFindingTask(this ILogger logger, string taskId);
62+
63+
[LoggerMessage(EventId = 700013, Level = LogLevel.Error, Message = "Error finding Task :{taskId} or previousTask {previousTask}")]
64+
public static partial void ErrorFindingTaskOrPrevious(this ILogger logger, string taskId, string previousTask);
65+
66+
[LoggerMessage(EventId = 700014, Level = LogLevel.Warning, Message = "Error Task :{taskId} cant be trigger as it has missing artifacts {missingtypesJson}")]
67+
public static partial void ErrorTaskMissingArtifacts(this ILogger logger, string taskId, string missingtypesJson);
68+
6069

6170
}
6271
}

0 commit comments

Comments
 (0)