Class: GDK::Command::Evaluate

Inherits:
BaseCommand show all
Defined in:
lib/gdk/command/evaluate.rb

Constant Summary collapse

SUPPORTED_COMMANDS =
{
  'chat' => 'evaluation_scripts/chat/evaluate.py',
  'code_suggestions' => 'evaluation_scripts/code_suggestions/evaluate.py'
}.freeze

Instance Attribute Summary

Attributes inherited from BaseCommand

#stderr, #stdout

Instance Method Summary collapse

Methods inherited from BaseCommand

#config, #display_help_message, #help, #initialize, #print_help, #print_ready_message, #ready_messages, validate_config?

Constructor Details

This class inherits a constructor from GDK::Command::BaseCommand

Instance Method Details

#run(args = []) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/gdk/command/evaluate.rb', line 11

def run(args = [])
  sub_command = args.pop
  command = SUPPORTED_COMMANDS[sub_command]
  unless command
    GDK::Output.warn("Supported sub-commands are - #{SUPPORTED_COMMANDS.keys.join(', ')}")
    return false
  end

  unless project_exists?
    GDK::Output.warn('The ELI5 project has not yet been setup. Please see doc/howto/eli5.md.')
    return false
  end

  dataset_name = prompt_dataset_name(sub_command)
  return false if dataset_name.empty?

  sh = Shellout.new("poetry run python #{command} --dataset #{dataset_name}", chdir: project_path.to_s)
  sh.execute

  sh.success?
end