This is an automated email from the ASF dual-hosted git repository.
DImuthuUpe pushed a commit to branch workflow-pause-on-auth
in repository https://gitbox.apache.org/repos/asf/airavata.git
The following commit(s) were added to refs/heads/workflow-pause-on-auth by this
push:
new ffd18d66fb Refactoring launch process section
ffd18d66fb is described below
commit ffd18d66fbbab66df1351198f35407d07797088b
Author: DImuthuUpe <[email protected]>
AuthorDate: Fri Nov 6 19:47:11 2026 -0500
Refactoring launch process section
---
api/process/service/launch.go | 195 +++++++++++++++-----------
internal/orchestration/workflows/workflows.go | 2 +-
2 files changed, 117 insertions(+), 80 deletions(-)
diff --git a/api/process/service/launch.go b/api/process/service/launch.go
index 8d3dfaf065..32ee607a82 100644
--- a/api/process/service/launch.go
+++ b/api/process/service/launch.go
@@ -38,9 +38,11 @@ import (
appdto "github.com/apache/airavata/api/application/dto"
appmod "github.com/apache/airavata/api/application/model"
appserv "github.com/apache/airavata/api/application/service"
+ computedto "github.com/apache/airavata/api/compute/dto"
computesev "github.com/apache/airavata/api/compute/service"
credentialsev "github.com/apache/airavata/api/credentials/service"
datasev "github.com/apache/airavata/api/data/service"
+ processdto "github.com/apache/airavata/api/process/dto"
datamodel "github.com/apache/airavata/api/data/model"
"github.com/apache/airavata/api/process/dto"
@@ -250,66 +252,72 @@ func (s *LaunchService) launchBatchProcess(ctx
context.Context, process *dto.Res
// same directory the submission task is carried out in.
workingDir := strings.TrimSpace(*workRoot) + "/" + process.ProcessID
- inputMapping := batchProcess.InputMappings
- outputMapping := batchProcess.OutputMappings
- hpcStorageType := datamodel.DataStorageTypeHPC
- for _, input := range inputMapping {
- // Process each input mapping here
- tempInput := findTemplateInput(template, input.TemplateInputID)
-
- if tempInput == nil {
- return fmt.Errorf("Input mapping %s has no template
input", input.TemplateInputMappingID)
- }
+ if err := s.createInputStagingTasks(ctx, process.ProcessID, workingDir,
batchProcess, template, clusterConfig); err != nil {
+ return err
+ }
- if tempInput.InputType == nil {
- return fmt.Errorf("Input mapping %s has no input type",
input.TemplateInputMappingID)
- }
+ if err := s.createOutputStagingTasks(ctx, process.ProcessID,
workingDir, batchProcess, template, clusterConfig); err != nil {
+ return err
+ }
- if *tempInput.InputType == appmod.TemplateInputTypeFile {
- // Create a data staging task for the file input
- dataProductId := input.Value
- if dataProductId == nil || *dataProductId == "" {
- return fmt.Errorf("Input mapping %s has no
value", input.TemplateInputMappingID)
- }
+ if err := s.createJobSubmissionTask(ctx, process.ProcessID,
workingDir); err != nil {
+ return err
+ }
- dataProduct, err := s.dataProductService.Get(ctx,
*dataProductId)
- if err != nil {
- return fmt.Errorf("Failed to find data product
%s: %v", *dataProductId, err)
- }
+ if err := s.createJobMonitoringTask(ctx, process.ProcessID); err != nil
{
+ return err
+ }
- destPath := workingDir + "/" + *&tempInput.InputName
+ slog.Info("Created tasks for process. Now launching those",
"processId", process.ProcessID)
+ s.executionEngine.LaunchBatchJobSubmission(ctx, process.ProcessID)
- failureAction := procmodel.OnFailureActionRetry
- retryCount := 3
- taskOrder := 0
+ if _, err := s.statusService.Record(ctx, process.ProcessID,
procmodel.ProcessStatusTypeSubmitted, nil); err != nil {
+ return err
+ }
+ return nil
+}
- dataStagingTask := &procmodel.DataStagingTask{
- ProcessID: &process.ProcessID,
- SourceDataStorageID:
dataProduct.DataStorageID,
- SourcePath: dataProduct.Path,
- SourceDataStorageType:
&dataProduct.DataStorageType,
+func (s *LaunchService) createJobMonitoringTask(ctx context.Context, processId
string) error {
- DestinationDataStorageID:
&clusterConfig.SlurmClusterConfigID,
- DestinationDataStorageType: &hpcStorageType,
- DestinationPath: &destPath,
- OnFailure: &failureAction,
- RetryCount: &retryCount,
- TaskOrder: &taskOrder,
- }
+ jobMonitoringRetryCount := 10
+ jobMonitoringTaskOrder := 3
+ jobMonitoringFailureAction := procmodel.OnFailureActionRetry
+ jobMonitoring := &procmodel.JobMonitoringTask{
+ ProcessID: &processId,
+ OnFailure: &jobMonitoringFailureAction,
+ RetryCount: &jobMonitoringRetryCount,
+ TaskOrder: &jobMonitoringTaskOrder,
+ }
+ if err := s.monitoringTasks.Save(ctx, jobMonitoring); err != nil {
+ return err
+ }
+ return nil
+}
- if err := s.dataStagingTasks.Save(ctx,
dataStagingTask); err != nil {
- return err
- }
- }
+func (s *LaunchService) createJobSubmissionTask(ctx context.Context, processId
string, workingDir string) error {
- if *tempInput.InputType == appmod.TemplateInputTypeFileList {
- // Create a data staging task for the list input
- }
+ jobSubmissionFailureAction := procmodel.OnFailureActionExit
+ jobSubmissionRetryCount := 1
+ jobSubmissionTaskOrder := 1
+ jobSubmission := &procmodel.JobSubmissionTask{
+ ProcessID: &processId,
+ WorkingDir: &workingDir,
+ OnFailure: &jobSubmissionFailureAction,
+ RetryCount: &jobSubmissionRetryCount,
+ TaskOrder: &jobSubmissionTaskOrder,
+ }
- if *tempInput.InputType == appmod.TemplateInputTypeDirectory {
- // Create a data staging task for the directory input
- }
+ if err := s.jobSubmissionTasks.Save(ctx, jobSubmission); err != nil {
+ return err
}
+ return nil
+}
+
+func (s *LaunchService) createOutputStagingTasks(ctx context.Context,
processId string, workingDir string,
+ batchProcess *processdto.BatchProcessResponse, template
*appdto.TemplateResponse, clusterConfig *computedto.SlurmClusterConfigResponse)
error {
+
+ outputMapping := batchProcess.OutputMappings
+ hpcStorageType := datamodel.DataStorageTypeHPC
for _, output := range outputMapping {
// Process each output mapping here
@@ -342,7 +350,7 @@ func (s *LaunchService) launchBatchProcess(ctx
context.Context, process *dto.Res
retryCount := 3
taskOrder := 4
dataStagingTask := &procmodel.DataStagingTask{
- ProcessID: &process.ProcessID,
+ ProcessID: &processId,
SourceDataStorageID:
&clusterConfig.SlurmClusterConfigID,
SourcePath: &sourcePath,
SourceDataStorageType: &hpcStorageType,
@@ -359,40 +367,69 @@ func (s *LaunchService) launchBatchProcess(ctx
context.Context, process *dto.Res
}
}
}
+ return nil
+}
- jobSubmissionFailureAction := procmodel.OnFailureActionExit
- jobSubmissionRetryCount := 1
- jobSubmissionTaskOrder := 1
- jobSubmission := &procmodel.JobSubmissionTask{
- ProcessID: &process.ProcessID,
- WorkingDir: &workingDir,
- OnFailure: &jobSubmissionFailureAction,
- RetryCount: &jobSubmissionRetryCount,
- TaskOrder: &jobSubmissionTaskOrder,
- }
+func (s *LaunchService) createInputStagingTasks(ctx context.Context, processId
string, workingDir string,
+ batchProcess *processdto.BatchProcessResponse, template
*appdto.TemplateResponse, clusterConfig *computedto.SlurmClusterConfigResponse)
error {
+ inputMapping := batchProcess.InputMappings
+ hpcStorageType := datamodel.DataStorageTypeHPC
+ for _, input := range inputMapping {
+ // Process each input mapping here
+ tempInput := findTemplateInput(template, input.TemplateInputID)
- if err := s.jobSubmissionTasks.Save(ctx, jobSubmission); err != nil {
- return err
- }
+ if tempInput == nil {
+ return fmt.Errorf("Input mapping %s has no template
input", input.TemplateInputMappingID)
+ }
- jobMonitoringRetryCount := 10
- jobMonitoringTaskOrder := 3
- jobMonitoringFailureAction := procmodel.OnFailureActionRetry
- jobMonitoring := &procmodel.JobMonitoringTask{
- ProcessID: &process.ProcessID,
- OnFailure: &jobMonitoringFailureAction,
- RetryCount: &jobMonitoringRetryCount,
- TaskOrder: &jobMonitoringTaskOrder,
- }
- if err := s.monitoringTasks.Save(ctx, jobMonitoring); err != nil {
- return err
- }
+ if tempInput.InputType == nil {
+ return fmt.Errorf("Input mapping %s has no input type",
input.TemplateInputMappingID)
+ }
- slog.Info("Created tasks for process. Now launching those",
"processId", process.ProcessID)
- s.executionEngine.LaunchBatchJobSubmission(ctx, process.ProcessID)
+ if *tempInput.InputType == appmod.TemplateInputTypeFile {
+ // Create a data staging task for the file input
+ dataProductId := input.Value
+ if dataProductId == nil || *dataProductId == "" {
+ return fmt.Errorf("Input mapping %s has no
value", input.TemplateInputMappingID)
+ }
- if _, err := s.statusService.Record(ctx, process.ProcessID,
procmodel.ProcessStatusTypeSubmitted, nil); err != nil {
- return err
+ dataProduct, err := s.dataProductService.Get(ctx,
*dataProductId)
+ if err != nil {
+ return fmt.Errorf("Failed to find data product
%s: %v", *dataProductId, err)
+ }
+
+ destPath := workingDir + "/" + *&tempInput.InputName
+
+ failureAction := procmodel.OnFailureActionRetry
+ retryCount := 3
+ taskOrder := 0
+
+ dataStagingTask := &procmodel.DataStagingTask{
+ ProcessID: &processId,
+ SourceDataStorageID:
dataProduct.DataStorageID,
+ SourcePath: dataProduct.Path,
+ SourceDataStorageType:
&dataProduct.DataStorageType,
+
+ DestinationDataStorageID:
&clusterConfig.SlurmClusterConfigID,
+ DestinationDataStorageType: &hpcStorageType,
+ DestinationPath: &destPath,
+ OnFailure: &failureAction,
+ RetryCount: &retryCount,
+ TaskOrder: &taskOrder,
+ }
+
+ if err := s.dataStagingTasks.Save(ctx,
dataStagingTask); err != nil {
+ return err
+ }
+ }
+
+ if *tempInput.InputType == appmod.TemplateInputTypeFileList {
+ // Create a data staging task for the list input
+ }
+
+ if *tempInput.InputType == appmod.TemplateInputTypeDirectory {
+ // Create a data staging task for the directory input
+ }
}
return nil
}
diff --git a/internal/orchestration/workflows/workflows.go
b/internal/orchestration/workflows/workflows.go
index 9b1a5dc5a7..bfc1fb24aa 100644
--- a/internal/orchestration/workflows/workflows.go
+++ b/internal/orchestration/workflows/workflows.go
@@ -171,7 +171,7 @@ func (w *Workflows) HandleBatchJobCompletion(ctx
workflow.Context, processID str
}
// HandleBatchJobSubmission stages a process's inputs onto its cluster and
submits the
-// job.
+// job. This is an async call and will not block the caller.
func (w *Workflows) HandleBatchJobSubmission(ctx workflow.Context, processID
string) error {
ctxInt := context.Background()