Class: Openlayer::InferencePipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/openlayer/inference_pipeline.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(client, inference_pipeline_id) ⇒ InferencePipeline

Returns a new instance of InferencePipeline.



7
8
9
10
# File 'lib/openlayer/inference_pipeline.rb', line 7

def initialize(client, inference_pipeline_id)
  @client = client
  @inference_pipeline_id = inference_pipeline_id
end

Instance Attribute Details

#clientObject (readonly)

Returns the value of attribute client.



5
6
7
# File 'lib/openlayer/inference_pipeline.rb', line 5

def client
  @client
end

#inference_pipeline_idObject (readonly)

Returns the value of attribute inference_pipeline_id.



5
6
7
# File 'lib/openlayer/inference_pipeline.rb', line 5

def inference_pipeline_id
  @inference_pipeline_id
end

Instance Method Details

#handle_response(response) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/openlayer/inference_pipeline.rb', line 17

def handle_response(response)
  message = response.body["error"]
  case response.status
  when 200
    response.body
  when 401
    raise Error, message
  when 404
    raise Error, message
  when 422
    raise Error, message
  when 500
    raise Error, message
  else
    raise Error, message
  end
  response
end

#stream_data(body = {}) ⇒ Object



12
13
14
15
# File 'lib/openlayer/inference_pipeline.rb', line 12

def stream_data(body = {})
  handle_response client.connection.post("inference-pipelines/#{inference_pipeline_id}/data-stream", body)
  true
end