chalk_ruby 0.4.1 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/chalk_ruby/client.rb +4 -14
- data/lib/chalk_ruby/grpc_client.rb +41 -12
- data/lib/chalk_ruby/version.rb +1 -1
- data/test/chalk_ruby/integration/grpc_client_test.rb +28 -0
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 41aeb7dd875f71ac96acd9d74dc75f583d59bc21a8611002996de8915ef92c11
|
4
|
+
data.tar.gz: dd7ff83b7c46fdfc1dd9cddba6cf874113c3ad64a0126e3efbf5b0abd4b31da9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fb9fc19e2b66f1ad829b3024d6d63a3aa28be882501689a56193424e447a3f98ebd49e795b0f3f8983052b7447afe6e767a4454923598f5625345c0361750d6e
|
7
|
+
data.tar.gz: e4f11dfeb743205a724e890335d6811f4f36eb93157da25874196f18bf8c26d52bb1149909f8760026414205a896ab3f6f42f78aa1096af02baa56dcec370adc
|
data/lib/chalk_ruby/client.rb
CHANGED
@@ -228,7 +228,7 @@ module ChalkRuby
|
|
228
228
|
end
|
229
229
|
|
230
230
|
# Warm up connections to the API and query servers by establishing
|
231
|
-
#
|
231
|
+
# connections without making actual requests
|
232
232
|
def warm_connections
|
233
233
|
# Get the query server host
|
234
234
|
query_host = query_server_host
|
@@ -242,23 +242,13 @@ module ChalkRuby
|
|
242
242
|
|
243
243
|
private
|
244
244
|
|
245
|
-
# Establish a connection to a host
|
245
|
+
# Establish a connection to a host without making a request
|
246
246
|
def warm_connection(host)
|
247
247
|
# Access the underlying HTTP requester
|
248
248
|
requester = @transporter.instance_variable_get(:@http_requester)
|
249
249
|
|
250
|
-
#
|
251
|
-
|
252
|
-
|
253
|
-
# Make a HEAD request to "/" to actually establish the TCP connection
|
254
|
-
# HEAD is used as it's lightweight and most servers support it
|
255
|
-
begin
|
256
|
-
connection.head('/')
|
257
|
-
rescue => e
|
258
|
-
# Ignore errors - we're just warming the connection
|
259
|
-
# The server might not support HEAD on /, but the TCP connection
|
260
|
-
# will still be established
|
261
|
-
end
|
250
|
+
# This will create and cache the Faraday connection
|
251
|
+
requester.connection(host)
|
262
252
|
end
|
263
253
|
|
264
254
|
def api_server_request(method:, path:, body:, headers:)
|
@@ -248,7 +248,7 @@ module ChalkRuby
|
|
248
248
|
end
|
249
249
|
|
250
250
|
def get_token
|
251
|
-
response =
|
251
|
+
response = auth_service.get_token(
|
252
252
|
Chalk::Server::V1::GetTokenRequest.new(
|
253
253
|
client_id: @config.client_id,
|
254
254
|
client_secret: @config.client_secret
|
@@ -469,26 +469,55 @@ module ChalkRuby
|
|
469
469
|
end
|
470
470
|
|
471
471
|
def to_feather(input_hash)
|
472
|
-
|
473
|
-
|
474
|
-
|
472
|
+
raise NotImplementedError,
|
473
|
+
"Add `gem 'red-arrow', '~> 18.0'` to your Gemfile" unless red_arrow_available?
|
474
|
+
|
475
475
|
require 'arrow'
|
476
476
|
|
477
|
-
#
|
478
|
-
array_input_hash = input_hash.
|
477
|
+
# Normalise column data
|
478
|
+
array_input_hash = input_hash.transform_keys(&:to_s)
|
479
|
+
.transform_values { |v| v.is_a?(Array) ? v : [v] }
|
479
480
|
|
480
|
-
|
481
|
-
|
481
|
+
lengths = array_input_hash.values.map(&:length).uniq
|
482
|
+
raise ArgumentError, "Columns must be the same length (got #{lengths})" unless lengths.one?
|
482
483
|
|
483
|
-
|
484
|
-
buffer = Arrow::ResizableBuffer.new(0)
|
484
|
+
table = Arrow::Table.new(array_input_hash)
|
485
485
|
|
486
|
+
buffer = Arrow::ResizableBuffer.new(0)
|
486
487
|
output = Arrow::BufferOutputStream.new(buffer)
|
487
488
|
|
489
|
+
# ──────────────────────────────────────────────────────────
|
488
490
|
table.write_as_feather(output)
|
491
|
+
output.close # ← **critical**: flush footer
|
492
|
+
# ──────────────────────────────────────────────────────────
|
489
493
|
|
490
|
-
#
|
491
|
-
|
494
|
+
# The stream writes exactly `output.tell` bytes; slice to that.
|
495
|
+
bytes_written = output.tell
|
496
|
+
buffer.data.to_s.b.byteslice(0, bytes_written)
|
492
497
|
end
|
493
498
|
end
|
499
|
+
|
500
|
+
# def to_feather(input_hash)
|
501
|
+
# unless red_arrow_available?
|
502
|
+
# raise NotImplementedError, "to_feather requires the 'red-arrow' gem. Please add it to your Gemfile: gem 'red-arrow', '~> 18.0.0'"
|
503
|
+
# end
|
504
|
+
# require 'arrow'
|
505
|
+
#
|
506
|
+
# # Ensure all values in the input hash are arrays
|
507
|
+
# array_input_hash = input_hash.transform_values { |v| v.is_a?(Array) ? v : [v] }
|
508
|
+
#
|
509
|
+
# # Create a table from the transformed input hash
|
510
|
+
# table = Arrow::Table.new(array_input_hash)
|
511
|
+
#
|
512
|
+
# # Write to feather format in memory
|
513
|
+
# buffer = Arrow::ResizableBuffer.new(0)
|
514
|
+
#
|
515
|
+
# output = Arrow::BufferOutputStream.new(buffer)
|
516
|
+
#
|
517
|
+
# table.write_as_feather(output)
|
518
|
+
#
|
519
|
+
# # Remove trailing null bytes from the resizable buffer; the buffer is 512 aligned
|
520
|
+
# buffer.data.to_s.b.gsub(/ARROW1(.*)ARROW1.*/m) {"ARROW1#{$1}ARROW1"}
|
521
|
+
# end
|
522
|
+
# end
|
494
523
|
end
|
data/lib/chalk_ruby/version.rb
CHANGED
@@ -73,4 +73,32 @@ RSpec.describe ChalkRuby::GrpcClient do
|
|
73
73
|
expect(response[:data][0]['user.id']).to eq(1)
|
74
74
|
end
|
75
75
|
end
|
76
|
+
|
77
|
+
describe '#get_token' do
|
78
|
+
let(:client) do
|
79
|
+
ChalkRuby::GrpcClient.new(
|
80
|
+
ChalkRuby::Config.new(
|
81
|
+
query_server: "standard-gke.chalk-develop.gcp.chalk.ai",
|
82
|
+
api_server: "api.staging.chalk.ai:443",
|
83
|
+
client_id: CLIENT_ID,
|
84
|
+
client_secret: CLIENT_SECRET,
|
85
|
+
environment: "tmnmc9beyujew"
|
86
|
+
)
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'can get auth token successfully' do
|
91
|
+
token = client.get_token
|
92
|
+
|
93
|
+
expect(token).not_to be_nil
|
94
|
+
expect(token).to be_a(String)
|
95
|
+
expect(token.length).to be > 0
|
96
|
+
end
|
97
|
+
|
98
|
+
it 'uses auth_service instead of undefined @auth_stub' do
|
99
|
+
# This test ensures the fix for the NoMethodError is working
|
100
|
+
# The method should not raise an error about undefined @auth_stub
|
101
|
+
expect { client.get_token }.not_to raise_error(NoMethodError)
|
102
|
+
end
|
103
|
+
end
|
76
104
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chalk_ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chalk AI, Inc.
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2025-
|
11
|
+
date: 2025-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -376,7 +376,7 @@ metadata:
|
|
376
376
|
bug_tracker_uri: https://github.com/chalk-ai/chalk-ruby/issues
|
377
377
|
documentation_uri: https://docs.chalk.ai/docs
|
378
378
|
source_code_uri: https://github.com/chalk-ai/chalk-ruby
|
379
|
-
post_install_message:
|
379
|
+
post_install_message:
|
380
380
|
rdoc_options: []
|
381
381
|
require_paths:
|
382
382
|
- lib
|
@@ -391,8 +391,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
391
391
|
- !ruby/object:Gem::Version
|
392
392
|
version: '0'
|
393
393
|
requirements: []
|
394
|
-
rubygems_version: 3.
|
395
|
-
signing_key:
|
394
|
+
rubygems_version: 3.0.3.1
|
395
|
+
signing_key:
|
396
396
|
specification_version: 4
|
397
397
|
summary: A simple Ruby client for Chalk
|
398
398
|
test_files:
|