milvus 0.10.1 β 0.10.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +71 -0
- data/docker-compose.yml +77 -0
- data/lib/milvus/aliases.rb +78 -0
- data/lib/milvus/client.rb +26 -3
- data/lib/milvus/roles.rb +32 -0
- data/lib/milvus/users.rb +96 -0
- data/lib/milvus/version.rb +1 -1
- data/lib/milvus.rb +3 -0
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 914040de2cf35a3985d67dbd19de618e00d82262b61220df8bbf517cee40f72f
|
4
|
+
data.tar.gz: d88ca74f1a6674cefadd0d790b3a3c828da1f2e585a2cd9b4d3fa9dca492115a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5092e0ec3696ce6d8e8a7a9d8df199f32f9ef4172f3aa65e0d415312da019c47763beef7df1e4714e3adee53f806f0bfd79f35e99884d8df8abb5745755f73a1
|
7
|
+
data.tar.gz: 9580e92290a0a3f132b39629ff4bc25ef759b7b2d608cf744218bd529e9e54ac328194584db757af76b56f03790793468e9e6b6bebadc173301403fb17fc52bc
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,14 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.10.3] - 2024-10-01
|
4
|
+
- Weaviate::Client constructor accepts customer logger: to be passed in
|
5
|
+
- Added Alias management
|
6
|
+
|
7
|
+
## [0.10.2] - 2024-07-28
|
8
|
+
- Added Roles management
|
9
|
+
- Added Users management
|
10
|
+
- Added docker-compose.yml with directions to run Milvus in Docker
|
11
|
+
|
3
12
|
## [0.10.1] - 2024-07-04 πΊπΈ
|
4
13
|
- Fixes and improvements to the gem.
|
5
14
|
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -267,12 +267,83 @@ client.partitions.drop(
|
|
267
267
|
)
|
268
268
|
```
|
269
269
|
|
270
|
+
### Roles
|
271
|
+
```ruby
|
272
|
+
# List roles available on the server
|
273
|
+
client.roles.list
|
274
|
+
```
|
275
|
+
```ruby
|
276
|
+
# Describe the role
|
277
|
+
client.roles.describe(role_name: 'public')
|
278
|
+
```
|
279
|
+
|
280
|
+
### Users
|
281
|
+
```ruby
|
282
|
+
# Create new user
|
283
|
+
client.users.create(user_name: 'user_name', password: 'password')
|
284
|
+
```
|
285
|
+
```ruby
|
286
|
+
# List of roles assigned to the user
|
287
|
+
client.users.describe(user_name: 'user_name')
|
288
|
+
```
|
289
|
+
```ruby
|
290
|
+
# List all users in the specified database.
|
291
|
+
client.users.list
|
292
|
+
```
|
293
|
+
```ruby
|
294
|
+
# Drop existing user
|
295
|
+
client.users.drop(user_name: 'user_name')
|
296
|
+
```
|
297
|
+
```ruby
|
298
|
+
# Update password for the user
|
299
|
+
client.users.update_password(user_name: 'user_name', password: 'old_password', new_password: 'new_password')
|
300
|
+
```
|
301
|
+
```ruby
|
302
|
+
# Grant role to the user
|
303
|
+
client.users.grant_role(user_name: 'user_name', role_name: 'admin')
|
304
|
+
```
|
305
|
+
```ruby
|
306
|
+
# Revoke role from the user
|
307
|
+
client.users.revoke_role(user_name: 'user_name', role_name: 'admin')
|
308
|
+
```
|
309
|
+
### Aliases
|
310
|
+
```ruby
|
311
|
+
# Lists all existing collection aliases in the specified database
|
312
|
+
client.aliases.list
|
313
|
+
```
|
314
|
+
```ruby
|
315
|
+
# Describes the details of a specific alias
|
316
|
+
client.aliases.describe
|
317
|
+
```
|
318
|
+
```ruby
|
319
|
+
# Reassigns the alias of one collection to another.
|
320
|
+
client.aliases.alter
|
321
|
+
```
|
322
|
+
```ruby
|
323
|
+
# Drops a specified alias
|
324
|
+
client.aliases.drop
|
325
|
+
```
|
326
|
+
```ruby
|
327
|
+
# Creates an alias for an existing collection
|
328
|
+
client.aliases.create
|
329
|
+
```
|
330
|
+
|
270
331
|
## Development
|
271
332
|
|
272
333
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
273
334
|
|
274
335
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
275
336
|
|
337
|
+
## Development with Docker
|
338
|
+
|
339
|
+
Run `docker compose run --rm ruby_app bash` and install required gems (`bundle install`). It will give you a fully working development environment with Milvus services and gem's code.
|
340
|
+
|
341
|
+
For example inside docker container run `bin/console` and inside the ruby console:
|
342
|
+
```ruby
|
343
|
+
client = Milvus::Client.new(url: ENV["MILVUS_URL"])
|
344
|
+
client.collections.list
|
345
|
+
```
|
346
|
+
|
276
347
|
## Contributing
|
277
348
|
|
278
349
|
Bug reports and pull requests are welcome on GitHub at https://github.com/patterns-ai-core/milvus.
|
data/docker-compose.yml
ADDED
@@ -0,0 +1,77 @@
|
|
1
|
+
services:
|
2
|
+
ruby_app:
|
3
|
+
image: ruby:bullseye
|
4
|
+
working_dir: /usr/src/app
|
5
|
+
volumes:
|
6
|
+
- .:/usr/src/app
|
7
|
+
- bundle:/usr/local/bundle
|
8
|
+
depends_on:
|
9
|
+
- standalone
|
10
|
+
environment:
|
11
|
+
MILVUS_URL: "http://standalone:19530"
|
12
|
+
|
13
|
+
etcd:
|
14
|
+
container_name: milvus-etcd
|
15
|
+
image: quay.io/coreos/etcd:v3.5.5
|
16
|
+
environment:
|
17
|
+
- ETCD_AUTO_COMPACTION_MODE=revision
|
18
|
+
- ETCD_AUTO_COMPACTION_RETENTION=1000
|
19
|
+
- ETCD_QUOTA_BACKEND_BYTES=4294967296
|
20
|
+
- ETCD_SNAPSHOT_COUNT=50000
|
21
|
+
volumes:
|
22
|
+
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/etcd:/etcd
|
23
|
+
command: etcd -advertise-client-urls=http://127.0.0.1:2379 -listen-client-urls http://0.0.0.0:2379 --data-dir /etcd
|
24
|
+
healthcheck:
|
25
|
+
test: ["CMD", "etcdctl", "endpoint", "health"]
|
26
|
+
interval: 30s
|
27
|
+
timeout: 20s
|
28
|
+
retries: 3
|
29
|
+
|
30
|
+
minio:
|
31
|
+
container_name: milvus-minio
|
32
|
+
image: minio/minio:RELEASE.2023-03-20T20-16-18Z
|
33
|
+
environment:
|
34
|
+
MINIO_ACCESS_KEY: minioadmin
|
35
|
+
MINIO_SECRET_KEY: minioadmin
|
36
|
+
ports:
|
37
|
+
- "9001:9001"
|
38
|
+
- "9000:9000"
|
39
|
+
volumes:
|
40
|
+
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/minio:/minio_data
|
41
|
+
command: minio server /minio_data --console-address ":9001"
|
42
|
+
healthcheck:
|
43
|
+
test: ["CMD", "curl", "-f", "http://localhost:9000/minio/health/live"]
|
44
|
+
interval: 30s
|
45
|
+
timeout: 20s
|
46
|
+
retries: 3
|
47
|
+
|
48
|
+
standalone:
|
49
|
+
container_name: milvus-standalone
|
50
|
+
image: milvusdb/milvus:v2.4.5
|
51
|
+
command: ["milvus", "run", "standalone"]
|
52
|
+
security_opt:
|
53
|
+
- seccomp:unconfined
|
54
|
+
environment:
|
55
|
+
ETCD_ENDPOINTS: etcd:2379
|
56
|
+
MINIO_ADDRESS: minio:9000
|
57
|
+
volumes:
|
58
|
+
- ${DOCKER_VOLUME_DIRECTORY:-.}/volumes/milvus:/var/lib/milvus
|
59
|
+
healthcheck:
|
60
|
+
test: ["CMD", "curl", "-f", "http://localhost:9091/healthz"]
|
61
|
+
interval: 30s
|
62
|
+
start_period: 90s
|
63
|
+
timeout: 20s
|
64
|
+
retries: 3
|
65
|
+
ports:
|
66
|
+
- "19530:19530"
|
67
|
+
- "9091:9091"
|
68
|
+
depends_on:
|
69
|
+
- "etcd"
|
70
|
+
- "minio"
|
71
|
+
|
72
|
+
networks:
|
73
|
+
default:
|
74
|
+
name: milvus
|
75
|
+
|
76
|
+
volumes:
|
77
|
+
bundle:
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# https://docs.zilliz.com/reference/restful/alias-operations-v2
|
2
|
+
|
3
|
+
module Milvus
|
4
|
+
class Aliases < Base
|
5
|
+
PATH = "aliases"
|
6
|
+
|
7
|
+
# Lists available roles on the server
|
8
|
+
#
|
9
|
+
# @return [Hash] The response from the server
|
10
|
+
def list
|
11
|
+
response = client.connection.post("#{PATH}/list") do |req|
|
12
|
+
req.body = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
response.body
|
16
|
+
end
|
17
|
+
|
18
|
+
# Describes the details of a specific alias
|
19
|
+
#
|
20
|
+
# @param alias_name [String] The name of the alias to describe
|
21
|
+
# @return [Hash] The response from the server
|
22
|
+
def describe(alias_name:)
|
23
|
+
response = client.connection.post("#{PATH}/describe") do |req|
|
24
|
+
req.body = {
|
25
|
+
aliasName: alias_name
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
response.body
|
30
|
+
end
|
31
|
+
|
32
|
+
# Reassigns the alias of one collection to another
|
33
|
+
#
|
34
|
+
# @param alias_name [String] The alias of the collection
|
35
|
+
# @param collection_name [String] The name of the target collection to reassign an alias to
|
36
|
+
# @return [Hash] The response from the server
|
37
|
+
def alter(alias_name:, collection_name:)
|
38
|
+
response = client.connection.post("#{PATH}/alter") do |req|
|
39
|
+
req.body = {
|
40
|
+
aliasName: alias_name,
|
41
|
+
collectionName: collection_name
|
42
|
+
}
|
43
|
+
end
|
44
|
+
|
45
|
+
response.body
|
46
|
+
end
|
47
|
+
|
48
|
+
# This operation drops a specified alias
|
49
|
+
#
|
50
|
+
# @param alias_name [String] The alias to drop
|
51
|
+
# @return [Hash] The response from the server
|
52
|
+
def drop(alias_name:)
|
53
|
+
response = client.connection.post("#{PATH}/drop") do |req|
|
54
|
+
req.body = {
|
55
|
+
aliasName: alias_name
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
response.body
|
60
|
+
end
|
61
|
+
|
62
|
+
# This operation creates an alias for an existing collection. A collection can have multiple aliases, while an alias can be associated with only one collection.
|
63
|
+
#
|
64
|
+
# @param alias_name [String] The alias of the collection
|
65
|
+
# @param collection_name [String] The name of the target collection to reassign an alias to
|
66
|
+
# @return [Hash] The response from the server
|
67
|
+
def create(alias_name:, collection_name:)
|
68
|
+
response = client.connection.post("#{PATH}/create") do |req|
|
69
|
+
req.body = {
|
70
|
+
aliasName: alias_name,
|
71
|
+
collectionName: collection_name
|
72
|
+
}
|
73
|
+
end
|
74
|
+
|
75
|
+
response.body
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
data/lib/milvus/client.rb
CHANGED
@@ -4,13 +4,22 @@ require "faraday"
|
|
4
4
|
|
5
5
|
module Milvus
|
6
6
|
class Client
|
7
|
-
attr_reader :url, :api_key
|
7
|
+
attr_reader :url, :api_key, :adapter, :raise_error, :logger
|
8
8
|
|
9
9
|
API_VERSION = "v2/vectordb"
|
10
10
|
|
11
|
-
def initialize(
|
11
|
+
def initialize(
|
12
|
+
url:,
|
13
|
+
api_key: nil,
|
14
|
+
adapter: Faraday.default_adapter,
|
15
|
+
raise_error: false,
|
16
|
+
logger: nil
|
17
|
+
)
|
12
18
|
@url = url
|
13
19
|
@api_key = api_key
|
20
|
+
@adapter = adapter
|
21
|
+
@raise_error = raise_error
|
22
|
+
@logger = logger || Logger.new($stdout)
|
14
23
|
end
|
15
24
|
|
16
25
|
def collections
|
@@ -29,14 +38,28 @@ module Milvus
|
|
29
38
|
@indexes ||= Milvus::Indexes.new(client: self)
|
30
39
|
end
|
31
40
|
|
41
|
+
def roles
|
42
|
+
@roles ||= Milvus::Roles.new(client: self)
|
43
|
+
end
|
44
|
+
|
45
|
+
def users
|
46
|
+
@users ||= Milvus::Users.new(client: self)
|
47
|
+
end
|
48
|
+
|
49
|
+
def aliases
|
50
|
+
@aliases ||= Milvus::Aliases.new(client: self)
|
51
|
+
end
|
52
|
+
|
32
53
|
def connection
|
33
54
|
@connection ||= Faraday.new(url: "#{url}/#{API_VERSION}/") do |faraday|
|
34
55
|
if api_key
|
35
56
|
faraday.request :authorization, :Bearer, api_key
|
36
57
|
end
|
37
58
|
faraday.request :json
|
59
|
+
faraday.response :logger, logger, {headers: true, bodies: true, errors: true}
|
60
|
+
faraday.response :raise_error if raise_error
|
38
61
|
faraday.response :json, content_type: /\bjson$/
|
39
|
-
faraday.adapter
|
62
|
+
faraday.adapter adapter
|
40
63
|
end
|
41
64
|
end
|
42
65
|
end
|
data/lib/milvus/roles.rb
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Milvus
|
4
|
+
class Roles < Base
|
5
|
+
PATH = "roles"
|
6
|
+
|
7
|
+
# Lists available roles on the server
|
8
|
+
#
|
9
|
+
# @return [Hash] The response from the server.
|
10
|
+
def list
|
11
|
+
response = client.connection.post("#{PATH}/list") do |req|
|
12
|
+
req.body = {}
|
13
|
+
end
|
14
|
+
|
15
|
+
response.body
|
16
|
+
end
|
17
|
+
|
18
|
+
# This operation inserts data into a specific collection.
|
19
|
+
#
|
20
|
+
# @param role_name [String] The name of the collection to insert data into.
|
21
|
+
# @return [Hash] The response from the server.
|
22
|
+
def describe(role_name:)
|
23
|
+
response = client.connection.post("#{PATH}/describe") do |req|
|
24
|
+
req.body = {
|
25
|
+
roleName: role_name
|
26
|
+
}
|
27
|
+
end
|
28
|
+
|
29
|
+
response.body
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/milvus/users.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Milvus
|
4
|
+
class Users < Base
|
5
|
+
PATH = "users"
|
6
|
+
|
7
|
+
# Create a user
|
8
|
+
#
|
9
|
+
# @param user_name [String] Username for the user
|
10
|
+
# @param password [String] Password for the user
|
11
|
+
# @return [Hash] Server response
|
12
|
+
def create(user_name:, password:)
|
13
|
+
response = client.connection.post("#{PATH}/create") do |req|
|
14
|
+
req.body = {
|
15
|
+
userName: user_name,
|
16
|
+
password: password
|
17
|
+
}
|
18
|
+
end
|
19
|
+
|
20
|
+
response.body
|
21
|
+
end
|
22
|
+
|
23
|
+
# Describe a user
|
24
|
+
#
|
25
|
+
# @param user_name [String] Username for the user
|
26
|
+
# @return [Hash] Server response
|
27
|
+
def describe(user_name:)
|
28
|
+
response = client.connection.post("#{PATH}/describe") do |req|
|
29
|
+
req.body = {
|
30
|
+
userName: user_name
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
response.body
|
35
|
+
end
|
36
|
+
|
37
|
+
# List users
|
38
|
+
#
|
39
|
+
# @return [Hash] Server response
|
40
|
+
def list
|
41
|
+
response = client.connection.post("#{PATH}/list") do |req|
|
42
|
+
req.body = {}
|
43
|
+
end
|
44
|
+
|
45
|
+
response.body
|
46
|
+
end
|
47
|
+
|
48
|
+
# Drops a user
|
49
|
+
#
|
50
|
+
# @param user_name [String] Username for the user
|
51
|
+
# @return [Hash] Server response
|
52
|
+
def drop(user_name:)
|
53
|
+
response = client.connection.post("#{PATH}/drop") do |req|
|
54
|
+
req.body = {
|
55
|
+
userName: user_name
|
56
|
+
}
|
57
|
+
end
|
58
|
+
|
59
|
+
response.body
|
60
|
+
end
|
61
|
+
|
62
|
+
def update_password(user_name:, password:, new_password:)
|
63
|
+
response = client.connection.post("#{PATH}/update_password") do |req|
|
64
|
+
req.body = {
|
65
|
+
userName: user_name,
|
66
|
+
password: password,
|
67
|
+
newPassword: new_password
|
68
|
+
}
|
69
|
+
end
|
70
|
+
|
71
|
+
response.body
|
72
|
+
end
|
73
|
+
|
74
|
+
def grant_role(user_name:, role_name:)
|
75
|
+
response = client.connection.post("#{PATH}/grant_role") do |req|
|
76
|
+
req.body = {
|
77
|
+
userName: user_name,
|
78
|
+
roleName: role_name
|
79
|
+
}
|
80
|
+
end
|
81
|
+
|
82
|
+
response.body
|
83
|
+
end
|
84
|
+
|
85
|
+
def revoke_role(user_name:, role_name:)
|
86
|
+
response = client.connection.post("#{PATH}/revoke_role") do |req|
|
87
|
+
req.body = {
|
88
|
+
userName: user_name,
|
89
|
+
roleName: role_name
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
93
|
+
response.body
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
data/lib/milvus/version.rb
CHANGED
data/lib/milvus.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: milvus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.10.
|
4
|
+
version: 0.10.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrei Bondarev
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry-byebug
|
@@ -60,7 +60,9 @@ files:
|
|
60
60
|
- LICENSE
|
61
61
|
- README.md
|
62
62
|
- Rakefile
|
63
|
+
- docker-compose.yml
|
63
64
|
- lib/milvus.rb
|
65
|
+
- lib/milvus/aliases.rb
|
64
66
|
- lib/milvus/base.rb
|
65
67
|
- lib/milvus/client.rb
|
66
68
|
- lib/milvus/collections.rb
|
@@ -69,6 +71,8 @@ files:
|
|
69
71
|
- lib/milvus/error.rb
|
70
72
|
- lib/milvus/indexes.rb
|
71
73
|
- lib/milvus/partitions.rb
|
74
|
+
- lib/milvus/roles.rb
|
75
|
+
- lib/milvus/users.rb
|
72
76
|
- lib/milvus/version.rb
|
73
77
|
- sig/milvus.rbs
|
74
78
|
homepage: https://github.com/andreibondarev/milvus
|
@@ -93,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
93
97
|
- !ruby/object:Gem::Version
|
94
98
|
version: '0'
|
95
99
|
requirements: []
|
96
|
-
rubygems_version: 3.5.
|
100
|
+
rubygems_version: 3.5.20
|
97
101
|
signing_key:
|
98
102
|
specification_version: 4
|
99
103
|
summary: Ruby wrapper for the Milvus vector search database API
|