Skip to content
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

refactor: Start deep refactor of the client part of the project. #208

Draft
wants to merge 26 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
9d58564
refactor: Start deep refactor of the client part of the project.
wkirschenmann Aug 21, 2023
394da0c
Remove retry code and calls to GetResultId.
wkirschenmann Aug 21, 2023
9288898
Merge branch 'main' into WK-clean
wkirschenmann Aug 22, 2023
b4dacc0
Apply reformat
wkirschenmann Aug 22, 2023
5d6a805
Merge branch 'wk_clean-csproj' into WK-clean
wkirschenmann Aug 23, 2023
d6edac0
Apply reviews
wkirschenmann Aug 23, 2023
f694288
Restore language version 10
wkirschenmann Aug 23, 2023
b2fcf50
Apply format
wkirschenmann Aug 23, 2023
59f1bab
Add tests about retry management.
wkirschenmann Aug 23, 2023
505065c
Avoids different retry mechanisms to mix each other.
wkirschenmann Aug 23, 2023
fa230ac
Correct retry logs
wkirschenmann Aug 23, 2023
ff707fd
Handle the case where download returns null.
wkirschenmann Aug 23, 2023
144c2cd
Merge branch 'main' into WK-clean
wkirschenmann Aug 23, 2023
3049c26
Use new version of core.
wkirschenmann Aug 24, 2023
76a87c1
Begin cleaning remaining retries.
wkirschenmann Aug 24, 2023
e92c17f
Reverting most retry code
wkirschenmann Aug 24, 2023
cff652b
Merge branch 'main' into WK-clean
wkirschenmann Aug 24, 2023
d8c22b5
Correct BlockRequest
wkirschenmann Aug 24, 2023
685d2e9
Deactivate legacy retry policies
wkirschenmann Aug 25, 2023
95e77e5
Clean BaseClientSubmitter.cs
wkirschenmann Aug 25, 2023
574a6d8
fix: channelPool lifecycle
wkirschenmann Aug 25, 2023
1627ce7
doc: as per review.
wkirschenmann Aug 25, 2023
812f139
refactor: remove unused class
aneojgurhem Aug 25, 2023
2f80318
Use ObjectPool instead of ChannelPool
wkirschenmann Aug 25, 2023
89a41eb
renamed a file and thrown an exception.
wkirschenmann Aug 25, 2023
01adf36
Clean format
wkirschenmann Aug 25, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ jobs:

- name: Build the package
run: |
dotnet build ArmoniK.Extensions.Csharp.sln -c Release -p:Version=$GENVERSION
dotnet build ArmoniK.Extensions.Csharp.sln -c Release -p:Version=$GENVERSION -p:RunAnalyzers=false -p:WarningLevel=0

- name: Pack the package VERSION
run: |
Expand Down Expand Up @@ -266,7 +266,7 @@ jobs:
if [ "${{ matrix.mtls }}" = "true" ]; then
export Grpc__ClientP12="${{ steps.deploy.outputs.generated-folder }}/certificates/ingress/client.submitter.p12"
fi
dotnet test --runtime linux-x64 -f net6.0 --logger "trx;LogFileName=test-results.trx"
dotnet test --runtime linux-x64 -f net6.0 --logger "trx;LogFileName=test-results.trx" -p:RunAnalyzers=false -p:WarningLevel=0

- name: Test Report
uses: dorny/test-reporter@v1
Expand Down
24 changes: 20 additions & 4 deletions ArmoniK.Extensions.Csharp.sln
Original file line number Diff line number Diff line change
Expand Up @@ -57,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 @@ -111,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 @@ -134,10 +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}
{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
7 changes: 7 additions & 0 deletions Client/src/Common/ArmoniK.DevelopmentKit.Client.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,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 @@ -20,4 +22,9 @@
<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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
public enum ArmonikTaskStatusCode
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,
Available,
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.Available,
ResultStatus.Aborted => ArmoniKResultStatus.Error,
ResultStatus.Notfound => ArmoniKResultStatus.Error,
_ => throw new ArgumentOutOfRangeException(nameof(resultStatus),
resultStatus,
null),
};
}
Loading