Skip to content

Commit

Permalink
feat: add CreatedBy to Task (#737)
Browse files Browse the repository at this point in the history
  • Loading branch information
aneojgurhem authored Aug 30, 2024
2 parents 117385f + c523838 commit 92b8933
Show file tree
Hide file tree
Showing 49 changed files with 557 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ public ResultDataModelMapping()
.SetIsRequired(true);
cm.MapProperty(nameof(Result.Name))
.SetIsRequired(true);
cm.MapProperty(nameof(Result.CreatedBy))
.SetIsRequired(true);
cm.MapProperty(nameof(Result.OwnerTaskId))
.SetIsRequired(true);
cm.MapProperty(nameof(Result.Status))
Expand All @@ -57,6 +59,7 @@ public ResultDataModelMapping()
cm.MapCreator(model => new Result(model.SessionId,
model.ResultId,
model.Name,
model.CreatedBy,
model.OwnerTaskId,
model.Status,
model.DependentTasks,
Expand Down
3 changes: 3 additions & 0 deletions Adaptors/MongoDB/src/Table/DataModel/TaskDataModelMapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ static TaskDataModelMapping()
.SetIsRequired(true);
cm.MapProperty(nameof(TaskData.InitialTaskId))
.SetIsRequired(true);
cm.MapProperty(nameof(TaskData.CreatedBy))
.SetIsRequired(true);
cm.MapProperty(nameof(TaskData.RetryOfIds))
.SetIsRequired(true);
cm.MapProperty(nameof(TaskData.Status))
Expand Down Expand Up @@ -103,6 +105,7 @@ static TaskDataModelMapping()
model.RemainingDataDependencies,
model.ExpectedOutputIds,
model.InitialTaskId,
model.CreatedBy,
model.RetryOfIds,
model.Status,
model.StatusMessage,
Expand Down
2 changes: 2 additions & 0 deletions Adaptors/MongoDB/tests/BsonSerializerTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ public void SerializeResultDataModel()
var rdm = new Result("sessionId",
"ResultId",
"Name",
"CreatedBy",
"OwnerTaskId",
ResultStatus.Completed,
new List<string>
Expand Down Expand Up @@ -148,6 +149,7 @@ public void SerializeTaskDataModel()
"output1",
},
"taskId",
"createdBy",
new List<string>
{
"retry1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ public void ShouldRecognizeSession()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -92,6 +93,7 @@ public void ShouldRejectOtherSession()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -129,6 +131,7 @@ public void ShouldExcludeSession()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -166,6 +169,7 @@ public void ShouldIncludeOtherSession()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -203,6 +207,7 @@ public void ShouldRecognizeStatus()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -240,6 +245,7 @@ public void ShouldExcludeStatus()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -277,6 +283,7 @@ public void ShouldRecognizeMultipleStatus()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -315,6 +322,7 @@ public void ShouldExcludeMultipleStatus()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -351,6 +359,7 @@ public void ShouldRejectOtherStatus()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -388,6 +397,7 @@ public void ShouldIncludeOtherStatus()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -425,6 +435,7 @@ public void ShouldRejectOtherMultipleStatus()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -463,6 +474,7 @@ public void ShouldIncludeOtherMultipleStatus()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -499,6 +511,7 @@ public void ShouldRecognizeTask()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -536,6 +549,7 @@ public void ShouldExcludeTask()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -573,6 +587,7 @@ public void ShouldRecognizeMultipleTask()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -611,6 +626,7 @@ public void ShouldExcludeMultipleTask()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -647,6 +663,7 @@ public void ShouldRejectOtherTask()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -684,6 +701,7 @@ public void ShouldIncludeOtherTask()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -721,6 +739,7 @@ public void ShouldRejectOtherMultipleTask()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down Expand Up @@ -759,6 +778,7 @@ public void ShouldIncludeOtherMultipleTask()
"OwnerPodId",
"OwnerPodName",
"PayloadId",
"CreatedBy",
new[]
{
"parent1",
Expand Down
2 changes: 1 addition & 1 deletion Common/src/ArmoniK.Core.Common.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@


<ItemGroup>
<PackageReference Include="ArmoniK.Api.Core" Version="3.19.0" />
<PackageReference Include="ArmoniK.Api.Core" Version="3.20.0-edge.18.3daa69e" />
<PackageReference Include="ArmoniK.Utils.Diagnostics" Version="0.5.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
2 changes: 2 additions & 0 deletions Common/src/Pollster/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -291,6 +291,7 @@ public async Task<ICollection<Result>> CreateResults(string
return new Result(rc.request.SessionId,
resultId,
rc.request.Name,
taskData_.TaskId,
"",
ResultStatus.Created,
new List<string>(),
Expand Down Expand Up @@ -372,6 +373,7 @@ public async Task<ICollection<Result>> CreateResultsMetaData(string
Guid.NewGuid()
.ToString(),
rc.Name,
taskData_.TaskId,
"",
ResultStatus.Created,
new List<string>(),
Expand Down
2 changes: 2 additions & 0 deletions Common/src/Storage/Result.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ namespace ArmoniK.Core.Common.Storage;
/// <param name="SessionId">Id of the session that produces and consumes this data</param>
/// <param name="ResultId">Unique Id of the result</param>
/// <param name="Name">Name to reference and access this result</param>
/// <param name="CreatedBy">Id of the task that created this result.</param>
/// <param name="OwnerTaskId">Id of the task that is responsible of generating this result.</param>
/// <param name="Status">Status of the result (can be Created, Completed or Aborted)</param>
/// <param name="DependentTasks">List of tasks that depend on this result.</param>
Expand All @@ -34,6 +35,7 @@ namespace ArmoniK.Core.Common.Storage;
public record Result(string SessionId,
string ResultId,
string Name,
string CreatedBy,
string OwnerTaskId,
ResultStatus Status,
List<string> DependentTasks,
Expand Down
5 changes: 5 additions & 0 deletions Common/src/Storage/TaskData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ namespace ArmoniK.Core.Common.Storage;
/// responsibility to produce
/// </param>
/// <param name="InitialTaskId">Task id before retry</param>
/// <param name="CreatedBy">Id of the task that created this task.</param>
/// <param name="RetryOfIds">List of previous tasks ids before the current retry</param>
/// <param name="Status">Current status of the task</param>
/// <param name="StatusMessage">Message associated to the status</param>
Expand Down Expand Up @@ -74,6 +75,7 @@ public record TaskData(string SessionId,
IDictionary<string, bool> RemainingDataDependencies,
IList<string> ExpectedOutputIds,
string InitialTaskId,
string CreatedBy,
IList<string> RetryOfIds,
TaskStatus Status,
string StatusMessage,
Expand All @@ -100,6 +102,7 @@ public record TaskData(string SessionId,
/// <param name="ownerPodId">Identifier of the polling agent running the task</param>
/// <param name="ownerPodName">Hostname of the polling agent running the task</param>
/// <param name="payloadId">Unique identifier of the payload in input of the task</param>
/// <param name="createdBy">Id of the task that created this task.</param>
/// <param name="parentTaskIds">
/// Unique identifiers of the tasks that submitted the current task up to the session id which
/// represents a submission from the client
Expand All @@ -118,6 +121,7 @@ public TaskData(string sessionId,
string ownerPodId,
string ownerPodName,
string payloadId,
string createdBy,
IList<string> parentTaskIds,
IList<string> dataDependencies,
IList<string> expectedOutputIds,
Expand All @@ -140,6 +144,7 @@ public TaskData(string sessionId,
_ => true),
expectedOutputIds,
taskId,
createdBy,
retryOfIds,
status,
"",
Expand Down
3 changes: 3 additions & 0 deletions Common/src/Storage/TaskDataFields.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public enum TaskDataFields
/// <inheritdoc cref="TaskDataHolder.InitialTaskId" />
InitialTaskId,

/// <inheritdoc cref="TaskDataHolder.CreatedBy" />
CreatedBy,

/// <inheritdoc cref="TaskDataHolder.RetryOfIds" />
RetryOfIds,

Expand Down
3 changes: 3 additions & 0 deletions Common/src/Storage/TaskDataHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ public record TaskDataHolder
/// <inheritdoc cref="TaskData.InitialTaskId" />
public string InitialTaskId { get; set; } = string.Empty;

/// <inheritdoc cref="TaskData.CreatedBy" />
public string CreatedBy { get; set; } = string.Empty;

/// <inheritdoc cref="TaskData.StatusMessage" />
public string StatusMessage { get; set; } = string.Empty;

Expand Down
4 changes: 4 additions & 0 deletions Common/src/Storage/TaskDataMask.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ public TaskDataMask(ICollection<TaskDataFields> taskDataFields,
return data => data.ExpectedOutputIds.Count;
case TaskDataFields.InitialTaskId:
return data => data.InitialTaskId;
case TaskDataFields.CreatedBy:
return data => data.CreatedBy;
case TaskDataFields.RetryOfIds:
return data => data.RetryOfIds;
case TaskDataFields.RetryOfIdsCount:
Expand Down Expand Up @@ -213,6 +215,8 @@ public TaskDataMask(ICollection<TaskDataFields> taskDataFields,
return data => data.ReceivedToEndDuration;
case TaskDataFields.FetchedDate:
return data => data.FetchedDate;
case TaskDataFields.CreatedBy:
return data => data.CreatedBy;
default:
throw new ArgumentOutOfRangeException(nameof(field),
field,
Expand Down
3 changes: 3 additions & 0 deletions Common/src/Storage/TaskLifeCycleHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,11 @@ public static async Task CreateTasks(ITaskTable taskTable,
CancellationToken cancellationToken)
{
var parentTaskIds = new List<string>();
var createdBy = string.Empty;

if (!parentTaskId.Equals(sessionId))
{
createdBy = parentTaskId;
var res = await taskTable.GetParentTaskIds(parentTaskId,
cancellationToken)
.ConfigureAwait(false);
Expand All @@ -139,6 +141,7 @@ public static async Task CreateTasks(ITaskTable taskTable,
"",
"",
request.PayloadId,
createdBy,
parentTaskIds,
request.DataDependencies.ToList(),
request.ExpectedOutputKeys.ToList(),
Expand Down
1 change: 1 addition & 0 deletions Common/src/Storage/TaskTableExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -496,6 +496,7 @@ public static async Task<string> RetryTask(this ITaskTable taskTable,
taskData.RemainingDataDependencies,
taskData.ExpectedOutputIds,
taskData.InitialTaskId,
taskData.TaskId,
newTaskRetryOfIds,
TaskStatus.Creating,
"",
Expand Down
1 change: 1 addition & 0 deletions Common/src/gRPC/Convertors/ResultExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public static ResultRaw ToGrpcResultRaw(this Result result)
Status = result.Status.ToGrpcStatus(),
CreatedAt = Timestamp.FromDateTime(result.CreationDate),
Name = result.Name,
CreatedBy = result.CreatedBy,
OwnerTaskId = result.OwnerTaskId,
ResultId = result.ResultId,
Size = result.Size,
Expand Down
2 changes: 2 additions & 0 deletions Common/src/gRPC/Convertors/TaskDataHolderExt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ public static TaskDetailed ToTaskDetailed(this TaskDataHolder taskData)
FetchedAt = taskData.FetchedDate is not null
? FromDateTime(taskData.FetchedDate.Value)
: null,
CreatedBy = taskData.CreatedBy,
};


Expand Down Expand Up @@ -169,5 +170,6 @@ public static TaskSummary ToTaskSummary(this TaskDataHolder taskDataSummary)
FetchedAt = taskDataSummary.FetchedDate is not null
? FromDateTime(taskDataSummary.FetchedDate.Value)
: null,
CreatedBy = taskDataSummary.CreatedBy,
};
}
Loading

0 comments on commit 92b8933

Please sign in to comment.