Skip to content

Commit

Permalink
Apply reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
wkirschenmann committed Aug 23, 2023
1 parent 5d6a805 commit d6edac0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Client/src/Common/Submitter/ApiExt/ArmoniKResultStatus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ namespace ArmoniK.DevelopmentKit.Client.Common.Submitter.ApiExt;
public enum ArmoniKResultStatus
{
Unknown,
Ready,
Available,
NotReady,
Error,
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public static ArmoniKResultStatus ToArmoniKResultStatus(this ResultStatus result
{
ResultStatus.Unspecified => ArmoniKResultStatus.Unknown,
ResultStatus.Created => ArmoniKResultStatus.NotReady,
ResultStatus.Completed => ArmoniKResultStatus.Ready,
ResultStatus.Completed => ArmoniKResultStatus.Available,
ResultStatus.Aborted => ArmoniKResultStatus.Error,
ResultStatus.Notfound => ArmoniKResultStatus.Error,
_ => throw new ArgumentOutOfRangeException(nameof(resultStatus),
Expand Down
35 changes: 34 additions & 1 deletion Client/src/Common/Submitter/ApiExt/IArmoniKClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ namespace ArmoniK.DevelopmentKit.Client.Common.Submitter.ApiExt;
// TODO: Should be split in different services interfaces
public interface IArmoniKClient
{

/// <summary>
/// Creates a new ArmoniK session.
/// </summary>
/// <param name="taskOptions">Default task options for the session</param>
/// <param name="partitions">List of all partition that will be used during the session</param>
/// <param name="maxRetries">Number of times the call must be retried. Default=1</param>
Expand All @@ -46,6 +50,10 @@ public Task<string> CreateSessionAsync(TaskOptions taskOptions,
double totalTimeoutMs = 1e10,
CancellationToken cancellationToken = default);


/// <summary>
/// Submits new tasks to ArmoniK
/// </summary>
/// <param name="sessionId">Id of the session</param>
/// <param name="definitions">Definition of the tasks</param>
/// <param name="taskOptions">Task options for these tasks</param>
Expand All @@ -59,6 +67,10 @@ public Task<IEnumerable<TaskInfo>> SubmitTasksAsync(string
double totalTimeoutMs = 1e10,
CancellationToken cancellationToken = default);


/// <summary>
/// Gets the resultIds from the tasks
/// </summary>
/// <param name="taskIds">Id of the tasks</param>
/// <param name="maxRetries">Number of times the call must be retried. Default=1</param>
/// <param name="totalTimeoutMs">Define a timeout for the global call (including all retries)</param>
Expand All @@ -67,7 +79,9 @@ public Task<IEnumerable<TaskOutputIds>> GetResultIdsAsync(IReadOnlyCollection<st
int maxRetries = 1,
double totalTimeoutMs = 1e10,
CancellationToken cancellationToken = default);

/// <summary>
/// Downloads a result
/// </summary>
/// <param name="sessionId">Id of the session</param>
/// <param name="resultId">Id of the result</param>
/// <param name="maxRetries">Number of times the call must be retried. Default=1</param>
Expand All @@ -79,6 +93,9 @@ public Task<byte[]> DownloadResultAsync(string sessionId,
double totalTimeoutMs = 1e10,
CancellationToken cancellationToken = default);

/// <summary>
/// Gets the status of a task
/// </summary>
/// <param name="taskIds">Id of the tasks</param>
/// <param name="maxRetries">Number of times the call must be retried. Default=1</param>
/// <param name="totalTimeoutMs">Define a timeout for the global call (including all retries)</param>
Expand All @@ -88,6 +105,9 @@ public Task<IEnumerable<TaskIdStatus>> GetTaskStatusAsync(IReadOnlyCollection<st
double totalTimeoutMs = 1e10,
CancellationToken cancellationToken = default);

/// <summary>
/// Gets the status of a result
/// </summary>
/// <param name="sessionId">Id of the session</param>
/// <param name="resultIds"></param>
/// <param name="maxRetries">Number of times the call must be retried. Default=1</param>
Expand All @@ -99,17 +119,24 @@ public Task<IEnumerable<ResultIdStatus>> GetResultStatusAsync(string
double totalTimeoutMs = 1e10,
CancellationToken cancellationToken = default);

/// <summary>
/// Tries to get the error result of a task
/// </summary>
/// <param name="sessionId">Id of the session</param>
/// <param name="taskId">Id of the task</param>
/// <param name="maxRetries">Number of times the call must be retried. Default=1</param>
/// <param name="totalTimeoutMs">Define a timeout for the global call (including all retries)</param>
/// <param name="cancellationToken"></param>
/// <returns><c>null</c> if no error is available, the error message otherwise</returns>
public Task<string?> TryGetTaskErrorAsync(string sessionId,
string taskId,
int maxRetries = 1,
double totalTimeoutMs = 1e10,
CancellationToken cancellationToken = default);

/// <summary>
/// Waits for tasks to be completed
/// </summary>
/// <param name="sessionId">Id of the session</param>
/// <param name="taskIds">Id of the tasks</param>
/// <param name="stopOnFirstTaskCancellation"></param>
Expand All @@ -125,6 +152,9 @@ public Task<ImmutableDictionary<TaskStatus, int>> WaitForCompletionAsync(string
double totalTimeoutMs = 1e10,
CancellationToken cancellationToken = default);

/// <summary>
/// Waits for some results to be available
/// </summary>
/// <param name="sessionId">Id of the session</param>
/// <param name="resultId"></param>
/// <param name="maxRetries">Number of times the call must be retried. Default=1</param>
Expand All @@ -137,6 +167,9 @@ public Task WaitForAvailability(string sessionId,
CancellationToken cancellationToken = default);


/// <summary>
/// Create the metadata corresponding to tasks
/// </summary>
/// <param name="sessionId">Id of the session</param>
/// <param name="resultNames"></param>
/// <param name="maxRetries">Number of times the call must be retried. Default=1</param>
Expand Down
4 changes: 2 additions & 2 deletions Client/src/Common/Submitter/BaseClientSubmitter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ public ResultStatusCollection GetResultStatus(IEnumerable<string> taskIds,
});


return new ResultStatusCollection(idStatuses[ArmoniKResultStatus.Ready]
return new ResultStatusCollection(idStatuses[ArmoniKResultStatus.Available]
.ToImmutableList(),
idStatuses[ArmoniKResultStatus.Error]
.ToImmutableList(),
Expand Down Expand Up @@ -484,7 +484,7 @@ public IEnumerable<Tuple<string, byte[]>> GetResults(IEnumerable<string> taskIds
/// <returns>Returns the result or byte[0] if there no result or null if task is not yet ready</returns>
// TODO: return a compound type to avoid having a nullable that holds the information and return an empty array.
[PublicAPI]
[Obsolete($"Use version without the {nameof(checkOutput)} parameter.")]
[Obsolete($"Use version without the checkOutput parameter.")]
public byte[]? TryGetResult(string taskId,
bool checkOutput,
CancellationToken cancellationToken = default)
Expand Down
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
<!--Code analysis-->
<EnableNETAnalyzers>true</EnableNETAnalyzers>
<Nullable>enable</Nullable>
<LangVersion>10</LangVersion>
<LangVersion>11</LangVersion>
<!-- Ready for the future
<AnalysisLevel>latest</AnalysisLevel>
<AnalysisMode>AllEnabledByDefault</AnalysisMode>
Expand Down

0 comments on commit d6edac0

Please sign in to comment.