Skip to content

Commit

Permalink
Merge pull request #1 from andreibondarev/andreibondarev-patch-1
Browse files Browse the repository at this point in the history
Trigger the specs
  • Loading branch information
andreibondarev authored Apr 21, 2023
2 parents b8a44ef + 172e1bb commit b0ed55a
Show file tree
Hide file tree
Showing 18 changed files with 85 additions and 57 deletions.
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ gemspec
gem "rake", "~> 13.0"

gem "rspec", "~> 3.0"
gem "standard", "~> 1.27.0"
32 changes: 32 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,30 @@ PATH
GEM
remote: https://rubygems.org/
specs:
ast (2.4.2)
byebug (11.1.3)
coderay (1.1.3)
diff-lcs (1.5.0)
faraday (2.7.4)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
json (2.6.3)
language_server-protocol (3.17.0.3)
method_source (1.0.0)
parallel (1.23.0)
parser (3.2.2.0)
ast (~> 2.4.1)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
pry-byebug (3.10.1)
byebug (~> 11.0)
pry (>= 0.13, < 0.15)
rainbow (3.1.1)
rake (13.0.6)
regexp_parser (2.8.0)
rexml (3.2.5)
rspec (3.12.0)
rspec-core (~> 3.12.0)
rspec-expectations (~> 3.12.0)
Expand All @@ -35,17 +44,40 @@ GEM
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-support (3.12.0)
rubocop (1.50.2)
json (~> 2.3)
parallel (~> 1.10)
parser (>= 3.2.0.0)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 1.8, < 3.0)
rexml (>= 3.2.5, < 4.0)
rubocop-ast (>= 1.28.0, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.28.0)
parser (>= 3.2.1.0)
rubocop-performance (1.16.0)
rubocop (>= 1.7.0, < 2.0)
rubocop-ast (>= 0.4.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
standard (1.27.0)
language_server-protocol (~> 3.17.0.2)
rubocop (~> 1.50.2)
rubocop-performance (~> 1.16.0)
unicode-display_width (2.4.2)

PLATFORMS
x86_64-darwin-19
x86_64-darwin-22
x86_64-linux

DEPENDENCIES
milvus!
pry-byebug (~> 3.10.0)
rake (~> 13.0)
rspec (~> 3.0)
standard (~> 1.27.0)

BUNDLED WITH
2.4.0
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ client.entities.compact!(
collection_id: "book"
)
# => {"status"=>{}, "compactionID"=>440928616022809499}

```
```ruby
# Check compaction status
client.entities.compact_status(
compaction_id: 440928616022809499
Expand Down
2 changes: 1 addition & 1 deletion lib/milvus/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ module Milvus
class Client
attr_reader :url, :api_key

API_VERSION = "api/v1".freeze
API_VERSION = "api/v1"

def initialize(
url:,
Expand Down
2 changes: 1 addition & 1 deletion lib/milvus/collections.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Milvus
class Collections < Base
PATH = "collection".freeze
PATH = "collection"

# Create a Collection
def create(
Expand Down
2 changes: 1 addition & 1 deletion lib/milvus/constants.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ module Milvus
"binary_vector" => 101,
"float_vector" => 102
}.freeze
end
end
4 changes: 2 additions & 2 deletions lib/milvus/entities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Milvus
class Entities < Base
PATH = "entities".freeze
PATH = "entities"

# Insert the data to the collection.
def insert(
Expand All @@ -18,7 +18,7 @@ def insert(
num_rows: num_rows
}.to_json

req.body['partition_name'] = partition_name if partition_name
req.body["partition_name"] = partition_name if partition_name
end
response.body.empty? ? true : response.body
end
Expand Down
2 changes: 1 addition & 1 deletion lib/milvus/health.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Milvus
class Health < Base
PATH = "health".freeze
PATH = "health"

def get
response = client.connection.get(PATH.to_s)
Expand Down
2 changes: 1 addition & 1 deletion lib/milvus/indices.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Milvus
class Indices < Base
PATH = "index".freeze
PATH = "index"

def create(
collection_name:,
Expand Down
2 changes: 1 addition & 1 deletion lib/milvus/partitions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Milvus
class Partitions < Base
PATH = "partition".freeze
PATH = "partition"

# Create a partition
def create(collection_name:, partition_name:)
Expand Down
2 changes: 1 addition & 1 deletion lib/milvus/query.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module Milvus
class Query < Base
PATH = "query".freeze
PATH = "query"

def post(
collection_name:,
Expand Down
22 changes: 8 additions & 14 deletions lib/milvus/search.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,28 @@

module Milvus
class Search < Base
PATH = "search".freeze
PATH = "search"

def post(
collection_name:,
output_fields: nil,
anns_field:,
top_k:,
params:,
metric_type:,
round_decimal: nil,
vectors:,
dsl_type:
anns_field:, top_k:, params:, metric_type:, vectors:, dsl_type:, output_fields: nil,
round_decimal: nil
)
response = client.connection.post(PATH) do |req|
req.body = {
collection_name: collection_name,
search_params: [
{ key: "anns_field", value: anns_field },
{ key: "topk", value: top_k },
{ key: "params", value: params },
{ key: "metric_type", value: metric_type },
{key: "anns_field", value: anns_field},
{key: "topk", value: top_k},
{key: "params", value: params},
{key: "metric_type", value: metric_type}
],
dsl_type: dsl_type,
vectors: vectors
}
if round_decimal
req.body[:search_params].push(
{ key: "round_decimal", value: round_decimal }
{key: "round_decimal", value: round_decimal}
)
end
if output_fields
Expand Down
2 changes: 1 addition & 1 deletion lib/milvus/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# frozen_string_literal: true

module Milvus
VERSION = "0.9.0".freeze
VERSION = "0.9.0"
end
32 changes: 16 additions & 16 deletions spec/milvus/collections_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,27 +28,27 @@
auto_id: false,
fields: [
{
"name": "book_id",
"description": "book id",
"is_primary_key": true,
"autoID": false,
"data_type": Milvus::DATA_TYPES["int64"]
name: "book_id",
description: "book id",
is_primary_key: true,
autoID: false,
data_type: Milvus::DATA_TYPES["int64"]
},
{
"name": "word_count",
"description": "count of words",
"is_primary_key": false,
"data_type": Milvus::DATA_TYPES["int64"]
name: "word_count",
description: "count of words",
is_primary_key: false,
data_type: Milvus::DATA_TYPES["int64"]
},
{
"name": "book_intro",
"description": "embedded vector of book introduction",
"data_type": Milvus::DATA_TYPES["binary_vector"],
"is_primary_key": false,
"type_params": [
name: "book_intro",
description: "embedded vector of book introduction",
data_type: Milvus::DATA_TYPES["binary_vector"],
is_primary_key: false,
type_params: [
{
"key": "dim",
"value": "2"
key: "dim",
value: "2"
}
]
}
Expand Down
20 changes: 10 additions & 10 deletions spec/milvus/entities_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@
num_rows: 5,
fields_data: [
{
"field_name": "book_id",
"type": Milvus::DATA_TYPES["int64"],
"field": [1,2,3,4,5]
field_name: "book_id",
type: Milvus::DATA_TYPES["int64"],
field: [1, 2, 3, 4, 5]
},
{
"field_name": "word_count",
"type": Milvus::DATA_TYPES["int64"],
"field": [1000,2000,3000,4000,5000]
field_name: "word_count",
type: Milvus::DATA_TYPES["int64"],
field: [1000, 2000, 3000, 4000, 5000]
},
{
"field_name": "book_intro",
"type": 101,
"field": [ [1,1],[2,1],[3,1],[4,1],[5,1] ]
field_name: "book_intro",
type: 101,
field: [[1, 1], [2, 1], [3, 1], [4, 1], [5, 1]]
}
]
]
)
expect(response).to eq(entities_created_fixture)
end
Expand Down
8 changes: 4 additions & 4 deletions spec/milvus/indices_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
collection_name: "book",
field_name: "book_intro",
extra_params: [
{ key: "metric_type", "value": "L2" },
{ key: "index_type", "value": "IVF_FLAT" },
{ key: "params", "value": "{\"nlist\":1024}" }
{key: "metric_type", value: "L2"},
{key: "index_type", value: "IVF_FLAT"},
{key: "params", value: "{\"nlist\":1024}"}
]
)
expect(response).to eq(true)
Expand All @@ -52,4 +52,4 @@
expect(response).to eq(true)
end
end
end
end
2 changes: 1 addition & 1 deletion spec/milvus/query_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@
expect(response).to eq(true)
end
end
end
end
2 changes: 1 addition & 1 deletion spec/milvus/search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
params: "{\"nprobe\": 10}",
metric_type: "L2",
round_decimal: "-1",
vectors: [ [0.1,0.2] ],
vectors: [[0.1, 0.2]],
dsl_type: 1
)
expect(response).to eq(search_result)
Expand Down

0 comments on commit b0ed55a

Please sign in to comment.