Skip to content

Commit 5550121

Browse files
committed
Add argo workflow link on sara workflows
1 parent 7ef6944 commit 5550121

16 files changed

Lines changed: 751 additions & 19 deletions

api/Controllers/Models/WorkflowDto.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,11 @@ public WorkflowDto() { }
3232
public WorkflowDto(Workflow workflow, IBlobStorageService blobService)
3333
{
3434
this.Id = workflow.Id;
35+
this.AnalysisRunId = workflow.AnalysisRunId;
3536
this.StepNumber = workflow.StepNumber;
3637
this.WorkflowType = workflow.WorkflowType;
3738
this.Status = workflow.Status;
39+
this.ArgoWorkflowName = workflow.ArgoWorkflowName;
3840
this.OutputBlobSAS =
3941
workflow.OutputBlobStorageLocation != null
4042
? blobService.CreateReadSasUri(workflow.OutputBlobStorageLocation).Result
@@ -144,9 +146,11 @@ string workflowType
144146
}
145147

146148
public Guid Id { get; set; }
149+
public Guid AnalysisRunId { get; set; }
147150
public int StepNumber { get; set; }
148151
public string WorkflowType { get; set; }
149152
public WorkflowStatus Status { get; set; }
153+
public string? ArgoWorkflowName { get; set; }
150154
public Uri? OutputBlobSAS { get; set; }
151155
public AnalysisResultDto? Result { get; set; }
152156
public string? ResultJson { get; set; }

api/Controllers/WorkflowNotificationController.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ IWorkflowService workflowService
2929
[Route("{workflowId:guid}/started")]
3030
[ProducesResponseType(StatusCodes.Status204NoContent)]
3131
[ProducesResponseType(StatusCodes.Status404NotFound)]
32-
public async Task<IActionResult> WorkflowStarted([FromRoute] Guid workflowId)
32+
public async Task<IActionResult> WorkflowStarted(
33+
[FromRoute] Guid workflowId,
34+
[FromBody] WorkflowStartedNotification? notification = null
35+
)
3336
{
3437
var workflow = await context.Workflows.FirstOrDefaultAsync(w => w.Id == workflowId);
3538
if (workflow is null)
@@ -38,13 +41,18 @@ public async Task<IActionResult> WorkflowStarted([FromRoute] Guid workflowId)
3841
}
3942

4043
logger.LogInformation(
41-
"Workflow {WorkflowType} (Id: {WorkflowId}) reported started",
44+
"Workflow {WorkflowType} (Id: {WorkflowId}) reported started (ArgoWorkflowName: {ArgoWorkflowName})",
4245
workflow.WorkflowType,
43-
workflow.Id
46+
workflow.Id,
47+
notification?.ArgoWorkflowName
4448
);
4549

4650
workflow.Status = WorkflowStatus.InProgress;
4751
workflow.StartedAt = DateTime.UtcNow;
52+
if (!string.IsNullOrWhiteSpace(notification?.ArgoWorkflowName))
53+
{
54+
workflow.ArgoWorkflowName = notification.ArgoWorkflowName;
55+
}
4856
await context.SaveChangesAsync();
4957

5058
return NoContent();
@@ -134,6 +142,11 @@ [FromBody] WorkflowExitedNotification notification
134142
}
135143
}
136144

145+
public class WorkflowStartedNotification
146+
{
147+
public string? ArgoWorkflowName { get; set; }
148+
}
149+
137150
public class WorkflowResultNotification
138151
{
139152
public string? ResultJson { get; set; }

api/Database/Models/Workflow.cs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ public class Workflow
6060

6161
public WorkflowStatus Status { get; set; } = WorkflowStatus.Pending;
6262

63+
/// <summary>
64+
/// Name of the underlying Argo Workflow resource, reported by the workflow
65+
/// notifier when the workflow starts. Combined with the SARA-configured Argo
66+
/// Workflows base URL and namespace to build a deep link to the Argo UI.
67+
/// </summary>
68+
public string? ArgoWorkflowName { get; set; }
69+
6370
public BlobStorageLocation? OutputBlobStorageLocation { get; set; }
6471

6572
public string? ResultJson { get; set; }

0 commit comments

Comments
 (0)