Class: LlmConductor::Eval::Store::FileStore

Inherits:
Base
  • Object
show all
Defined in:
lib/llm_conductor/eval/store/file_store.rb

Overview

Resumable on-disk store. Reproduces the Rails prototype’s layout:

<base_dir>/<run_id>/manifest.json
<base_dir>/<run_id>/<input_id>/_input.json
<base_dir>/<run_id>/<input_id>/<model_slug>.raw.txt
<base_dir>/<run_id>/<input_id>/<model_slug>.json

The manifest is rewritten after every (input, model) pair, so a run is reportable / re-judgeable mid-flight (see Runner.report_only/judge_only).

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(base_dir) ⇒ FileStore

Returns a new instance of FileStore.



22
23
24
25
# File 'lib/llm_conductor/eval/store/file_store.rb', line 22

def initialize(base_dir)
  super()
  @base_dir = base_dir.to_s
end

Instance Attribute Details

#base_dirObject (readonly)

Returns the value of attribute base_dir.



20
21
22
# File 'lib/llm_conductor/eval/store/file_store.rb', line 20

def base_dir
  @base_dir
end

Instance Method Details

#completed?(run_id, input_id, model_slug) ⇒ Boolean

Returns:

  • (Boolean)


59
60
61
62
# File 'lib/llm_conductor/eval/store/file_store.rb', line 59

def completed?(run_id, input_id, model_slug)
  File.exist?(output_path(run_id, input_id, "#{model_slug}.json")) ||
    File.exist?(output_path(run_id, input_id, "#{model_slug}.raw.txt"))
end

#read_input_data(run_id, input_id) ⇒ Object



47
48
49
# File 'lib/llm_conductor/eval/store/file_store.rb', line 47

def read_input_data(run_id, input_id)
  read_json(output_path(run_id, input_id, '_input.json'))
end

#read_manifest(run_id) ⇒ Object



55
56
57
# File 'lib/llm_conductor/eval/store/file_store.rb', line 55

def read_manifest(run_id)
  read_json(manifest_path(run_id))
end

#read_parsed(run_id, input_id, model_slug) ⇒ Object



39
40
41
# File 'lib/llm_conductor/eval/store/file_store.rb', line 39

def read_parsed(run_id, input_id, model_slug)
  read_json(output_path(run_id, input_id, "#{model_slug}.json"))
end

#read_raw(run_id, input_id, model_slug) ⇒ Object



31
32
33
# File 'lib/llm_conductor/eval/store/file_store.rb', line 31

def read_raw(run_id, input_id, model_slug)
  read_file(output_path(run_id, input_id, "#{model_slug}.raw.txt"))
end

#write_input_data(run_id, input_id, hash) ⇒ Object



43
44
45
# File 'lib/llm_conductor/eval/store/file_store.rb', line 43

def write_input_data(run_id, input_id, hash)
  write_file(output_path(run_id, input_id, '_input.json'), JSON.pretty_generate(hash))
end

#write_manifest(run_id, manifest_hash) ⇒ Object



51
52
53
# File 'lib/llm_conductor/eval/store/file_store.rb', line 51

def write_manifest(run_id, manifest_hash)
  write_file(manifest_path(run_id), JSON.pretty_generate(manifest_hash))
end

#write_parsed(run_id, input_id, model_slug, hash) ⇒ Object



35
36
37
# File 'lib/llm_conductor/eval/store/file_store.rb', line 35

def write_parsed(run_id, input_id, model_slug, hash)
  write_file(output_path(run_id, input_id, "#{model_slug}.json"), JSON.pretty_generate(hash))
end

#write_raw(run_id, input_id, model_slug, text) ⇒ Object



27
28
29
# File 'lib/llm_conductor/eval/store/file_store.rb', line 27

def write_raw(run_id, input_id, model_slug, text)
  write_file(output_path(run_id, input_id, "#{model_slug}.raw.txt"), text.to_s)
end