Class: Retab::ExperimentRuns

Inherits:
Object
  • Object
show all
Defined in:
lib/retab/experiment_runs.rb

Instance Method Summary collapse

Constructor Details

#initialize(client) ⇒ ExperimentRuns

Returns a new instance of ExperimentRuns.



9
10
11
# File 'lib/retab/experiment_runs.rb', line 9

def initialize(client)
  @client = client
end

Instance Method Details

#cancel(run_id:, request_options: {}) ⇒ Retab::CancelWorkflowExperimentRunResponse

Cancel Experiment Run

Parameters:

  • run_id (String)
  • request_options (Hash) (defaults to: {})

    (see Retab::Types::RequestOptions)

Returns:



154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/retab/experiment_runs.rb', line 154

def cancel(
  run_id:,
  request_options: {}
)
  response = @client.request(
    method: :post,
    path: "/v1/workflows/experiments/runs/#{Retab::Util.encode_path(run_id)}/cancel",
    auth: true,
    request_options: request_options
  )
  result = Retab::CancelWorkflowExperimentRunResponse.new(response.body)
  result.last_response = Retab::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#create(experiment_id:, workflow_id: nil, request_options: {}) ⇒ Retab::ExperimentRun

Create Experiment Run Flat

Parameters:

  • experiment_id (String)

    The experiment to create a run for.

  • workflow_id (String, nil) (defaults to: nil)

    Optional. When omitted, the workflow is derived from the experiment record. When supplied, must match the experiment’s workflow_id (404 otherwise).

  • request_options (Hash) (defaults to: {})

    (see Retab::Types::RequestOptions)

Returns:



110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
# File 'lib/retab/experiment_runs.rb', line 110

def create(
  experiment_id:,
  workflow_id: nil,
  request_options: {}
)
  body = {
    'experiment_id' => experiment_id,
    'workflow_id' => workflow_id
  }.compact
  response = @client.request(
    method: :post,
    path: '/v1/workflows/experiments/runs',
    auth: true,
    body: body,
    request_options: request_options
  )
  result = Retab::ExperimentRun.new(response.body)
  result.last_response = Retab::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#get(run_id:, request_options: {}) ⇒ Retab::ExperimentRun

Get Experiment Run

Parameters:

  • run_id (String)
  • request_options (Hash) (defaults to: {})

    (see Retab::Types::RequestOptions)

Returns:



135
136
137
138
139
140
141
142
143
144
145
146
147
148
# File 'lib/retab/experiment_runs.rb', line 135

def get(
  run_id:,
  request_options: {}
)
  response = @client.request(
    method: :get,
    path: "/v1/workflows/experiments/runs/#{Retab::Util.encode_path(run_id)}",
    auth: true,
    request_options: request_options
  )
  result = Retab::ExperimentRun.new(response.body)
  result.last_response = Retab::Types::ApiResponse.new(http_status: response.code.to_i, http_headers: response.each_header.to_h, request_id: response["x-request-id"])
  result
end

#list(workflow_id: nil, experiment_id: nil, block_id: nil, status: nil, statuses: nil, exclude_status: nil, trigger_type: nil, trigger_types: nil, from_date: nil, to_date: nil, sort_by: 'created_at', fields: nil, before: nil, after: nil, limit: 20, order: 'desc', request_options: {}) ⇒ Retab::Types::ListStruct<Retab::ExperimentRun>

List Experiment Runs

Parameters:

  • workflow_id (String, nil) (defaults to: nil)
  • experiment_id (String, nil) (defaults to: nil)
  • block_id (String, nil) (defaults to: nil)
  • status (Retab::Types::WorkflowExperimentsStatus, nil) (defaults to: nil)
  • statuses (String, nil) (defaults to: nil)
  • exclude_status (Retab::Types::WorkflowExperimentsExcludeStatus, nil) (defaults to: nil)
  • trigger_type (String, nil) (defaults to: nil)
  • trigger_types (String, nil) (defaults to: nil)
  • from_date (String, nil) (defaults to: nil)
  • to_date (String, nil) (defaults to: nil)
  • sort_by (String, nil) (defaults to: 'created_at')
  • fields (String, nil) (defaults to: nil)
  • before (String, nil) (defaults to: nil)
  • after (String, nil) (defaults to: nil)
  • limit (Integer, nil) (defaults to: 20)
  • order (Retab::Types::ExperimentRunsOrder, nil) (defaults to: 'desc')
  • request_options (Hash) (defaults to: {})

    (see Retab::Types::RequestOptions)

Returns:



32
33
34
35
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# File 'lib/retab/experiment_runs.rb', line 32

def list(
  workflow_id: nil,
  experiment_id: nil,
  block_id: nil,
  status: nil,
  statuses: nil,
  exclude_status: nil,
  trigger_type: nil,
  trigger_types: nil,
  from_date: nil,
  to_date: nil,
  sort_by: 'created_at',
  fields: nil,
  before: nil,
  after: nil,
  limit: 20,
  order: 'desc',
  request_options: {}
)
  params = {
    'workflow_id' => workflow_id,
    'experiment_id' => experiment_id,
    'block_id' => block_id,
    'status' => status,
    'statuses' => statuses,
    'exclude_status' => exclude_status,
    'trigger_type' => trigger_type,
    'trigger_types' => trigger_types,
    'from_date' => from_date,
    'to_date' => to_date,
    'sort_by' => sort_by,
    'fields' => fields,
    'before' => before,
    'after' => after,
    'limit' => limit,
    'order' => order
  }.compact
  response = @client.request(
    method: :get,
    path: '/v1/workflows/experiments/runs',
    auth: true,
    params: params,
    request_options: request_options
  )
  fetch_next = ->(cursor) {
    list(
      workflow_id: workflow_id,
      experiment_id: experiment_id,
      block_id: block_id,
      status: status,
      statuses: statuses,
      exclude_status: exclude_status,
      trigger_type: trigger_type,
      trigger_types: trigger_types,
      from_date: from_date,
      to_date: to_date,
      sort_by: sort_by,
      fields: fields,
      before: before,
      after: cursor,
      limit: limit,
      order: order,
      request_options: request_options
    )
  }
  Retab::Types::ListStruct.from_response(
    response,
    model: Retab::ExperimentRun,
    filters: { workflow_id: workflow_id, experiment_id: experiment_id, block_id: block_id, status: status, statuses: statuses, exclude_status: exclude_status, trigger_type: trigger_type, trigger_types: trigger_types, from_date: from_date, to_date: to_date, sort_by: sort_by, fields: fields, before: before, limit: limit, order: order },
    fetch_next: fetch_next
  )
end