Skip to content

Commit

Permalink
refactor: Start deep refactor of the client part of the project.
Browse files Browse the repository at this point in the history
  • Loading branch information
wkirschenmann committed Aug 21, 2023
1 parent ba2c40a commit 97039b2
Show file tree
Hide file tree
Showing 70 changed files with 2,213 additions and 685 deletions.
30 changes: 20 additions & 10 deletions ArmoniK.Extensions.Csharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Symphony", "Symphony", "{E5
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "DLLWorker", "DLLWorker", "{AB285F22-A32F-4C5C-A6B3-294E347BFFAE}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Symphony", "Symphony", "{2343D895-0821-4EBB-A56D-C58F817D5FF4}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Unified", "Unified", "{34DA3A29-FD3C-462B-BD35-38D699C4D901}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArmoniK.EndToEndTests.Common", "Tests\ArmoniK.EndToEndTests\ArmoniK.EndToEndTests.Common\ArmoniK.EndToEndTests.Common.csproj", "{E7AE7482-42A7-4113-AB1E-EBECE53AF6CA}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArmoniK.EndToEndTests.Client", "Tests\ArmoniK.EndToEndTests\ArmoniK.EndToEndTests.Client\ArmoniK.EndToEndTests.Client.csproj", "{7E5AE5BF-099E-4E00-B7CB-1C80FDC7C193}"
Expand All @@ -61,6 +57,14 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArmoniK.EndToEndTests.Worke
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArmoniK.DevelopmentKit.Common.Tests", "Tests\ArmoniK.DevelopmentKit.Common.Tests\ArmoniK.DevelopmentKit.Common.Tests.csproj", "{84BB2691-33F0-45B4-8D63-0ECF82708CFC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Common", "Common", "{129C2A61-56BD-4E29-9B25-8ADC98EC31CB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "EndToEnd", "EndToEnd", "{7C63FF64-D798-4BD1-A461-BEE09B3D1BAC}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Client", "Client", "{B837CF75-270B-4354-9809-61360BB802FB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ArmoniK.DevelopmentKit.Client.Common.Tests", "Client\tests\ArmoniK.DevelopmentKit.Client.Common.Tests\ArmoniK.DevelopmentKit.Client.Common.Tests.csproj", "{637ABAA8-2000-42F1-867A-B3C6531773D4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -115,6 +119,10 @@ Global
{84BB2691-33F0-45B4-8D63-0ECF82708CFC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{84BB2691-33F0-45B4-8D63-0ECF82708CFC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{84BB2691-33F0-45B4-8D63-0ECF82708CFC}.Release|Any CPU.Build.0 = Release|Any CPU
{637ABAA8-2000-42F1-867A-B3C6531773D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{637ABAA8-2000-42F1-867A-B3C6531773D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{637ABAA8-2000-42F1-867A-B3C6531773D4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{637ABAA8-2000-42F1-867A-B3C6531773D4}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -138,12 +146,14 @@ Global
{E6F98032-63BB-41CC-8E71-5E5DB54C3A87} = {9EFC0507-3071-4F7D-BFDD-6D99880D80C4}
{E5766860-034C-4F83-907B-922205DD2E0E} = {9EFC0507-3071-4F7D-BFDD-6D99880D80C4}
{AB285F22-A32F-4C5C-A6B3-294E347BFFAE} = {9EFC0507-3071-4F7D-BFDD-6D99880D80C4}
{2343D895-0821-4EBB-A56D-C58F817D5FF4} = {29622951-3654-41F0-9393-11D6737FD1F0}
{34DA3A29-FD3C-462B-BD35-38D699C4D901} = {29622951-3654-41F0-9393-11D6737FD1F0}
{E7AE7482-42A7-4113-AB1E-EBECE53AF6CA} = {CD412C3D-63D0-4726-B4C3-FEF701E4DCAF}
{7E5AE5BF-099E-4E00-B7CB-1C80FDC7C193} = {CD412C3D-63D0-4726-B4C3-FEF701E4DCAF}
{B960962F-4CB1-480D-8D10-9DE2990896B7} = {CD412C3D-63D0-4726-B4C3-FEF701E4DCAF}
{84BB2691-33F0-45B4-8D63-0ECF82708CFC} = {CD412C3D-63D0-4726-B4C3-FEF701E4DCAF}
{E7AE7482-42A7-4113-AB1E-EBECE53AF6CA} = {7C63FF64-D798-4BD1-A461-BEE09B3D1BAC}
{7E5AE5BF-099E-4E00-B7CB-1C80FDC7C193} = {7C63FF64-D798-4BD1-A461-BEE09B3D1BAC}
{B960962F-4CB1-480D-8D10-9DE2990896B7} = {7C63FF64-D798-4BD1-A461-BEE09B3D1BAC}
{84BB2691-33F0-45B4-8D63-0ECF82708CFC} = {129C2A61-56BD-4E29-9B25-8ADC98EC31CB}
{129C2A61-56BD-4E29-9B25-8ADC98EC31CB} = {CD412C3D-63D0-4726-B4C3-FEF701E4DCAF}
{7C63FF64-D798-4BD1-A461-BEE09B3D1BAC} = {CD412C3D-63D0-4726-B4C3-FEF701E4DCAF}
{B837CF75-270B-4354-9809-61360BB802FB} = {CD412C3D-63D0-4726-B4C3-FEF701E4DCAF}
{637ABAA8-2000-42F1-867A-B3C6531773D4} = {B837CF75-270B-4354-9809-61360BB802FB}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1285A466-2AF6-43E6-8DCC-2F93A5D5F02E}
Expand Down
1 change: 1 addition & 0 deletions ArmoniK.Extensions.Csharp.sln.DotSettings
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
<s:Boolean x:Key="/Default/UserDictionary/Words/=qmdm/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=redispatched/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=requeued/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=Retriable/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=serilog/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=subtask/@EntryIndexedValue">True</s:Boolean>
<s:Boolean x:Key="/Default/UserDictionary/Words/=subtasking/@EntryIndexedValue">True</s:Boolean>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFrameworks>net472;net48;netstandard2.0;net5.0;net6.0</TargetFrameworks>
<TargetFrameworks>net472;net48;netstandard2.0;net6.0</TargetFrameworks>
<OutputType>Library</OutputType>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<IsPackable>true</IsPackable>
Expand All @@ -11,6 +11,8 @@
<ItemGroup>
<PackageReference Include="ArmoniK.Api.Client" Version="3.11.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.EnvironmentVariables" Version="7.0.0" />
<PackageReference Include="Polly" Version="7.2.4" />
<PackageReference Include="Polly.Contrib.WaitAndRetry" Version="1.1.1" />
</ItemGroup>

<ItemGroup>
Expand All @@ -21,4 +23,8 @@
<RemoveDir Directories="$(NugetPackageRoot)/$(PackageId.ToLower())/" />
</Target>

<ItemGroup>
<InternalsVisibleTo Include="$(AssemblyName).Tests,PublicKey=0024000004800000940000000602000000240000525341310004000001000100b9cbe494cb23f1c9a351b8d0f211ba3f27afd44f1e683f1c08077b08372ad2649a9427e888c2aad68f010776c168f7a755e6ec591e48fcdd6928d2d6f1aeba06f7c3857437a5a15c7407756e17c3e1877a92eb5f9c82369731520f257bbca1f61a4caaa8aafc7aa40c5810cb81f16c68b4d4f8aa3044b09f7b417ca553bd53be"/>
</ItemGroup>

</Project>
34 changes: 17 additions & 17 deletions Client/src/Common/Exceptions/ServiceInvocationException.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public class ServiceInvocationException : Exception
/// The default constructor
/// </summary>
/// <param name="message">The message to set for the exception</param>
/// <param name="statusCode">the statusCode in the output</param>
public ServiceInvocationException(string message,
ArmonikStatusCode statusCode)
/// <param name="taskStatusCode">the taskStatusCode in the output</param>
public ServiceInvocationException(string message,
ArmonikTaskStatusCode taskStatusCode)
{
message_ = message;
StatusCode = statusCode;
message_ = message;
TaskStatusCode = taskStatusCode;
}

/// <summary>
Expand All @@ -57,36 +57,36 @@ public ServiceInvocationException(Exception e)
/// The overriden constructor to accept inner Exception as parameters
/// </summary>
/// <param name="e">The previous exception</param>
/// <param name="statusCode">The status of the task which is failing</param>
public ServiceInvocationException(Exception e,
ArmonikStatusCode statusCode)
/// <param name="taskStatusCode">The status of the task which is failing</param>
public ServiceInvocationException(Exception e,
ArmonikTaskStatusCode taskStatusCode)
: base(e.Message,
e)
{
StatusCode = statusCode;
message_ = $"{message_} with InnerException {e.GetType()} message : {e.Message}";
TaskStatusCode = taskStatusCode;
message_ = $"{message_} with InnerException {e.GetType()} message : {e.Message}";
}

/// <summary>
/// The overriden constructor to acceptation inner exception and message as parameters
/// </summary>
/// <param name="message">The message to set in the exception</param>
/// <param name="e">The previous exception generated by failure</param>
/// <param name="statusCode">The status of the task which is failing</param>
public ServiceInvocationException(string message,
ArgumentException e,
ArmonikStatusCode statusCode)
/// <param name="taskStatusCode">The status of the task which is failing</param>
public ServiceInvocationException(string message,
ArgumentException e,
ArmonikTaskStatusCode taskStatusCode)
: base(message,
e)
{
message_ = message;
StatusCode = statusCode;
message_ = message;
TaskStatusCode = taskStatusCode;
}

/// <summary>
/// The status code when error occurred
/// </summary>
public ArmonikStatusCode StatusCode { get; }
public ArmonikTaskStatusCode TaskStatusCode { get; }

/// <summary>
/// The error details coming from TaskOutput API
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ namespace ArmoniK.DevelopmentKit.Client.Common.Status;
/// List of status for task and result in Armonik
/// </summary>
[PublicAPI]
public enum ArmonikStatusCode
public enum ArmonikTaskStatusCode
{
/// <summary>
/// Unknown status of task or result
Expand All @@ -34,7 +34,6 @@ public enum ArmonikStatusCode
/// <summary>
/// The task is completed but result could not be ready
/// </summary>
[Obsolete("unused")]
TaskCompleted,

/// <summary>
Expand Down
8 changes: 4 additions & 4 deletions Client/src/Common/Status/ResultStatusData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

using ArmoniK.Api.gRPC.V1;
using ArmoniK.DevelopmentKit.Client.Common.Submitter.ApiExt;

using JetBrains.Annotations;

Expand All @@ -27,6 +27,6 @@ namespace ArmoniK.DevelopmentKit.Client.Common.Status;
/// <param name="TaskId">The id of the task producing the result</param>
/// <param name="Status">The status of the result</param>
[PublicAPI]
public sealed record ResultStatusData(string ResultId,
string TaskId,
ResultStatus Status);
public sealed record ResultStatusData(string ResultId,
string TaskId,
ArmoniKResultStatus Status);
26 changes: 13 additions & 13 deletions Client/src/Common/Status/TaskStatusExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@ public static class TaskStatusExt
/// </summary>
/// <param name="taskStatus">the native API status to convert</param>
/// <returns>the SDK status</returns>
public static ArmonikStatusCode ToArmonikStatusCode(this TaskStatus taskStatus)
public static ArmonikTaskStatusCode ToArmonikStatusCode(this TaskStatus taskStatus)
=> taskStatus switch
{
TaskStatus.Submitted => ArmonikStatusCode.ResultNotReady,
TaskStatus.Timeout => ArmonikStatusCode.TaskTimeout,
TaskStatus.Cancelled => ArmonikStatusCode.TaskCancelled,
TaskStatus.Cancelling => ArmonikStatusCode.TaskCancelled,
TaskStatus.Error => ArmonikStatusCode.TaskFailed,
TaskStatus.Processing => ArmonikStatusCode.ResultNotReady,
TaskStatus.Dispatched => ArmonikStatusCode.ResultNotReady,
TaskStatus.Completed => ArmonikStatusCode.ResultNotReady,
TaskStatus.Creating => ArmonikStatusCode.ResultNotReady,
TaskStatus.Unspecified => ArmonikStatusCode.TaskFailed,
TaskStatus.Processed => ArmonikStatusCode.ResultReady,
_ => ArmonikStatusCode.Unknown,
TaskStatus.Submitted => ArmonikTaskStatusCode.ResultNotReady,
TaskStatus.Timeout => ArmonikTaskStatusCode.TaskTimeout,
TaskStatus.Cancelled => ArmonikTaskStatusCode.TaskCancelled,
TaskStatus.Cancelling => ArmonikTaskStatusCode.TaskCancelled,
TaskStatus.Error => ArmonikTaskStatusCode.TaskFailed,
TaskStatus.Processing => ArmonikTaskStatusCode.ResultNotReady,
TaskStatus.Dispatched => ArmonikTaskStatusCode.ResultNotReady,
TaskStatus.Completed => ArmonikTaskStatusCode.TaskCompleted,
TaskStatus.Creating => ArmonikTaskStatusCode.ResultNotReady,
TaskStatus.Unspecified => ArmonikTaskStatusCode.Unknown,
TaskStatus.Processed => ArmonikTaskStatusCode.ResultReady,
_ => ArmonikTaskStatusCode.Unknown,
};
}
49 changes: 49 additions & 0 deletions Client/src/Common/Submitter/ApiExt/ArmoniKException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// This file is part of the ArmoniK project
//
// Copyright (C) ANEO, 2021-2023. All rights reserved.
//
// 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;
using System.Runtime.Serialization;

using JetBrains.Annotations;

namespace ArmoniK.DevelopmentKit.Client.Common.Submitter.ApiExt;

/// <inheritdoc />
[PublicAPI]
public class ArmoniKException : ApplicationException
{
/// <inheritdoc />
public ArmoniKException(string? message,
Exception? innerException)
: base(message,
innerException)
{
}

/// <inheritdoc />
public ArmoniKException(string? message)
: base(message)
{
}

/// <inheritdoc />
public ArmoniKException(SerializationInfo info,
StreamingContext context)
: base(info,
context)
{
}
}
31 changes: 31 additions & 0 deletions Client/src/Common/Submitter/ApiExt/ArmoniKResultStatus.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
// This file is part of the ArmoniK project
//
// Copyright (C) ANEO, 2021-2023. All rights reserved.
//
// 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 JetBrains.Annotations;

namespace ArmoniK.DevelopmentKit.Client.Common.Submitter.ApiExt;

/// <summary>
/// Enum representing the status of a result
/// </summary>
[PublicAPI]
public enum ArmoniKResultStatus
{
Unknown,
Ready,
NotReady,
Error,
}
37 changes: 37 additions & 0 deletions Client/src/Common/Submitter/ApiExt/ArmoniKResultStatusExt.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// This file is part of the ArmoniK project
//
// Copyright (C) ANEO, 2021-2023. All rights reserved.
//
// 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;

using ArmoniK.Api.gRPC.V1;

namespace ArmoniK.DevelopmentKit.Client.Common.Submitter.ApiExt;

internal static class ArmoniKResultStatusExt
{
public static ArmoniKResultStatus ToArmoniKResultStatus(this ResultStatus resultStatus)
=> resultStatus switch
{
ResultStatus.Unspecified => ArmoniKResultStatus.Unknown,
ResultStatus.Created => ArmoniKResultStatus.NotReady,
ResultStatus.Completed => ArmoniKResultStatus.Ready,
ResultStatus.Aborted => ArmoniKResultStatus.Error,
ResultStatus.Notfound => ArmoniKResultStatus.Error,
_ => throw new ArgumentOutOfRangeException(nameof(resultStatus),
resultStatus,
null),
};
}
Loading

0 comments on commit 97039b2

Please sign in to comment.