Class: Ace::Overseer::Molecules::AssignmentLauncher

Inherits:
Object
  • Object
show all
Defined in:
lib/ace/overseer/molecules/assignment_launcher.rb

Instance Method Summary collapse

Constructor Details

#initialize(assignment_executor: nil, task_manager: nil) ⇒ AssignmentLauncher

Returns a new instance of AssignmentLauncher.



9
10
11
12
# File 'lib/ace/overseer/molecules/assignment_launcher.rb', line 9

def initialize(assignment_executor: nil, task_manager: nil)
  @assignment_executor = assignment_executor
  @task_manager = task_manager
end

Instance Method Details

#launch(worktree_path:, preset_name:, task_ref:, subtask_refs: nil, task_refs: nil) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/ace/overseer/molecules/assignment_launcher.rb', line 14

def launch(worktree_path:, preset_name:, task_ref:, subtask_refs: nil, task_refs: nil)
  with_worktree_context(worktree_path) do
    requested_refs = effective_task_refs(task_ref, subtask_refs, task_refs)
    requested_refs = [task_ref] unless preset_supports_taskrefs?(preset_name: preset_name)

    creator = Ace::Assign::Organisms::TaskAssignmentCreator.new(
      task_manager: @task_manager,
      executor: @assignment_executor
    )
    result = creator.call(
      task_refs: requested_refs,
      preset_name: preset_name,
      primary_task_ref: task_ref
    )
    current = result[:current]

    {
      assignment_id: result[:assignment].id,
      first_step: current ? "#{current.number}-#{current.name}" : nil,
      job_path: result[:job_path]
    }
  end
rescue Ace::Support::Cli::Error => e
  raise Error, e.message
end

#preset_supports_taskrefs?(preset_name:, worktree_path: nil) ⇒ Boolean

Returns:

  • (Boolean)


40
41
42
43
44
45
46
47
48
49
50
# File 'lib/ace/overseer/molecules/assignment_launcher.rb', line 40

def preset_supports_taskrefs?(preset_name:, worktree_path: nil)
  if worktree_path
    with_worktree_context(worktree_path) do
      parameter_names(Ace::Assign::Atoms::PresetLoader.load(preset_name)).include?("taskrefs")
    end
  else
    parameter_names(Ace::Assign::Atoms::PresetLoader.load(preset_name)).include?("taskrefs")
  end
rescue Ace::Support::Cli::Error => e
  raise Error, e.message
end