Skip to content

Commit 68fd543

Browse files
standardrb fixes
1 parent 217acf4 commit 68fd543

File tree

11 files changed

+97
-101
lines changed

11 files changed

+97
-101
lines changed

lib/qdrant/client.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ def initialize(
2424
def connection
2525
@connection ||= Faraday.new(url: url) do |faraday|
2626
if api_key
27-
faraday.headers['api-key'] = api_key
27+
faraday.headers["api-key"] = api_key
2828
end
2929
faraday.request :json
3030
faraday.response :json, content_type: /\bjson$/
@@ -56,4 +56,4 @@ def points
5656
@points ||= Qdrant::Points.new(client: self)
5757
end
5858
end
59-
end
59+
end

lib/qdrant/clusters.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def remove_peer(
2222
force: nil
2323
)
2424
response = client.connection.post("#{PATH}/recover") do |req|
25-
req.params['force'] = force if force
25+
req.params["force"] = force if force
2626
end
2727
response.body
2828
end

lib/qdrant/collections.rb

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ def create(
3232
)
3333
response = client.connection.put("#{PATH}/#{collection_name}") do |req|
3434
req.body = {}
35-
req.body['vectors'] = vectors
36-
req.body['shard_number'] = shard_number unless shard_number.nil?
37-
req.body['replication_factor'] = replication_factor unless replication_factor.nil?
38-
req.body['write_consistency_factor'] = write_consistency_factor unless write_consistency_factor.nil?
39-
req.body['on_disk_payload'] = on_disk_payload unless on_disk_payload.nil?
40-
req.body['hnsw_config'] = hnsw_config unless hnsw_config.nil?
41-
req.body['wal_config'] = wal_config unless wal_config.nil?
42-
req.body['optimizers_config'] = optimizers_config unless optimizers_config.nil?
43-
req.body['init_from'] = init_from unless init_from.nil?
44-
req.body['quantization_config'] = quantization_config unless quantization_config.nil?
35+
req.body["vectors"] = vectors
36+
req.body["shard_number"] = shard_number unless shard_number.nil?
37+
req.body["replication_factor"] = replication_factor unless replication_factor.nil?
38+
req.body["write_consistency_factor"] = write_consistency_factor unless write_consistency_factor.nil?
39+
req.body["on_disk_payload"] = on_disk_payload unless on_disk_payload.nil?
40+
req.body["hnsw_config"] = hnsw_config unless hnsw_config.nil?
41+
req.body["wal_config"] = wal_config unless wal_config.nil?
42+
req.body["optimizers_config"] = optimizers_config unless optimizers_config.nil?
43+
req.body["init_from"] = init_from unless init_from.nil?
44+
req.body["quantization_config"] = quantization_config unless quantization_config.nil?
4545
end
4646

4747
response.body
@@ -95,7 +95,7 @@ def create_index(
9595
req.body = {
9696
field_name: field_name
9797
}
98-
req.body['field_schema'] = field_schema unless field_schema.nil?
98+
req.body["field_schema"] = field_schema unless field_schema.nil?
9999
end
100100

101101
response.body
@@ -136,7 +136,7 @@ def download_snapshot(
136136
filepath:
137137
)
138138
response = client.connection.get("#{PATH}/#{collection_name}/snapshots/#{snapshot_name}")
139-
File.open(File.expand_path(filepath), 'wb+') { |fp| fp.write(response.body) }
139+
File.open(File.expand_path(filepath), "wb+") { |fp| fp.write(response.body) }
140140
end
141141

142142
# Delete snapshot for a collection
@@ -172,12 +172,12 @@ def restore_snapshot(
172172
wait: nil
173173
)
174174
response = client.connection.post("#{PATH}/#{collection_name}/snapshots/recover") do |req|
175-
req.params['wait'] = wait unless wait.nil?
175+
req.params["wait"] = wait unless wait.nil?
176176

177177
req.body = {
178178
location: filepath
179179
}
180-
req.body['priority'] = priority unless priority.nil?
180+
req.body["priority"] = priority unless priority.nil?
181181
end
182182
response.body
183183
end

lib/qdrant/points.rb

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,8 @@ def upsert(
4646
# Delete points
4747
def delete(
4848
collection_name:,
49-
wait: nil,
50-
ordering: nil,
51-
points:
49+
points:, wait: nil,
50+
ordering: nil
5251
)
5352
response = client.connection.post("collections/#{collection_name}/#{PATH}/delete") do |req|
5453
req.params["wait"] = wait unless wait.nil?
@@ -96,9 +95,8 @@ def set_payload(
9695
# Replace full payload of points with new one
9796
def overwrite_payload(
9897
collection_name:,
99-
wait: nil,
98+
payload:, wait: nil,
10099
ordering: nil,
101-
payload:,
102100
points: nil,
103101
filter: nil
104102
)
@@ -111,14 +109,14 @@ def overwrite_payload(
111109
req.body["points"] = points unless points.nil?
112110
req.body["filter"] = filter unless filter.nil?
113111
end
112+
response.body
114113
end
115114

116115
# Delete specified key payload for points
117116
def clear_payload_keys(
118117
collection_name:,
119-
wait: nil,
118+
keys:, wait: nil,
120119
ordering: nil,
121-
keys:,
122120
points: nil,
123121
filter: nil
124122
)
@@ -129,7 +127,7 @@ def clear_payload_keys(
129127
req.body = {}
130128
req.body["keys"] = keys
131129
req.body["points"] = points unless points.nil?
132-
req.body["filter"] = filter unless filter.nil?
130+
req.body["filter"] = filter unless filter.nil?
133131
end
134132
response.body
135133
end

lib/qdrant/service.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ def metrics(
2222
response.body
2323
end
2424

25-
2625
# Set lock options. If write is locked, all write operations and collection creation are forbidden. Returns previous lock options
2726
def set_lock(
2827
write:,

lib/qdrant/snapshots.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def download(
3030
filepath:
3131
)
3232
response = client.connection.get("#{PATH}/#{snapshot_name}")
33-
File.open(File.expand_path(filepath), 'wb+') { |fp| fp.write(response.body) }
33+
File.open(File.expand_path(filepath), "wb+") { |fp| fp.write(response.body) }
3434
end
3535
end
3636
end

spec/qdrant/clusters_spec.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,14 @@
1717
}
1818

1919
describe "#info" do
20-
2120
before do
2221
allow_any_instance_of(Faraday::Connection).to receive(:get)
2322
.with("cluster")
2423
.and_return(response)
2524
end
2625

2726
it "return the cluster info" do
28-
expect(client.clusters.info.dig('status')).to eq('ok')
27+
expect(client.clusters.info.dig("status")).to eq("ok")
2928
end
3029
end
3130

@@ -37,7 +36,7 @@
3736
end
3837

3938
it "return the data" do
40-
expect(client.clusters.recover.dig('status')).to eq('ok')
39+
expect(client.clusters.recover.dig("status")).to eq("ok")
4140
end
4241
end
4342

spec/qdrant/collections_spec.rb

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
end
2626

2727
it "returns collections" do
28-
expect(collections.list.dig('result', 'collections').count).to eq(1)
28+
expect(collections.list.dig("result", "collections").count).to eq(1)
2929
end
3030
end
3131

@@ -40,7 +40,7 @@
4040

4141
it "returns the collection" do
4242
response = collections.get(collection_name: "test_collection")
43-
expect(response.dig('result', 'status')).to eq('green')
43+
expect(response.dig("result", "status")).to eq("green")
4444
end
4545
end
4646

@@ -77,8 +77,8 @@
7777

7878
it "returns the schema" do
7979
response = collections.delete(collection_name: "test_collection")
80-
expect(response.dig('status')).to eq('ok')
81-
expect(response.dig('result')).to eq(true)
80+
expect(response.dig("status")).to eq("ok")
81+
expect(response.dig("result")).to eq(true)
8282
end
8383
end
8484

@@ -98,8 +98,8 @@
9898
replication_factor: 1
9999
}
100100
)
101-
expect(response.dig('status')).to eq('ok')
102-
expect(response.dig('result')).to eq(true)
101+
expect(response.dig("status")).to eq("ok")
102+
expect(response.dig("result")).to eq(true)
103103
end
104104
end
105105

@@ -116,13 +116,13 @@
116116
response = collections.update_aliases(
117117
actions: [{
118118
create_alias: {
119-
collection_name: 'test_collection',
120-
alias_name: 'alias_test_collection'
119+
collection_name: "test_collection",
120+
alias_name: "alias_test_collection"
121121
}
122122
}]
123123
)
124-
expect(response.dig('status')).to eq('ok')
125-
expect(response.dig('result')).to eq(true)
124+
expect(response.dig("status")).to eq("ok")
125+
expect(response.dig("result")).to eq(true)
126126
end
127127
end
128128

@@ -137,7 +137,7 @@
137137

138138
it "returns the schema" do
139139
response = collections.aliases(collection_name: "test_collection")
140-
expect(response.dig('result', 'aliases').count).to eq(1)
140+
expect(response.dig("result", "aliases").count).to eq(1)
141141
end
142142
end
143143

@@ -156,8 +156,8 @@
156156
field_name: "description",
157157
field_schema: "text"
158158
)
159-
expect(response.dig('status')).to eq('ok')
160-
expect(response.dig('result')).to eq(true)
159+
expect(response.dig("status")).to eq("ok")
160+
expect(response.dig("result")).to eq(true)
161161
end
162162
end
163163

@@ -175,8 +175,8 @@
175175
collection_name: "test_collection",
176176
field_name: "description"
177177
)
178-
expect(response.dig('status')).to eq('ok')
179-
expect(response.dig('result')).to eq(true)
178+
expect(response.dig("status")).to eq("ok")
179+
expect(response.dig("result")).to eq(true)
180180
end
181181
end
182182

@@ -193,7 +193,7 @@
193193
response = collections.cluster_info(
194194
collection_name: "test_collection"
195195
)
196-
expect(response.dig('result', 'peer_id')).to eq(111)
196+
expect(response.dig("result", "peer_id")).to eq(111)
197197
end
198198
end
199199

@@ -210,13 +210,13 @@
210210
response = collections.update_cluster(
211211
collection_name: "test_collection",
212212
move_shard: {
213-
shard_id: 0,
214-
to_peer_id: 222,
215-
from_peer_id: 111
213+
shard_id: 0,
214+
to_peer_id: 222,
215+
from_peer_id: 111
216216
}
217217
)
218-
expect(response.dig('status')).to eq('ok')
219-
expect(response.dig('result')).to eq(true)
218+
expect(response.dig("status")).to eq("ok")
219+
expect(response.dig("result")).to eq(true)
220220
end
221221
end
222222

@@ -233,7 +233,7 @@
233233
response = collections.list_snapshots(
234234
collection_name: "test_collection"
235235
)
236-
expect(response.dig('result').count).to eq(2)
236+
expect(response.dig("result").count).to eq(2)
237237
end
238238
end
239239

@@ -252,8 +252,8 @@
252252
response = collections.create_snapshot(
253253
collection_name: "test_collection"
254254
)
255-
expect(response.dig('status')).to eq('ok')
256-
expect(response.dig('result', 'name')).to eq("test_collection-6106351684939824381-2023-04-06-20-43-03.snapshot")
255+
expect(response.dig("status")).to eq("ok")
256+
expect(response.dig("result", "name")).to eq("test_collection-6106351684939824381-2023-04-06-20-43-03.snapshot")
257257
end
258258
end
259259

@@ -271,8 +271,8 @@
271271
collection_name: "test_collection",
272272
snapshot_name: "test_collection-6106351684939824381-2023-04-06-20-43-03.snapshot"
273273
)
274-
expect(response.dig('status')).to eq('ok')
275-
expect(response.dig('result')).to eq(true)
274+
expect(response.dig("status")).to eq("ok")
275+
expect(response.dig("result")).to eq(true)
276276
end
277277
end
278278

@@ -283,8 +283,8 @@
283283
allow_any_instance_of(Faraday::Connection).to receive(:get)
284284
.with("collections/test_collection/snapshots/test_collection-6106351684939824381-2023-04-06-20-43-03.snapshot")
285285
.and_return(response)
286-
287-
allow(File).to receive(:open).with("/dir/snapshot.txt", 'wb+').and_return(999)
286+
287+
allow(File).to receive(:open).with("/dir/snapshot.txt", "wb+").and_return(999)
288288
end
289289

290290
it "returns the schema" do
@@ -311,8 +311,8 @@
311311
collection_name: "test_collection",
312312
filepath: "test_collection-6106351684939824381-2023-04-06-20-43-03.snapshot"
313313
)
314-
expect(response.dig('status')).to eq('ok')
315-
expect(response.dig('result')).to eq(true)
314+
expect(response.dig("status")).to eq("ok")
315+
expect(response.dig("result")).to eq(true)
316316
end
317317
end
318318
end

0 commit comments

Comments
 (0)