Skip to content

Nds/#422 #429

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Aug 22, 2023
Merged
Show file tree
Hide file tree
Changes from 17 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
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
10 changes: 5 additions & 5 deletions doc/dependency_decisions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@
- - :approve
- Polly
- :who: mocsharp
:why: New BSD License (https://github.com/App-vNext/Polly/raw/main/LICENSE.txt)
:why: New BSD License (https://raw.githubusercontent.com/App-vNext/Polly/main/LICENSE)
:versions:
- 7.2.4
:when: 2022-08-16 23:06:27.913122244 Z
Expand Down Expand Up @@ -2324,28 +2324,28 @@
- - :approve
- MongoDB.Bson
- :who: mocsharp
:why: Apache-2.0 (https://github.com/mongodb/mongo-csharp-driver/raw/master/License.txt)
:why: Apache-2.0 (https://raw.githubusercontent.com/mongodb/mongo-csharp-driver/master/LICENSE.md)
:versions:
- 2.21.0
:when: 2022-11-16 23:38:53.891380809 Z
- - :approve
- MongoDB.Driver
- :who: mocsharp
:why: Apache-2.0 (https://github.com/mongodb/mongo-csharp-driver/raw/master/License.txt)
:why: Apache-2.0 (https://raw.githubusercontent.com/mongodb/mongo-csharp-driver/master/LICENSE.md)
:versions:
- 2.21.0
:when: 2022-11-16 23:38:54.213853364 Z
- - :approve
- MongoDB.Driver.Core
- :who: mocsharp
:why: Apache-2.0 (https://github.com/mongodb/mongo-csharp-driver/raw/master/License.txt)
:why: Apache-2.0 (https://raw.githubusercontent.com/mongodb/mongo-csharp-driver/master/LICENSE.md)
:versions:
- 2.21.0
:when: 2022-11-16 23:38:54.553730219 Z
- - :approve
- MongoDB.Libmongocrypt
- :who: mocsharp
:why: Apache-2.0 (https://github.com/mongodb/mongo-csharp-driver/raw/master/License.txt)
:why: Apache-2.0 (https://raw.githubusercontent.com/mongodb/mongo-csharp-driver/master/LICENSE.md)
:versions:
- 1.8.0
:when: 2022-11-16 23:38:54.863359236 Z
Expand Down
1 change: 0 additions & 1 deletion docs/compliance/third-party-licenses.md
Original file line number Diff line number Diff line change
Expand Up @@ -41669,4 +41669,3 @@ Data pulled from spdx/license-list-data on February 9, 2023.
```

</details>

13 changes: 9 additions & 4 deletions src/Api/ExportRequestDataMessage.cs
100644 → 100755
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 All @@ -47,6 +48,11 @@ public string ExportTaskId
get { return _exportRequest.ExportTaskId; }
}

public string WorkflowInstanceId
{
get { return _exportRequest.WorkflowInstanceId; }
}

public string CorrelationId
{
get { return _exportRequest.CorrelationId; }
Expand All @@ -57,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
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; }
}
}
11 changes: 11 additions & 0 deletions src/Api/Storage/Payload.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,10 @@ public enum PayloadState

public string CorrelationId { get; init; }

public string? WorkflowInstanceId { get; init; }

public string? TaskId { get; init; }

public int Count { get => Files.Count; }

public bool HasTimedOut { get => ElapsedTime().TotalSeconds >= Timeout; }
Expand All @@ -80,13 +84,20 @@ public TimeSpan Elapsed
public int FilesFailedToUpload { get => Files.Count(p => p.IsUploadFailed); }

public Payload(string key, string correlationId, uint timeout)
: this(key, correlationId, null, null, timeout)
{
}

public Payload(string key, string correlationId, string? workflowInstanceId, string? taskId, uint timeout)
{
Guard.Against.NullOrWhiteSpace(key, nameof(key));

Files = new List<FileStorageMetadata>();
_lastReceived = new Stopwatch();

CorrelationId = correlationId;
WorkflowInstanceId = workflowInstanceId;
TaskId = taskId;
MachineName = Environment.MachineName;
DateTimeCreated = DateTime.UtcNow;
PayloadId = Guid.NewGuid();
Expand Down
Loading