Skip to content

Commit

Permalink
chore: remove wait_untill delay from queuing jobs except for status j…
Browse files Browse the repository at this point in the history
…ob (#886)
  • Loading branch information
ericenns authored Jan 8, 2025
1 parent a8d5c1f commit 83a05ec
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion app/jobs/workflow_execution_cancelation_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class WorkflowExecutionCancelationJob < ApplicationJob
workflow_execution.http_error_code = exception.http_error_code
workflow_execution.save

WorkflowExecutionCleanupJob.set(wait_until: 30.seconds.from_now).perform_later(workflow_execution)
WorkflowExecutionCleanupJob.perform_later(workflow_execution)

workflow_execution
end
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/workflow_execution_preparation_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def perform(workflow_execution)
result = WorkflowExecutions::PreparationService.new(workflow_execution).execute

if result
WorkflowExecutionSubmissionJob.set(wait_until: 30.seconds.from_now).perform_later(workflow_execution)
WorkflowExecutionSubmissionJob.perform_later(workflow_execution)
else
@workflow_execution.state = :error
@workflow_execution.cleaned = true
Expand Down
8 changes: 4 additions & 4 deletions app/jobs/workflow_execution_status_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ class WorkflowExecutionStatusJob < ApplicationJob
workflow_execution.http_error_code = exception.http_error_code
workflow_execution.save

WorkflowExecutionCleanupJob.set(wait_until: 30.seconds.from_now).perform_later(workflow_execution)
WorkflowExecutionCleanupJob.perform_later(workflow_execution)

workflow_execution
end

def perform(workflow_execution) # rubocop:disable Metrics/AbcSize
def perform(workflow_execution)
# User signaled to cancel
return if workflow_execution.canceling? || workflow_execution.canceled?

Expand All @@ -28,9 +28,9 @@ def perform(workflow_execution) # rubocop:disable Metrics/AbcSize

case workflow_execution.state.to_sym
when :canceled, :error
WorkflowExecutionCleanupJob.set(wait_until: 30.seconds.from_now).perform_later(workflow_execution)
WorkflowExecutionCleanupJob.perform_later(workflow_execution)
when :completing
WorkflowExecutionCompletionJob.set(wait_until: 30.seconds.from_now).perform_later(workflow_execution)
WorkflowExecutionCompletionJob.perform_later(workflow_execution)
else
WorkflowExecutionStatusJob.set(wait_until: 30.seconds.from_now).perform_later(workflow_execution)
end
Expand Down
2 changes: 1 addition & 1 deletion app/jobs/workflow_execution_submission_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class WorkflowExecutionSubmissionJob < ApplicationJob
workflow_execution.http_error_code = exception.http_error_code
workflow_execution.save

WorkflowExecutionCleanupJob.set(wait_until: 30.seconds.from_now).perform_later(workflow_execution)
WorkflowExecutionCleanupJob.perform_later(workflow_execution)

workflow_execution
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/data_exports/create_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def execute
if @data_export.valid?
@data_export.export_type == 'analysis' ? validate_analysis_ids : validate_sample_ids
@data_export.save
DataExports::CreateJob.set(wait_until: 30.seconds.from_now).perform_later(@data_export)
DataExports::CreateJob.perform_later(@data_export)
end

@data_export
Expand Down
8 changes: 3 additions & 5 deletions app/services/workflow_executions/cancel_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def initialize(workflow_execution, user = nil)
@workflow_execution = workflow_execution
end

def execute # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
def execute # rubocop:disable Metrics/MethodLength
return false unless @workflow_execution.cancellable?

authorize! @workflow_execution, to: :cancel?
Expand All @@ -17,9 +17,7 @@ def execute # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
# Schedule a job to cancel the run on the ga4gh wes server
@workflow_execution.state = :canceling
@workflow_execution.save
WorkflowExecutionCancelationJob.set(
wait_until: 30.seconds.from_now
).perform_later(@workflow_execution, current_user)
WorkflowExecutionCancelationJob.perform_later(@workflow_execution, current_user)
elsif @workflow_execution.initial?
# No files to clean up, mark as cleaned and do not create a cleanup job.
@workflow_execution.state = :canceled
Expand All @@ -29,7 +27,7 @@ def execute # rubocop:disable Metrics/MethodLength,Metrics/AbcSize
# Files were generated but not sent to ga4gh, schedule a cleanup job
@workflow_execution.state = :canceled
@workflow_execution.save
WorkflowExecutionCleanupJob.set(wait_until: 30.seconds.from_now).perform_later(@workflow_execution)
WorkflowExecutionCleanupJob.perform_later(@workflow_execution)
end

@workflow_execution
Expand Down
2 changes: 1 addition & 1 deletion app/services/workflow_executions/cancelation_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def execute

@workflow_execution.save

WorkflowExecutionCleanupJob.set(wait_until: 30.seconds.from_now).perform_later(@workflow_execution)
WorkflowExecutionCleanupJob.perform_later(@workflow_execution)

@workflow_execution
end
Expand Down
2 changes: 1 addition & 1 deletion app/services/workflow_executions/completion_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def execute # rubocop:disable Metrics/MethodLength

@workflow_execution.save

WorkflowExecutionCleanupJob.set(wait_until: 30.seconds.from_now).perform_later(@workflow_execution)
WorkflowExecutionCleanupJob.perform_later(@workflow_execution)

@workflow_execution
end
Expand Down
4 changes: 2 additions & 2 deletions app/services/workflow_executions/create_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def initialize(user = nil, params = {})
super
end

def execute # rubocop:disable Metrics/AbcSize
def execute
return false if params.empty?

@workflow_execution = WorkflowExecution.new(params)
Expand All @@ -24,7 +24,7 @@ def execute # rubocop:disable Metrics/AbcSize

if @workflow_execution.save
create_activities
WorkflowExecutionPreparationJob.set(wait_until: 30.seconds.from_now).perform_later(@workflow_execution)
WorkflowExecutionPreparationJob.perform_later(@workflow_execution)
end

@workflow_execution
Expand Down

0 comments on commit 83a05ec

Please sign in to comment.