Skip to content

Commit

Permalink
gh-418 Implement data input plug-in engine and integration with SCP s…
Browse files Browse the repository at this point in the history
…ervice

- Implement IInputDataPluginEngine and IInputDataPlugin
- Add unit tests
- Update SCP feature in integration test

Signed-off-by: Victor Chang <[email protected]>
  • Loading branch information
mocsharp committed Aug 3, 2023
1 parent b44839a commit 2ca4c2e
Show file tree
Hide file tree
Showing 29 changed files with 1,152 additions and 188 deletions.
32 changes: 32 additions & 0 deletions src/Api/IInputDataPlugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using System.Threading.Tasks;
using FellowOakDicom;
using Monai.Deploy.InformaticsGateway.Api.Storage;

namespace Monai.Deploy.InformaticsGateway.Api
{
/// <summary>
/// <c>IInputDataPlugin</c> enables lightweight data processing over incoming data received from supported data ingestion
/// services.
/// Refer to <see cref="IInputDataPluginEngine" /> for additional details.
/// </summary>
public interface IInputDataPlugin
{
Task<(DicomFile dicomFile, FileStorageMetadata fileMetadata)> Execute(DicomFile dicomFile, FileStorageMetadata fileMetadata);
}
}
40 changes: 40 additions & 0 deletions src/Api/IInputDataPluginEngine.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright 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.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

using System.Collections.Generic;
using System.Threading.Tasks;
using FellowOakDicom;
using Monai.Deploy.InformaticsGateway.Api.Storage;

namespace Monai.Deploy.InformaticsGateway.Api
{
/// <summary>
/// <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>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>
/// </list>
/// </summary>
public interface IInputDataPluginEngine
{
void Configure(IReadOnlyList<string> pluginAssemblies);

Task<(DicomFile dicomFile, FileStorageMetadata fileMetadata)> ExecutePlugins(DicomFile dicomFile, FileStorageMetadata fileMetadata);
}
}
4 changes: 4 additions & 0 deletions src/Api/MonaiApplicationEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ public class MonaiApplicationEntity : MongoDBEntityBase
/// </summary>
public List<string> Workflows { get; set; } = default!;

public List<string> PluginAssemblies { get; set; } = default!;

/// <summary>
/// Optional field to specify SOP Class UIDs to ignore.
/// <see cref="IgnoredSopClasses"/> and <see cref="AllowedSopClasses"/> are mutually exclusive.
Expand Down Expand Up @@ -128,6 +130,8 @@ public void SetDefaultValues()
IgnoredSopClasses ??= new List<string>();

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

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

public override string ToString()
Expand Down
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 2021 NVIDIA Corporation
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -25,6 +25,7 @@
namespace Monai.Deploy.InformaticsGateway.Database.EntityFramework.Configuration
{
#pragma warning disable CS8604, CS8603

internal class MonaiApplicationEntityConfiguration : IEntityTypeConfiguration<MonaiApplicationEntity>
{
public void Configure(EntityTypeBuilder<MonaiApplicationEntity> builder)
Expand All @@ -51,6 +52,11 @@ public void Configure(EntityTypeBuilder<MonaiApplicationEntity> builder)
v => JsonSerializer.Serialize(v, jsonSerializerSettings),
v => JsonSerializer.Deserialize<List<string>>(v, jsonSerializerSettings))
.Metadata.SetValueComparer(valueComparer);
builder.Property(j => j.PluginAssemblies)
.HasConversion(
v => JsonSerializer.Serialize(v, jsonSerializerSettings),
v => JsonSerializer.Deserialize<List<string>>(v, jsonSerializerSettings))
.Metadata.SetValueComparer(valueComparer);
builder.Property(j => j.IgnoredSopClasses)
.HasConversion(
v => JsonSerializer.Serialize(v, jsonSerializerSettings),
Expand All @@ -67,5 +73,6 @@ public void Configure(EntityTypeBuilder<MonaiApplicationEntity> builder)
builder.Ignore(p => p.Id);
}
}

#pragma warning restore CS8604, CS8603
}
Loading

0 comments on commit 2ca4c2e

Please sign in to comment.