Skip to content

Commit

Permalink
Refactor RemoteAppExecution plug-ins to a new project
Browse files Browse the repository at this point in the history
- New APIs to allow plug-in projects to extend database setups and configurations
- Add integration test feature for end-to-end RemoteAppExecution
- Rename Plugin to PlugIn

Signed-off-by: Victor Chang <[email protected]>
  • Loading branch information
mocsharp committed Aug 19, 2023
1 parent 22c23d2 commit fb6f764
Show file tree
Hide file tree
Showing 174 changed files with 5,680 additions and 2,178 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ jobs:
timeout-minutes: 30
strategy:
matrix:
feature: [AcrApi, DicomDimseScp, DicomDimseScu, DicomWebExport, DicomWebStow, HealthLevel7, Fhir]
feature: [AcrApi, DicomDimseScp, DicomDimseScu, DicomWebExport, DicomWebStow, HealthLevel7, Fhir, RemoteAppExecutionPlugIn]
database: [ef, mongodb]
fail-fast: false
env:
Expand Down
8 changes: 0 additions & 8 deletions src/Api/DestinationApplicationEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@
* limitations under the License.
*/

using System.Collections.Generic;

namespace Monai.Deploy.InformaticsGateway.Api
{
/// <summary>
Expand All @@ -38,11 +36,5 @@ public class DestinationApplicationEntity : BaseApplicationEntity
/// Gets or sets the port to connect to.
/// </summary>
public int Port { get; set; }

/// <summary>
/// Gets or sets remote application executions.
/// </summary>
public virtual List<RemoteAppExecution> RemoteAppExecutions { get; set; } = new();
public virtual List<DestinationApplicationEntityRemoteAppExecution> DestinationApplicationEntityRemoteAppExecutions { get; set; } = new();
}
}
8 changes: 4 additions & 4 deletions src/Api/ExportRequestDataMessage.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2021-2022 MONAI Consortium
* Copyright 2021-2023 MONAI Consortium
* Copyright 2019-2021 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,6 +17,7 @@

using System.Collections.Generic;
using Ardalis.GuardClauses;
using Monai.Deploy.InformaticsGateway.Api.PlugIns;
using Monai.Deploy.Messaging.Events;

namespace Monai.Deploy.InformaticsGateway.Api
Expand All @@ -32,9 +33,9 @@ public class ExportRequestDataMessage
public string Filename { get; }

/// <summary>
/// Optional list of data output plug-in type names to be executed by the <see cref="IOutputDataPluginEngine"/>.
/// Optional list of data output plug-in type names to be executed by the <see cref="IOutputDataPlugInEngine"/>.
/// </summary>
public List<string> PluginAssemblies
public List<string> PlugInAssemblies
{
get
{
Expand Down Expand Up @@ -62,7 +63,6 @@ public string[] Destinations
get { return _exportRequest.Destinations; }
}


public ExportRequestDataMessage(ExportRequestEvent exportRequest, string filename)
{
IsFailed = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Api/IsExternalinit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

using System.ComponentModel;

namespace System.Runtime.CompilerServices
namespace Monai.Deploy.InformaticsGateway.Api
{
/// <summary>
/// Reserved to be used by the compiler for tracking metadata.
Expand Down
7 changes: 4 additions & 3 deletions src/Api/MonaiApplicationEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Security.Claims;
using Monai.Deploy.InformaticsGateway.Api.PlugIns;

namespace Monai.Deploy.InformaticsGateway.Api
{
Expand Down Expand Up @@ -73,9 +74,9 @@ public class MonaiApplicationEntity : MongoDBEntityBase
public List<string> Workflows { get; set; } = default!;

/// <summary>
/// Optional list of data input plug-in type names to be executed by the <see cref="IInputDataPluginEngine"/>.
/// Optional list of data input plug-in type names to be executed by the <see cref="IInputDataPlugInEngine"/>.
/// </summary>
public List<string> PluginAssemblies { get; set; } = default!;
public List<string> PlugInAssemblies { get; set; } = default!;

/// <summary>
/// Optional field to specify SOP Class UIDs to ignore.
Expand Down Expand Up @@ -134,7 +135,7 @@ public void SetDefaultValues()

AllowedSopClasses ??= new List<string>();

PluginAssemblies ??= new List<string>();
PlugInAssemblies ??= new List<string>();
}

public override string ToString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
using FellowOakDicom;
using Monai.Deploy.InformaticsGateway.Api.Storage;

namespace Monai.Deploy.InformaticsGateway.Api
namespace Monai.Deploy.InformaticsGateway.Api.PlugIns
{
/// <summary>
/// <c>IInputDataPlugin</c> enables lightweight data processing over incoming data received from supported data ingestion
/// <c>IInputDataPlugIn</c> enables lightweight data processing over incoming data received from supported data ingestion
/// services.
/// Refer to <see cref="IInputDataPluginEngine" /> for additional details.
/// Refer to <see cref="IInputDataPlugInEngine" /> for additional details.
/// </summary>
public interface IInputDataPlugin
public interface IInputDataPlugIn
{
string Name { get; }

Task<(DicomFile dicomFile, FileStorageMetadata fileMetadata)> Execute(DicomFile dicomFile, FileStorageMetadata fileMetadata);
Task<(DicomFile dicomFile, FileStorageMetadata fileMetadata)> ExecuteAsync(DicomFile dicomFile, FileStorageMetadata fileMetadata);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
using FellowOakDicom;
using Monai.Deploy.InformaticsGateway.Api.Storage;

namespace Monai.Deploy.InformaticsGateway.Api
namespace Monai.Deploy.InformaticsGateway.Api.PlugIns
{
/// <summary>
/// <c>IInputDataPluginEngine</c> processes incoming data receivied from various supported services through
/// a list of plug-ins based on <see cref="IInputDataPlugin"/>.
/// <c>IInputDataPlugInEngine</c> processes incoming data receivied from various supported services through
/// a list of plug-ins based on <see cref="IInputDataPlugIn"/>.
/// Rules:
/// <list type="bullet">
/// <item>SCP: A list of plug-ins can be configured with each AET, and each plug-in is executed in the order stored, enabling piping of the incoming data before each file is uploaded to the storage service.</item>
Expand All @@ -33,10 +33,10 @@ namespace Monai.Deploy.InformaticsGateway.Api
/// <item>Plug-ins SHALL not accumulate files in memory or storage for bulk processing.</item>
/// </list>
/// </summary>
public interface IInputDataPluginEngine
public interface IInputDataPlugInEngine
{
void Configure(IReadOnlyList<string> pluginAssemblies);

Task<Tuple<DicomFile, FileStorageMetadata>> ExecutePlugins(DicomFile dicomFile, FileStorageMetadata fileMetadata);
Task<Tuple<DicomFile, FileStorageMetadata>> ExecutePlugInsAsync(DicomFile dicomFile, FileStorageMetadata fileMetadata);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
using System.Threading.Tasks;
using FellowOakDicom;

namespace Monai.Deploy.InformaticsGateway.Api
namespace Monai.Deploy.InformaticsGateway.Api.PlugIns
{
/// <summary>
/// <c>IOutputDataPlugin</c> enables lightweight data processing over incoming data received from supported data ingestion
/// <c>IOutputDataPlugIn</c> enables lightweight data processing over incoming data received from supported data ingestion
/// services.
/// Refer to <see cref="IOutputDataPluginEngine" /> for additional details.
/// Refer to <see cref="IOutputDataPlugInEngine" /> for additional details.
/// </summary>
public interface IOutputDataPlugin
public interface IOutputDataPlugIn
{
string Name { get; }

Task<(DicomFile dicomFile, ExportRequestDataMessage exportRequestDataMessage)> Execute(DicomFile dicomFile, ExportRequestDataMessage exportRequestDataMessage);
Task<(DicomFile dicomFile, ExportRequestDataMessage exportRequestDataMessage)> ExecuteAsync(DicomFile dicomFile, ExportRequestDataMessage exportRequestDataMessage);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,22 @@
using System.Collections.Generic;
using System.Threading.Tasks;

namespace Monai.Deploy.InformaticsGateway.Api
namespace Monai.Deploy.InformaticsGateway.Api.PlugIns
{
/// <summary>
/// <c>IOutputDataPluginEngine</c> processes each file before exporting to its destination
/// through a list of plug-ins based on <see cref="IOutputDataPlugin"/>.
/// <c>IOutputDataPlugInEngine</c> processes each file before exporting to its destination
/// through a list of plug-ins based on <see cref="IOutputDataPlugIn"/>.
/// Rules:
/// <list type="bullet">
/// <item>A list of plug-ins can be included with each export request, and each plug-in is executed in the order stored, processing one file at a time, enabling piping of the data before each file is exported.</item>
/// <item>Plugins MUST be lightweight and not hinder the export process.</item>
/// <item>Plugins SHALL not accumulate files in memory or storage for bulk processing.</item>
/// <item>Plug-ins MUST be lightweight and not hinder the export process.</item>
/// <item>Plug-ins SHALL not accumulate files in memory or storage for bulk processing.</item>
/// </list>
/// </summary>
public interface IOutputDataPluginEngine
public interface IOutputDataPlugInEngine
{
void Configure(IReadOnlyList<string> pluginAssemblies);

Task<ExportRequestDataMessage> ExecutePlugins(ExportRequestDataMessage exportRequestDataMessage);
Task<ExportRequestDataMessage> ExecutePlugInsAsync(ExportRequestDataMessage exportRequestDataMessage);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@
using System;
using Ardalis.GuardClauses;

namespace Monai.Deploy.InformaticsGateway.Api
namespace Monai.Deploy.InformaticsGateway.Api.PlugIns
{
[AttributeUsage(AttributeTargets.Class)]
public class PluginNameAttribute : Attribute
public class PlugInNameAttribute : Attribute
{
public string Name { get; set; }

public PluginNameAttribute(string name)
public PlugInNameAttribute(string name)
{
Guard.Against.NullOrWhiteSpace(name, nameof(name));

Expand Down
6 changes: 3 additions & 3 deletions src/InformaticsGateway/Common/SR.cs → src/Api/PlugIns/SR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
* limitations under the License.
*/

using System.IO;
using System;
using System.IO;

namespace Monai.Deploy.InformaticsGateway.Common
namespace Monai.Deploy.InformaticsGateway.Api.PlugIns
{
internal static class SR
public static class SR
{
public const string PlugInDirectoryName = "plug-ins";
public static readonly string PlugInDirectoryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, SR.PlugInDirectoryName);
Expand Down
58 changes: 0 additions & 58 deletions src/Api/RemoteAppExecution.cs

This file was deleted.

6 changes: 3 additions & 3 deletions src/Api/Storage/DicomFileStorageMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public DicomFileStorageMetadata(string associationId, string identifier, string
{
Guard.Against.NullOrWhiteSpace(associationId, nameof(associationId));
Guard.Against.NullOrWhiteSpace(identifier, nameof(identifier));
Guard.Against.NullOrWhiteSpace(identifier, nameof(identifier));
Guard.Against.NullOrWhiteSpace(identifier, nameof(identifier));
Guard.Against.NullOrWhiteSpace(identifier, nameof(identifier));
Guard.Against.NullOrWhiteSpace(studyInstanceUid, nameof(studyInstanceUid));
Guard.Against.NullOrWhiteSpace(seriesInstanceUid, nameof(seriesInstanceUid));
Guard.Against.NullOrWhiteSpace(sopInstanceUid, nameof(sopInstanceUid));

StudyInstanceUid = studyInstanceUid;
SeriesInstanceUid = seriesInstanceUid;
Expand Down
11 changes: 9 additions & 2 deletions src/Api/Storage/FileStorageMetadata.cs
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -18,6 +18,7 @@
using System.Collections.Generic;
using System.Text.Json.Serialization;
using Ardalis.GuardClauses;
using Microsoft.Extensions.Logging;

namespace Monai.Deploy.InformaticsGateway.Api.Storage
{
Expand Down Expand Up @@ -60,7 +61,7 @@ public abstract record FileStorageMetadata
/// For ACR retrieved DICOM/FHIR files: use the original transaction ID embedded in the request.
/// </summary>
[JsonPropertyName("correlationId")]
public string CorrelationId { get; init; } = default!;
public string CorrelationId { get; set; } = default!;

/// <summary>
/// Gets or sets the source of the file.
Expand Down Expand Up @@ -131,6 +132,12 @@ public virtual void SetFailed()
File.SetFailed();
}

public void ChangeCorrelationId(ILogger logger, string correlationId)
{
logger.LogWarning($"Changing correlation ID from {CorrelationId} to {correlationId}.");
CorrelationId = correlationId;
}

public string? PayloadId { get; set; }
}
}
Loading

0 comments on commit fb6f764

Please sign in to comment.