replicate-client 0.1.3 → 0.1.5
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/Gemfile.lock +1 -1
- data/LICENSE +21 -0
- data/lib/replicate-client/training.rb +40 -11
- data/lib/replicate-client/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f066662aa759a5881284f5008568d092d3ec28b8cbc1d87a2221c42a6c6fd4d4
|
4
|
+
data.tar.gz: ced72f79a1601dd5c0702e726d508c7226130de8c92b890df6e55fbaeeeb5552
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ba457621a0fdfc737c83a5e632abe315735fa45bcf792dab468a2d620aed526012a4f49c06bc43451c1d7702064b596d1ae32c9af07765295a54bd3b78f7017
|
7
|
+
data.tar.gz: a3dcf6a0153b84b7c44b0137dee34072e3d0ca89b5127cf12d96ba8e4edac14488a178c931034879b6444fc21fb8862c2472fad9a9a3f40071fca59559a7e727
|
data/Gemfile.lock
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2024 851 Inc.
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
@@ -42,11 +42,11 @@ module ReplicateClient
|
|
42
42
|
# @param destination [ReplicateClient::Model, String] The destination model instance or string in "owner/name"
|
43
43
|
# format.
|
44
44
|
# @param input [Hash] The input data for the training.
|
45
|
-
# @param
|
45
|
+
# @param webhook_url [String, nil] A URL to receive webhook notifications.
|
46
46
|
# @param webhook_events_filter [Array, nil] The events to trigger webhook requests.
|
47
47
|
#
|
48
48
|
# @return [ReplicateClient::Training]
|
49
|
-
def create!(owner:, name:, version:, destination:, input:,
|
49
|
+
def create!(owner:, name:, version:, destination:, input:, webhook_url: nil, webhook_events_filter: nil)
|
50
50
|
destination_str = destination.is_a?(ReplicateClient::Model) ? destination.full_name : destination
|
51
51
|
version_id = version.is_a?(ReplicateClient::Model::Version) ? version.id : version
|
52
52
|
|
@@ -54,7 +54,7 @@ module ReplicateClient
|
|
54
54
|
body = {
|
55
55
|
destination: destination_str,
|
56
56
|
input: input,
|
57
|
-
webhook:
|
57
|
+
webhook: webhook_url || ReplicateClient.configuration.webhook_url,
|
58
58
|
webhook_events_filter: webhook_events_filter
|
59
59
|
}
|
60
60
|
|
@@ -67,11 +67,11 @@ module ReplicateClient
|
|
67
67
|
# @param model [ReplicateClient::Model, String] The model instance or a string representing the model ID.
|
68
68
|
# @param destination [ReplicateClient::Model, String] The destination model or full name in "owner/name" format.
|
69
69
|
# @param input [Hash] The input data for the training.
|
70
|
-
# @param
|
70
|
+
# @param webhook_url [String, nil] A URL to receive webhook notifications.
|
71
71
|
# @param webhook_events_filter [Array, nil] The events to trigger webhook requests.
|
72
72
|
#
|
73
73
|
# @return [ReplicateClient::Training]
|
74
|
-
def create_for_model!(model:, destination:, input:,
|
74
|
+
def create_for_model!(model:, destination:, input:, webhook_url: nil, webhook_events_filter: nil)
|
75
75
|
model_instance = model.is_a?(ReplicateClient::Model) ? model : ReplicateClient::Model.find(model)
|
76
76
|
raise ArgumentError, "Invalid model" unless model_instance
|
77
77
|
|
@@ -81,7 +81,7 @@ module ReplicateClient
|
|
81
81
|
version: model_instance.version_id,
|
82
82
|
destination: destination,
|
83
83
|
input: input,
|
84
|
-
webhook:
|
84
|
+
webhook: webhook_url || ReplicateClient.configuration.webhook_url,
|
85
85
|
webhook_events_filter: webhook_events_filter
|
86
86
|
)
|
87
87
|
end
|
@@ -125,12 +125,12 @@ module ReplicateClient
|
|
125
125
|
# The full model name in the format "owner/name".
|
126
126
|
#
|
127
127
|
# @return [String]
|
128
|
-
attr_accessor :
|
128
|
+
attr_accessor :model_full_name
|
129
129
|
|
130
130
|
# The version ID of the model being trained.
|
131
131
|
#
|
132
132
|
# @return [String]
|
133
|
-
attr_accessor :
|
133
|
+
attr_accessor :version_id
|
134
134
|
|
135
135
|
# The input data provided for the training.
|
136
136
|
#
|
@@ -150,9 +150,14 @@ module ReplicateClient
|
|
150
150
|
|
151
151
|
# The timestamp when the training was completed.
|
152
152
|
#
|
153
|
-
# @return [
|
153
|
+
# @return [Time, nil]
|
154
154
|
attr_accessor :completed_at
|
155
155
|
|
156
|
+
# The timestamp when the training was started.
|
157
|
+
#
|
158
|
+
# @return [Time, nil]
|
159
|
+
attr_accessor :started_at
|
160
|
+
|
156
161
|
# The logs generated during the training process.
|
157
162
|
#
|
158
163
|
# @return [String]
|
@@ -173,6 +178,11 @@ module ReplicateClient
|
|
173
178
|
# @return [Hash, nil]
|
174
179
|
attr_accessor :output
|
175
180
|
|
181
|
+
# The metrics generated during the training process.
|
182
|
+
#
|
183
|
+
# @return [Hash, nil]
|
184
|
+
attr_accessor :metrics
|
185
|
+
|
176
186
|
# Initialize a new training instance.
|
177
187
|
#
|
178
188
|
# @param attributes [Hash] The attributes of the training.
|
@@ -232,6 +242,20 @@ module ReplicateClient
|
|
232
242
|
reset_attributes(attributes)
|
233
243
|
end
|
234
244
|
|
245
|
+
# The model instance of the training.
|
246
|
+
#
|
247
|
+
# @return [ReplicateClient::Model]
|
248
|
+
def model
|
249
|
+
@model ||= ReplicateClient::Model.find(model_full_name, version_id: version_id)
|
250
|
+
end
|
251
|
+
|
252
|
+
# The version instance of the training.
|
253
|
+
#
|
254
|
+
# @return [ReplicateClient::Model::Version]
|
255
|
+
def version
|
256
|
+
@version ||= model.version
|
257
|
+
end
|
258
|
+
|
235
259
|
private
|
236
260
|
|
237
261
|
# Set the attributes of the training.
|
@@ -241,8 +265,8 @@ module ReplicateClient
|
|
241
265
|
# @return [void]
|
242
266
|
def reset_attributes(attributes)
|
243
267
|
@id = attributes["id"]
|
244
|
-
@
|
245
|
-
@
|
268
|
+
@model_full_name = attributes["model"]
|
269
|
+
@version_id = attributes["version"]
|
246
270
|
@input = attributes["input"]
|
247
271
|
@status = attributes["status"]
|
248
272
|
@created_at = attributes["created_at"]
|
@@ -251,6 +275,11 @@ module ReplicateClient
|
|
251
275
|
@error = attributes["error"]
|
252
276
|
@urls = attributes["urls"]
|
253
277
|
@output = attributes["output"]
|
278
|
+
@started_at = attributes["started_at"]
|
279
|
+
@metrics = attributes["metrics"]
|
280
|
+
|
281
|
+
@model = nil
|
282
|
+
@version = nil
|
254
283
|
end
|
255
284
|
end
|
256
285
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: replicate-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dylan Player
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-08-
|
11
|
+
date: 2024-08-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -35,6 +35,7 @@ files:
|
|
35
35
|
- ".ruby-version"
|
36
36
|
- Gemfile
|
37
37
|
- Gemfile.lock
|
38
|
+
- LICENSE
|
38
39
|
- README.md
|
39
40
|
- Rakefile
|
40
41
|
- lib/replicate-client.rb
|