Class: Outhad::Integrations::Source::AwsSagemakerModel::Client

Inherits:
SourceConnector
  • Object
show all
Defined in:
lib/outhad/integrations/source/aws_sagemaker_model/client.rb

Instance Method Summary collapse

Instance Method Details

#check_connection(connection_config) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/outhad/integrations/source/aws_sagemaker_model/client.rb', line 7

def check_connection(connection_config)
  connection_config = connection_config.with_indifferent_access
  create_connection(connection_config)
  response = @client.describe_endpoint(endpoint_name: connection_config[:endpoint_name])
  if response.endpoint_status == "InService"
    success_status
  else
    failure_status
  end
rescue StandardError => e
  ConnectionStatus.new(status: ConnectionStatusType["failed"], message: e.message).to_outhad_message
end

#discover(_connection_config) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/outhad/integrations/source/aws_sagemaker_model/client.rb', line 20

def discover(_connection_config)
  catalog_json = read_json(CATALOG_SPEC_PATH)
  catalog = build_catalog(catalog_json)
  catalog.to_outhad_message
rescue StandardError => e
  handle_exception(e, {
                     context: "AWS:SAGEMAKER MODEL:DISCOVER:EXCEPTION",
                     type: "error"
                   })
end

#read(sync_config) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/outhad/integrations/source/aws_sagemaker_model/client.rb', line 31

def read(sync_config)
  connection_config = sync_config.source.connection_specification
  connection_config = connection_config.with_indifferent_access
  payload = sync_config.model.query
  create_connection(connection_config)
  run_model(connection_config, payload)
rescue StandardError => e
  handle_exception(e, {
                     context: "AWS:SAGEMAKER MODEL:READ:EXCEPTION",
                     type: "error",
                     sync_id: sync_config.sync_id,
                     sync_run_id: sync_config.sync_run_id
                   })
end