Skip to content

Commit

Permalink
Resolve conflict in cherry-pick of 85bb939d469bd820c456e23007095cf304…
Browse files Browse the repository at this point in the history
…3b9013 and change the commit message
  • Loading branch information
TivonB-AI2 authored and ai-squared committed Dec 25, 2024
1 parent 800b6fb commit c8e4f1d
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
4 changes: 4 additions & 0 deletions integrations/Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ GIT
PATH
remote: .
specs:
<<<<<<< HEAD
multiwoven-integrations (0.15.10)
=======
multiwoven-integrations (0.16.2)
>>>>>>> 85bb939d (chore(CE): add payload limit to databricks model (#745))
MailchimpMarketing
activesupport
async-websocket
Expand Down
4 changes: 4 additions & 0 deletions integrations/lib/multiwoven/integrations/rollout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@

module Multiwoven
module Integrations
<<<<<<< HEAD
VERSION = "0.15.10"
=======
VERSION = "0.16.2"
>>>>>>> 85bb939d (chore(CE): add payload limit to databricks model (#745))

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 c8e4f1d

Please sign in to comment.