Class: Retab::ExperimentResult

Inherits:
Types::BaseModel show all
Defined in:
lib/retab/experiment_run_results/experiment_result.rb

Constant Summary collapse

HASH_ATTRS =
{
  id: :id,
  experiment_run_id: :experiment_run_id,
  experiment_id: :experiment_id,
  document_id: :document_id,
  lifecycle: :lifecycle,
  timing: :timing,
  block_type: :block_type,
  handle_inputs: :handle_inputs,
  handle_outputs: :handle_outputs,
  artifact: :artifact,
  attempt: :attempt
}.freeze

Instance Attribute Summary collapse

Attributes inherited from Types::BaseModel

#last_response

Instance Method Summary collapse

Methods inherited from Types::BaseModel

deep_symbolize, #inspect, normalize, #to_h, #to_json

Constructor Details

#initialize(json) ⇒ ExperimentResult

Returns a new instance of ExperimentResult.



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/retab/experiment_run_results/experiment_result.rb', line 36

def initialize(json)
  super()
  hash = self.class.normalize(json)
  @id = hash[:id]
  @experiment_run_id = hash[:experiment_run_id]
  @experiment_id = hash[:experiment_id]
  @document_id = hash[:document_id]
  @lifecycle = hash[:lifecycle] ? (
    case hash[:lifecycle][:status]
    when "cancelled"
      Retab::CancelledWorkflowExperimentResult.new(hash[:lifecycle])
    when "completed"
      Retab::CompletedWorkflowExperimentResult.new(hash[:lifecycle])
    when "error"
      Retab::ErrorWorkflowExperimentResult.new(hash[:lifecycle])
    when "pending"
      Retab::PendingWorkflowExperimentResult.new(hash[:lifecycle])
    when "queued"
      Retab::QueuedWorkflowExperimentResult.new(hash[:lifecycle])
    when "running"
      Retab::RunningWorkflowExperimentResult.new(hash[:lifecycle])
    else
      hash[:lifecycle]
    end
  ) : nil
  @timing = hash[:timing] ? Retab::ExperimentResultTiming.new(hash[:timing]) : nil
  @block_type = hash[:block_type]
  @handle_inputs = hash[:handle_inputs] || {}
  @handle_outputs = hash[:handle_outputs] || {}
  @artifact = hash[:artifact] ? Retab::StepArtifactRef.new(hash[:artifact]) : nil
  @attempt = hash[:attempt]
end

Instance Attribute Details

#artifactObject

Returns the value of attribute artifact.



22
23
24
# File 'lib/retab/experiment_run_results/experiment_result.rb', line 22

def artifact
  @artifact
end

#attemptObject

Returns the value of attribute attempt.



22
23
24
# File 'lib/retab/experiment_run_results/experiment_result.rb', line 22

def attempt
  @attempt
end

#block_typeObject

Returns the value of attribute block_type.



22
23
24
# File 'lib/retab/experiment_run_results/experiment_result.rb', line 22

def block_type
  @block_type
end

#document_idObject

Returns the value of attribute document_id.



22
23
24
# File 'lib/retab/experiment_run_results/experiment_result.rb', line 22

def document_id
  @document_id
end

#experiment_idObject

Returns the value of attribute experiment_id.



22
23
24
# File 'lib/retab/experiment_run_results/experiment_result.rb', line 22

def experiment_id
  @experiment_id
end

#experiment_run_idObject

Returns the value of attribute experiment_run_id.



22
23
24
# File 'lib/retab/experiment_run_results/experiment_result.rb', line 22

def experiment_run_id
  @experiment_run_id
end

#handle_inputsObject

Returns the value of attribute handle_inputs.



22
23
24
# File 'lib/retab/experiment_run_results/experiment_result.rb', line 22

def handle_inputs
  @handle_inputs
end

#handle_outputsObject

Returns the value of attribute handle_outputs.



22
23
24
# File 'lib/retab/experiment_run_results/experiment_result.rb', line 22

def handle_outputs
  @handle_outputs
end

#idObject

Returns the value of attribute id.



22
23
24
# File 'lib/retab/experiment_run_results/experiment_result.rb', line 22

def id
  @id
end

#lifecycleObject

Returns the value of attribute lifecycle.



22
23
24
# File 'lib/retab/experiment_run_results/experiment_result.rb', line 22

def lifecycle
  @lifecycle
end

#timingObject

Returns the value of attribute timing.



22
23
24
# File 'lib/retab/experiment_run_results/experiment_result.rb', line 22

def timing
  @timing
end