Class: Lemans::Agents::Oracle

Inherits:
Base
  • Object
show all
Defined in:
lib/lemans/agents/oracle.rb

Overview

Runs the task's own solution instead of a model. A task whose oracle does not score full marks is broken, not hard.

Constant Summary collapse

NAME =
"oracle"
REMOTE_DIR =
"/solution"
SOLVE =
"solve"
ENTRYPOINT =
"solve.sh"
PATCH =
"solution.patch"

Instance Attribute Summary

Attributes inherited from Base

#model, #profile

Instance Method Summary collapse

Methods inherited from Base

#initialize, #install, #name

Constructor Details

This class inherits a constructor from Lemans::Agents::Base

Instance Method Details

#call(environment, task:, logs_dir:) ⇒ Object

rubocop:disable Lint/UnusedMethodArgument

Raises:



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/lemans/agents/oracle.rb', line 16

def call(environment, task:, logs_dir:) # rubocop:disable Lint/UnusedMethodArgument
  raise ConfigError, "#{task.name}: no solution/ to run — the oracle has nothing to prove" unless task.solution?

  upload_solution(environment, task)
  result = environment.exec(command_for(task), timeout: timeout_sec)

  unless result.success?
    raise InfrastructureError,
          "#{task.name}: the solution itself failed (exit #{result.exit_code}): " \
          "#{result.output.to_s[0, 500]}"
  end

  Result.new(outcome: Results::Outcome.new(:completed), usage: Results::Usage.zero, trajectory: nil)
end