-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into cherry-pick-ce-commit-38bcb06616369ecc46eb5f…
…231ad49f48ee3c4456
- Loading branch information
Showing
100 changed files
with
2,667 additions
and
914 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
integrations/lib/multiwoven/integrations/source/aws_sagemaker_model/client.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# frozen_string_literal: true | ||
|
||
module Multiwoven::Integrations::Source | ||
module AwsSagemakerModel | ||
include Multiwoven::Integrations::Core | ||
class Client < SourceConnector | ||
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_multiwoven_message | ||
end | ||
|
||
def discover(_connection_config) | ||
catalog_json = read_json(CATALOG_SPEC_PATH) | ||
catalog = build_catalog(catalog_json) | ||
catalog.to_multiwoven_message | ||
rescue StandardError => e | ||
handle_exception(e, { | ||
context: "AWS:SAGEMAKER MODEL:DISCOVER:EXCEPTION", | ||
type: "error" | ||
}) | ||
end | ||
|
||
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 | ||
|
||
private | ||
|
||
def create_connection(connection_config) | ||
@client = Aws::SageMaker::Client.new( | ||
region: connection_config[:region], | ||
access_key_id: connection_config[:access_key], | ||
secret_access_key: connection_config[:secret_access_key] | ||
) | ||
|
||
@client_runtime = Aws::SageMakerRuntime::Client.new( | ||
region: connection_config[:region], | ||
access_key_id: connection_config[:access_key], | ||
secret_access_key: connection_config[:secret_access_key] | ||
) | ||
end | ||
|
||
def run_model(connection_config, payload) | ||
response = @client_runtime.invoke_endpoint( | ||
endpoint_name: connection_config[:endpoint_name], | ||
content_type: "application/json", | ||
body: payload | ||
) | ||
process_response(response) | ||
rescue StandardError => e | ||
handle_exception(e, context: "AWS:SAGEMAKER MODEL:RUN_MODEL:EXCEPTION", type: "error") | ||
end | ||
|
||
def process_response(response) | ||
data = JSON.parse(response.body.read) | ||
[RecordMessage.new(data: { response: data }, emitted_at: Time.now.to_i).to_multiwoven_message] | ||
end | ||
end | ||
end | ||
end |
6 changes: 6 additions & 0 deletions
6
integrations/lib/multiwoven/integrations/source/aws_sagemaker_model/config/catalog.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"request_rate_limit": 600, | ||
"request_rate_limit_unit": "minute", | ||
"request_rate_concurrency": 10, | ||
"streams": [] | ||
} |
15 changes: 15 additions & 0 deletions
15
integrations/lib/multiwoven/integrations/source/aws_sagemaker_model/config/meta.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"data": { | ||
"name": "AwsSagemakerModel", | ||
"title": "AWS Sagemaker Model", | ||
"connector_type": "source", | ||
"category": "AI Model", | ||
"documentation_url": "https://docs.mutliwoven.com", | ||
"github_issue_label": "source-aws-sagemaker-model", | ||
"icon": "icon.svg", | ||
"license": "MIT", | ||
"release_stage": "alpha", | ||
"support_level": "community", | ||
"tags": ["language:ruby", "multiwoven"] | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
integrations/lib/multiwoven/integrations/source/aws_sagemaker_model/config/spec.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
{ | ||
"documentation_url": "https://docs.multiwoven.com/integrations/sources/aws_sagemaker-model", | ||
"stream_type": "user_defined", | ||
"connector_query_type": "ai_ml", | ||
"connection_specification": { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"title": "AWS Sagemaker Model", | ||
"type": "object", | ||
"required": ["access_key", "secret_access_key", "region", "endpoint_name", "request_format", "response_format"], | ||
"properties": { | ||
"access_key": { | ||
"description": "The AWS Access Key ID to use for authentication", | ||
"type": "string", | ||
"title": "Personal Access Key", | ||
"order": 0 | ||
}, | ||
"secret_access_key": { | ||
"description": "The AWS Secret Access Key to use for authentication", | ||
"type": "string", | ||
"multiwoven_secret": true, | ||
"title": "Secret Access Key", | ||
"order": 1 | ||
}, | ||
"region": { | ||
"description": "AWS region", | ||
"type": "string", | ||
"title": "Region", | ||
"order": 2 | ||
}, | ||
"endpoint_name": { | ||
"description": "Endpoint name for AWS Sagemaker", | ||
"type": "string", | ||
"title": "Endpoint name", | ||
"order": 3 | ||
}, | ||
"request_format": { | ||
"description": "Sample Request Format", | ||
"type": "string", | ||
"title": "Request Format", | ||
"order": 4 | ||
}, | ||
"response_format": { | ||
"description": "Sample Response Format", | ||
"type": "string", | ||
"title": "Response Format", | ||
"order": 5 | ||
} | ||
} | ||
} | ||
} |
18 changes: 18 additions & 0 deletions
18
integrations/lib/multiwoven/integrations/source/aws_sagemaker_model/icon.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.