Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions src/TaskManager/Plug-ins/TestPlugin/TestPlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,25 +17,21 @@
using Ardalis.GuardClauses;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Monai.Deploy.Messaging.API;
using Monai.Deploy.Messaging.Events;
using Monai.Deploy.WorkflowManager.TaskManager.API;

namespace Monai.Deploy.WorkflowManager.TaskManager.TestPlugin
{
public class TestPlugin : TaskPluginBase, IAsyncDisposable
public class TestPlugin : TaskPluginBase
{
private const string TaskManagerApplicationId = "4c9072a1-35f5-4d85-847d-dafca22244a8";
private readonly IServiceScope _scope;
private readonly ILogger<TestPlugin> _logger;
private readonly IMessageBrokerPublisherService? _messageBrokerPublisherService;

private string _executeTaskStatus = String.Empty;
private string _getStatusStatus = String.Empty;

public TestPlugin(
IServiceScopeFactory serviceScopeFactory,
IMessageBrokerPublisherService messageBrokerPublisherService,
ILogger<TestPlugin> logger,
TaskDispatchEvent taskDispatchEvent)
: base(taskDispatchEvent)
Expand All @@ -45,7 +41,6 @@ public TestPlugin(
_scope = serviceScopeFactory.CreateScope();

_logger = logger ?? throw new ArgumentNullException(nameof(logger));
_messageBrokerPublisherService = messageBrokerPublisherService ?? throw new ArgumentNullException(nameof(messageBrokerPublisherService));
_executeTaskStatus = string.Empty;
_getStatusStatus = string.Empty;
ValidateEventAndInit();
Expand Down Expand Up @@ -128,11 +123,5 @@ protected override void Dispose(bool disposing)

base.Dispose(disposing);
}

public async ValueTask DisposeAsync()
{
Dispose(disposing: false);
GC.SuppressFinalize(this);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public interface IPayloadRepsitory
/// <summary>
/// Retrieves a list of payloads in the database.
/// </summary>
Task<IList<Payload>> GetAllAsync(int? skip = null, int? limit = null, string? patientId = "", string? patientName = "");
Task<IList<Payload>> GetAllAsync(int? skip = null, int? limit = null, string patientId = "", string patientName = "");

/// <summary>
/// Retrieves a payload by id in the database.
Expand Down
2 changes: 1 addition & 1 deletion src/WorkflowManager/WorkflowExecuter/Common/EventMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public static TaskDispatchEvent ToTaskDispatchEvent(TaskExecution task, Workflow
IntermediateStorage = new Messaging.Common.Storage
{
Bucket = workflowInstance.BucketId,
RelativeRootPath = $"{task.OutputDirectory}/tmp",
RelativeRootPath = task.OutputDirectory,
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 @@ -319,8 +319,6 @@ private async Task<bool> UpdateWorkflowInstanceStatus(WorkflowInstance workflowI

private async Task HandleDicomExportAsync(WorkflowRevision workflow, WorkflowInstance workflowInstance, TaskExecution task, string correlationId)
{
var exportDestinations = workflow.Workflow?.Tasks?.FirstOrDefault(t => t.Id == task.TaskId)?.ExportDestinations;

var exportList = workflow.Workflow?.Tasks?.FirstOrDefault(t => t.Id == task.TaskId)?.ExportDestinations.Select(e => e.Name).ToArray();

var artifactValues = GetDicomExports(workflow, workflowInstance, task, exportList);
Expand All @@ -335,15 +333,17 @@ private async Task HandleDicomExportAsync(WorkflowRevision workflow, WorkflowIns
await DispatchDicomExport(workflowInstance, task, exportList, artifactValues, correlationId);
}

private string[] GetDicomExports(WorkflowRevision workflow, WorkflowInstance workflowInstance, TaskExecution task, string[] exportDestinations)
private string[] GetDicomExports(WorkflowRevision workflow, WorkflowInstance workflowInstance, TaskExecution task, string[]? exportDestinations)
{
var validExportDestinations = workflow.Workflow?.InformaticsGateway?.ExportDestinations;

#pragma warning disable CS8604 // Possible null reference argument.
if (exportDestinations.IsNullOrEmpty()
|| validExportDestinations.IsNullOrEmpty())
{
return Array.Empty<string>();
}
#pragma warning restore CS8604 // Possible null reference argument.

foreach (var exportDestination in exportDestinations)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ await RetryPolicy.ExecuteAsync(async () =>
try
{
var listOfKeys = new List<string>();
var count = 0;
var listArgs = new ListObjectsArgs()
.WithBucket(bucketName)
.WithPrefix("")
Expand All @@ -61,7 +60,7 @@ await RetryPolicy.ExecuteAsync(async () =>
await Client.RemoveObjectAsync(bucketName, obj.Key);
}
}
catch (Exception e)
catch (Exception)
{

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public void ThenWorkflowInstanceStatusIs(string status)
}
else if (DataHelper.WorkflowRequestMessage.PayloadId != null)
{
_outputHelper.WriteLine($"Retrieving workflow instance by PayloadId={DataHelper.WorkflowRequestMessage.PayloadId.ToString()}");
_outputHelper.WriteLine($"Retrieving workflow instance by PayloadId={DataHelper.WorkflowRequestMessage.PayloadId}");
workflowInstance = MongoClient.GetWorkflowInstance(DataHelper.WorkflowRequestMessage.PayloadId.ToString());
}
else
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public void ThenTheDeletedWorkflowIsNotReturned()
var result = ApiHelper.Response.Content.ReadAsStringAsync().Result;
var workflowRevisions = JsonConvert.DeserializeObject<PagedResponse<List<WorkflowRevision>>>(result);

workflowRevisions.Data.Should().BeNullOrEmpty();
workflowRevisions?.Data.Should().BeNullOrEmpty();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ public void ToTaskDispatchEvent_ValidAeTitleWorkflowRequest_ReturnsTaskDispatch(
Bucket = workflowInstance.BucketId,
Endpoint = configuration.Settings["endpoint"],
Name = task.TaskId,
RelativeRootPath = "minio/workflowid/taskid/tmp",
RelativeRootPath = "minio/workflowid/taskid",
SecuredConnection = bool.Parse(configuration.Settings["securedConnection"])
}
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ public async Task DeleteAsync_WorkflowsDoesntExist_SoftDeltesWorkflow()
var result = await WorkflowsController.DeleteAsync(wrongGuid);

var objectResult = Assert.IsType<ObjectResult>(result);
Assert.Equal(result.As<ObjectResult>().Value.As<ProblemDetails>().Detail, "Failed to validate id, workflow not found");
Assert.Equal("Failed to validate id, workflow not found", result.As<ObjectResult>().Value.As<ProblemDetails>().Detail);

Assert.Equal(404, objectResult.StatusCode);
}
Expand All @@ -463,7 +463,7 @@ public async Task DeleteAsync_WorkflowsServiceThrowsException_Should500Error()
var result = await WorkflowsController.DeleteAsync(workflowRevisionId);

var objectResult = Assert.IsType<ObjectResult>(result);
Assert.Equal(result.As<ObjectResult>().Value.As<ProblemDetails>().Detail, "Unexpected error occured: Error in the application.");
Assert.Equal("Unexpected error occured: Error in the application.", result.As<ObjectResult>().Value.As<ProblemDetails>().Detail);

Assert.Equal(500, objectResult.StatusCode);
}
Expand All @@ -476,7 +476,7 @@ public async Task DeleteAsync_WorkflowsGivenInvalidId_ShouldBadRequest()
var result = await WorkflowsController.DeleteAsync(invalidId);

var objectResult = Assert.IsType<ObjectResult>(result);
Assert.Equal(result.As<ObjectResult>().Value.As<ProblemDetails>().Detail, "Failed to validate id, not a valid guid");
Assert.Equal("Failed to validate id, not a valid guid", result.As<ObjectResult>().Value.As<ProblemDetails>().Detail);

Assert.Equal(400, objectResult.StatusCode);
}
Expand Down