Class: Broadlistening::Planner

Inherits:
Object
  • Object
show all
Defined in:
lib/broadlistening/planner.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config:, status:, output_dir:, spec_loader: nil) ⇒ Planner

Returns a new instance of Planner.



10
11
12
13
14
15
16
# File 'lib/broadlistening/planner.rb', line 10

def initialize(config:, status:, output_dir:, spec_loader: nil)
  @config = config
  @status = status
  @output_dir = Pathname.new(output_dir)
  @spec_loader = spec_loader || SpecLoader.default
  @previous_jobs = status.previous_completed_jobs
end

Instance Attribute Details

#configObject (readonly)

Returns the value of attribute config.



8
9
10
# File 'lib/broadlistening/planner.rb', line 8

def config
  @config
end

#output_dirObject (readonly)

Returns the value of attribute output_dir.



8
9
10
# File 'lib/broadlistening/planner.rb', line 8

def output_dir
  @output_dir
end

#spec_loaderObject (readonly)

Returns the value of attribute spec_loader.



8
9
10
# File 'lib/broadlistening/planner.rb', line 8

def spec_loader
  @spec_loader
end

#statusObject (readonly)

Returns the value of attribute status.



8
9
10
# File 'lib/broadlistening/planner.rb', line 8

def status
  @status
end

Instance Method Details

#create_plan(force: false, only: nil) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/broadlistening/planner.rb', line 18

def create_plan(force: false, only: nil)
  plan = []

  spec_loader.specs.each do |spec|
    step_name = spec[:step]
    run, reason = decide_step(spec, plan, force: force, only: only)
    plan << { step: step_name, run: run, reason: reason }
  end

  plan
end

#extract_current_params(step_name) ⇒ Object



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/broadlistening/planner.rb', line 30

def extract_current_params(step_name)
  case step_name.to_sym
  when :extraction
    { model: config.model, prompt: config.prompts[:extraction] }
  when :embedding
    { model: config.embedding_model }
  when :clustering
    { cluster_nums: config.cluster_nums }
  when :initial_labelling
    { model: config.model, prompt: config.prompts[:initial_labelling] }
  when :merge_labelling
    { model: config.model, prompt: config.prompts[:merge_labelling] }
  when :overview
    { model: config.model, prompt: config.prompts[:overview] }
  when :aggregation
    {}
  else
    {}
  end
end