predicsis_ml_sdk 0.3.1 → 0.4.0
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e55b4f098812ce79e77599cd388e0502cd0d3772
|
4
|
+
data.tar.gz: 7ea659bbdb0850bdddf69c132c03fa5517b76233
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 35ebefab33c0d30b75a274fdc719a71b432089cc31e839e6397ff15754c7828823ed8717fbd80c5c5cb0d1aff7bcdbc87a63cc6e58f49b183e5f2fc5b593542c
|
7
|
+
data.tar.gz: 7bfb8c00039e235d5cac7a92132a7b723284a8d4e9e03961b2f3c9bf36dc3ab9483f1948f74b165bb81b3faa5d40b2016913c7226a655b2978183ad536983267
|
@@ -11,10 +11,11 @@ module PredicsisMlSdk
|
|
11
11
|
class JobError < Error
|
12
12
|
attr_reader :job_id, :action
|
13
13
|
|
14
|
-
def initialize(
|
15
|
-
super(message, error)
|
14
|
+
def initialize(errors = nil, job_id = nil, action = nil)
|
16
15
|
@job_id = job_id
|
17
16
|
@action = action
|
17
|
+
@errors = errors
|
18
|
+
super(errors.map { |e| e['message'] }.join('. '), errors)
|
18
19
|
end
|
19
20
|
end
|
20
21
|
|
data/lib/predicsis_ml_sdk/job.rb
CHANGED
@@ -36,6 +36,11 @@ module PredicsisMlSdk
|
|
36
36
|
self
|
37
37
|
end
|
38
38
|
|
39
|
+
def next_job
|
40
|
+
return nil unless next_job_id
|
41
|
+
@next_job ||= Job.get(next_job_id, token)
|
42
|
+
end
|
43
|
+
|
39
44
|
def succeeded?
|
40
45
|
status.eql? 'completed'
|
41
46
|
end
|
@@ -47,5 +52,15 @@ module PredicsisMlSdk
|
|
47
52
|
def pending?
|
48
53
|
%w(pending processing).include? status
|
49
54
|
end
|
55
|
+
|
56
|
+
def terminated?
|
57
|
+
if failed?
|
58
|
+
fail JobError.new(errors, id, action)
|
59
|
+
elsif succeeded?
|
60
|
+
next_job ? next_job.terminated? : true
|
61
|
+
else
|
62
|
+
false
|
63
|
+
end
|
64
|
+
end
|
50
65
|
end
|
51
66
|
end
|
@@ -15,22 +15,13 @@ module PredicsisMlSdk
|
|
15
15
|
|
16
16
|
def terminated?
|
17
17
|
return true if @job_ids.empty?
|
18
|
-
|
19
|
-
fail JobError.new(job.error['message'], job.error, job.id, job.action)
|
20
|
-
else
|
21
|
-
return job.succeeded?
|
22
|
-
end
|
18
|
+
job.terminated?
|
23
19
|
end
|
24
20
|
|
25
21
|
def wait_for_result
|
26
22
|
return if @job_ids.empty?
|
27
|
-
sleep(1)
|
28
|
-
|
29
|
-
get
|
30
|
-
else
|
31
|
-
fail JobError.new(job.error['message'], job.error, job.id, job.action)
|
32
|
-
end
|
33
|
-
self
|
23
|
+
sleep(1) until job.terminated?
|
24
|
+
get
|
34
25
|
end
|
35
26
|
end
|
36
27
|
end
|
@@ -61,7 +61,7 @@ module PredicsisMlSdk
|
|
61
61
|
response = HTTParty.put(endpoint, body_stream: File.open(filename),
|
62
62
|
headers: { 'Content-Length' => File.size(filename).to_s })
|
63
63
|
if [200, 201, 204].include? response.code
|
64
|
-
params
|
64
|
+
params
|
65
65
|
else
|
66
66
|
fail RequestError.new(response['message'], JSON.parse(response.body))
|
67
67
|
end
|
@@ -104,9 +104,9 @@ module PredicsisMlSdk
|
|
104
104
|
end
|
105
105
|
|
106
106
|
MODELS.each do |model|
|
107
|
-
define_method("post_#{model}") do |token, params = {}|
|
107
|
+
define_method("post_#{model}") do |token, params = {}, other_params = {}|
|
108
108
|
PredicsisMlSdk.logger.debug "POST #{model.pluralize}"
|
109
|
-
params = { :"#{model}" => params }
|
109
|
+
params = { :"#{model}" => params }.merge(other_params)
|
110
110
|
response = post("#{api_host}/#{model.pluralize}", params.to_json, headers(token))
|
111
111
|
PredicsisMlSdk.logger.info("#{model}_id: #{response[model]['id']}")
|
112
112
|
response[model]
|
@@ -1,10 +1,12 @@
|
|
1
1
|
module PredicsisMlSdk
|
2
2
|
class Source
|
3
3
|
include Util
|
4
|
-
|
4
|
+
include JobStuff
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
attr_accessor :id, :token
|
7
|
+
|
8
|
+
def self.create(source_params = {}, data_store_params = {}, token = bearer_token)
|
9
|
+
data = Requests.post_source(token, source_params, data_store: data_store_params)
|
8
10
|
new(data['id'], token).tap do |source|
|
9
11
|
source.define_attributes(data)
|
10
12
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: predicsis_ml_sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Armand
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: json
|