Class: Lemans::Agents::Oracle

Inherits:
Lemans::Agent 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 Lemans::Agent

#model, #profile

Instance Method Summary collapse

Methods inherited from Lemans::Agent

#initialize, #install, #name

Constructor Details

This class inherits a constructor from Lemans::Agent

Instance Method Details

#run(task, environment) ⇒ Object

Raises:



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

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

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

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

  Response.new(outcome: Result::Outcome.new(:completed), usage: Result::Usage.zero)
end