Skip to content

Commit

Permalink
chore(CE): add payload limit to databricks model (#554)
Browse files Browse the repository at this point in the history
Co-authored-by: TivonB-AI2 <[email protected]>
  • Loading branch information
github-actions[bot] and TivonB-AI2 authored Dec 27, 2024
1 parent fcb9004 commit 8c395c7
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 4 deletions.
2 changes: 1 addition & 1 deletion integrations/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GIT
PATH
remote: .
specs:
multiwoven-integrations (0.16.1)
multiwoven-integrations (0.16.2)
MailchimpMarketing
activesupport
async-websocket
Expand Down
2 changes: 1 addition & 1 deletion integrations/lib/multiwoven/integrations/rollout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Multiwoven
module Integrations
VERSION = "0.16.1"
VERSION = "0.16.2"

ENABLED_SOURCES = %w[
Snowflake
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,12 @@ def run_model(connection_config, payload)

def process_response(response)
if success?(response)
data = JSON.parse(response.body)
[RecordMessage.new(data: data, emitted_at: Time.now.to_i).to_multiwoven_message]
begin
data = JSON.parse(response.body)
[RecordMessage.new(data: data, emitted_at: Time.now.to_i).to_multiwoven_message]
rescue JSON::ParserError
create_log_message("DATABRICKS MODEL:RUN_MODEL", "error", "parsing failed: please send a valid payload")
end
else
create_log_message("DATABRICKS MODEL:RUN_MODEL", "error", "request failed: #{response.body}")
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,27 @@
expect(records.first.record.data).to eq(JSON.parse(response_body))
end
end

context "when the payload is invalid in read" do
let(:response_body) { "{\"key\": invalid_json}" }.to_json
before do
response = Net::HTTPSuccess.new("1.1", "200", "Unauthorized")
response.content_type = "application/json"
allow(response).to receive(:body).and_return(response_body)
allow(Multiwoven::Integrations::Core::HttpClient).to receive(:request)
.with("https://test-host.databricks.com/serving-endpoints/test/invocations",
"POST",
payload: JSON.parse(payload.to_json),
headers: headers)
.and_return(response)
end
it "handles exceptions during reading" do
records = client.read(sync_config)
expect(records.log).to be_a(Multiwoven::Integrations::Protocol::LogMessage)
expect(records.log.message).to eq("parsing failed: please send a valid payload")
end
end

context "when the read is failed" do
it "handles exceptions during reading" do
error_instance = StandardError.new("test error")
Expand Down

0 comments on commit 8c395c7

Please sign in to comment.