nexosis_api 1.3.0 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nexosis_api/calendar_jointarget.rb +1 -0
- data/lib/nexosis_api/client/datasets.rb +15 -7
- data/lib/nexosis_api/client/imports.rb +15 -4
- data/lib/nexosis_api/client/models.rb +7 -6
- data/lib/nexosis_api/client/sessions.rb +20 -15
- data/lib/nexosis_api/client/views.rb +4 -6
- data/lib/nexosis_api/client.rb +1 -0
- data/lib/nexosis_api/column.rb +1 -0
- data/lib/nexosis_api/column_options.rb +1 -0
- data/lib/nexosis_api/dataset_jointarget.rb +1 -0
- data/lib/nexosis_api/join.rb +2 -0
- data/lib/nexosis_api/paged_array.rb +35 -0
- data/lib/nexosis_api/session.rb +37 -14
- data/lib/nexosis_api/view_definition.rb +1 -0
- data/nexosisapi.gemspec +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7c526af7e9fcefc72090c15c425122bdcb1d84ad
|
4
|
+
data.tar.gz: d8b6c9a510f6c709f1d30cf4a7e63bd9864730cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbfdbdc1f4da07c9ce8c88c7410ac483929ab07cd298906a31fb60395d5ed39a71c7609d3d69a705c2fba12c39de2102d8420d47ea3077efb6d20e4191e9232d
|
7
|
+
data.tar.gz: c17bdd00ea6712696f731b46193bcb6cd16f9a0f32bbe2c4cbb9e8fb8542e98ae8b13d21fbca517ddbb80c4892380b838215429a407eacbdaa076a51bcc0d0b2
|
@@ -29,14 +29,22 @@ module NexosisApi
|
|
29
29
|
# Gets the list of data sets that have been saved to the system, optionally filtering by partial name match.
|
30
30
|
#
|
31
31
|
# @param partial_name [String] if provided, all datasets returned will contain this string
|
32
|
-
# @
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
# @param page [int] page number for items in list
|
33
|
+
# @param page_size [int] number of items in each page
|
34
|
+
# @return [NexosisApi::PagedArray of NexosisApi::DatasetSummary] array of datasets found
|
35
|
+
# @since 1.4 - added paging parameters
|
36
|
+
def list_datasets(partial_name = '', page = 0, page_size = 50)
|
37
|
+
list_dataset_url = '/data'
|
38
|
+
query = {
|
39
|
+
page: page,
|
40
|
+
pageSize: page_size
|
41
|
+
}
|
42
|
+
query['partialName'] = partial_name unless partial_name.empty?
|
43
|
+
response = self.class.get(list_dataset_url, headers: @headers, query: query)
|
36
44
|
if response.success?
|
37
|
-
response.parsed_response
|
38
|
-
|
39
|
-
|
45
|
+
NexosisApi::PagedArray.new(response.parsed_response,
|
46
|
+
response.parsed_response['items']
|
47
|
+
.map { |dr| NexosisApi::DatasetSummary.new(dr) })
|
40
48
|
else
|
41
49
|
raise HttpException.new("There was a problem listing datasets: #{response.code}.", "listing datasets with partial name #{partial_name}", response)
|
42
50
|
end
|
@@ -8,12 +8,23 @@ module NexosisApi
|
|
8
8
|
|
9
9
|
# List all existing import requests
|
10
10
|
#
|
11
|
-
# @
|
12
|
-
|
11
|
+
# @param dataset_name [String] optional name filter of dataset which was imported
|
12
|
+
# @param page [int] page number for items in list
|
13
|
+
# @param page_size [int] number of items in each page
|
14
|
+
# @return [NexosisApi::PagedArray of NexosisApi::ImportsResponse]
|
15
|
+
# @since 1.4 added paging parameters
|
16
|
+
def list_imports(dataset_name = '', page = 0, page_size = 50)
|
13
17
|
imports_url = '/imports'
|
14
|
-
|
18
|
+
query = {
|
19
|
+
dataSetName: dataset_name,
|
20
|
+
page: page,
|
21
|
+
pageSize: page_size
|
22
|
+
}
|
23
|
+
response = self.class.get(imports_url, headers: @headers, query: query)
|
15
24
|
if (response.success?)
|
16
|
-
|
25
|
+
NexosisApi::PagedArray.new(response.parsed_response,
|
26
|
+
response.parsed_response['items']
|
27
|
+
.map { |i| NexosisApi::ImportsResponse.new(i) })
|
17
28
|
else
|
18
29
|
raise HttpException.new("There was a problem getting the imports: #{response.code}.", "uploading dataset from s3 #{dataset_name}", response)
|
19
30
|
end
|
@@ -9,7 +9,7 @@ module NexosisApi
|
|
9
9
|
# models created for this data source name.
|
10
10
|
# @param query_options [Hash] limit by dates: begin_date and/or end_date
|
11
11
|
# @note - query options dates can either be ISO 8601 compliant strings or Date objects
|
12
|
-
# @return [
|
12
|
+
# @return [NexosisApi::PagedArray of NexosisApi::ModelSummary] - all models available within the query parameters
|
13
13
|
def list_models(datasource_name = nil, page = 0, page_size = 50, query_options = {})
|
14
14
|
model_url = '/models'
|
15
15
|
query = {
|
@@ -22,11 +22,12 @@ module NexosisApi
|
|
22
22
|
end
|
23
23
|
query.store(dataSourceName: datasource_name) unless datasource_name.nil?
|
24
24
|
response = self.class.get(model_url, headers: @headers, query: query)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
25
|
+
raise HttpException.new("There was a problem listing models: #{response.code}.",
|
26
|
+
"listing models with data source name #{datasource_name}",
|
27
|
+
response) unless response.success?
|
28
|
+
NexosisApi::PagedArray.new(response.parsed_response,
|
29
|
+
response.parsed_response['items']
|
30
|
+
.map { |item| NexosisApi::ModelSummary.new(item) })
|
30
31
|
end
|
31
32
|
|
32
33
|
# Get the details of the particular model requested by id
|
@@ -13,14 +13,14 @@ module NexosisApi
|
|
13
13
|
# @param query_options [Hash] optionally provide query parameters to limit the search of sessions.
|
14
14
|
# @param page [Integer] optionally provide a page number for paging. Defaults to 0 (first page).
|
15
15
|
# @param pageSize [Integer] optionally provide a page size to limit the total number of results. Defaults to 50, max 1000
|
16
|
-
# @return [
|
16
|
+
# @return [NexosisApi::PagedArray of NexosisApi::SessionResponse] with all sessions matching the query or all if no query
|
17
17
|
# @note query parameters hash members are dataset_name, event_name, requested_before_date, and requested_after_date.
|
18
18
|
# After and before dates refer to the session requested date.
|
19
19
|
# @example query for just one dataset
|
20
20
|
# sessions = NexosisApi.client.list_sessions :dataset_name => 'MyDataset'
|
21
21
|
def list_sessions(query_options = {}, page = 0, pageSize = 50)
|
22
22
|
sessions_url = '/sessions'
|
23
|
-
query = {
|
23
|
+
query = {
|
24
24
|
'dataSetName' => query_options[:dataset_name],
|
25
25
|
'eventName' => query_options[:event_name],
|
26
26
|
'requestedAfterDate' => query_options[:requested_after_date],
|
@@ -29,17 +29,14 @@ module NexosisApi
|
|
29
29
|
'page' => page,
|
30
30
|
'pageSize' => pageSize
|
31
31
|
}
|
32
|
-
response = self.class.get(sessions_url, :
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
else
|
41
|
-
raise HttpException.new('Could not retrieve sessions',"Get all sessions with query #{query_options.to_s}",response)
|
42
|
-
end
|
32
|
+
response = self.class.get(sessions_url, headers: @headers, query: query)
|
33
|
+
raise HttpException.new('Could not retrieve sessions',
|
34
|
+
"Get all sessions with query #{query_options}",
|
35
|
+
response) unless response.success?
|
36
|
+
NexosisApi::PagedArray.new(response.parsed_response, response.parsed_response['items'].map do |session_hash|
|
37
|
+
response_hash = { 'session' => session_hash }.merge(response.headers)
|
38
|
+
NexosisApi::SessionResponse.new(response_hash)
|
39
|
+
end)
|
43
40
|
end
|
44
41
|
|
45
42
|
# Remove a session
|
@@ -127,11 +124,13 @@ module NexosisApi
|
|
127
124
|
#
|
128
125
|
# @param session_id [String] the Guid string returned in a previous session request
|
129
126
|
# @param as_csv [Boolean] indicate whether results should be returned in csv format
|
127
|
+
# @param prediction_interval [Float] one of the available prediction intervals for the session.
|
130
128
|
# @return [NexosisApi::SessionResult] SessionResult if parsed, String of csv data otherwise
|
131
|
-
def get_session_results(session_id, as_csv = false)
|
129
|
+
def get_session_results(session_id, as_csv = false, prediction_interval = nil)
|
132
130
|
session_result_url = "/sessions/#{session_id}/results"
|
133
131
|
@headers['Accept'] = 'text/csv' if as_csv
|
134
|
-
|
132
|
+
query = { predictionInterval: prediction_interval } unless prediction_interval.nil?
|
133
|
+
response = self.class.get(session_result_url, headers: @headers, query: query)
|
135
134
|
@headers.delete('Accept')
|
136
135
|
|
137
136
|
if (response.success?)
|
@@ -153,6 +152,12 @@ module NexosisApi
|
|
153
152
|
raise HttpException.new("There was a problem getting the session: #{response.code}.", "getting session #{session_id}" ,response)
|
154
153
|
end
|
155
154
|
|
155
|
+
# Create a new model based on a data source
|
156
|
+
#
|
157
|
+
# @param datasource_name [String] The datasource from which to build the model
|
158
|
+
# @param target_column [String] The column which will be predicted when using the model
|
159
|
+
# @param columns [Hash] column metadata to modify roles, imputation, or target.
|
160
|
+
# @since 1.3.0
|
156
161
|
def create_model(datasource_name, target_column, columns = {})
|
157
162
|
model_url = '/sessions/model'
|
158
163
|
body = {
|
@@ -11,7 +11,7 @@ module NexosisApi
|
|
11
11
|
# @param dataset_name [String] optionally limit results by dataset used in definition
|
12
12
|
# @param page [Integer] optionally get results by non-zero page - defaults to 0
|
13
13
|
# @param page_size [Integer] optionally limit page size - defaults to 50 (max: 1000)
|
14
|
-
# @return [
|
14
|
+
# @return [NexosisApi::PagedArray of NexosisApi::ViewDefinition]
|
15
15
|
# @raise [NexosisApi::HttpException]
|
16
16
|
def list_views(partial_name = '', dataset_name = '', page = 0, page_size = 50)
|
17
17
|
url = '/views'
|
@@ -22,11 +22,9 @@ module NexosisApi
|
|
22
22
|
query.store 'partialName', partial_name if partial_name.empty? == false
|
23
23
|
query.store 'dataSetName', dataset_name if dataset_name.empty? == false
|
24
24
|
response = self.class.get(url, headers: @headers, query: query)
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end
|
29
|
-
end
|
25
|
+
raise NexosisApi::HttpException('Could not retrieve list of views.', 'attempting list of views', response) unless response.success?
|
26
|
+
NexosisApi::PagedArray.new(response.parsed_response, response.parsed_response['items']
|
27
|
+
.map { |definition| NexosisApi::ViewDefinition.new(definition) })
|
30
28
|
end
|
31
29
|
|
32
30
|
# Create a new view or update an existing one by name
|
data/lib/nexosis_api/client.rb
CHANGED
@@ -17,6 +17,7 @@ require 'nexosis_api/join'
|
|
17
17
|
require 'nexosis_api/link'
|
18
18
|
require 'nexosis_api/metric'
|
19
19
|
require 'nexosis_api/model_summary'
|
20
|
+
require 'nexosis_api/paged_array'
|
20
21
|
require 'nexosis_api/predict_response'
|
21
22
|
require 'nexosis_api/session_response'
|
22
23
|
require 'nexosis_api/session_result'
|
data/lib/nexosis_api/column.rb
CHANGED
data/lib/nexosis_api/join.rb
CHANGED
@@ -37,6 +37,7 @@ module NexosisApi
|
|
37
37
|
# @return [Array of NexosisApi::Join] zero or more additional joins
|
38
38
|
attr_accessor :joins
|
39
39
|
|
40
|
+
# provides a custom hash which can be converted to json matching api request
|
40
41
|
def to_hash
|
41
42
|
hash = join_target.to_hash
|
42
43
|
if column_options.nil? == false
|
@@ -54,6 +55,7 @@ module NexosisApi
|
|
54
55
|
hash
|
55
56
|
end
|
56
57
|
|
58
|
+
# gets a json represenation which can be used in api request
|
57
59
|
def to_json
|
58
60
|
to_hash.to_json
|
59
61
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module NexosisApi
|
2
|
+
# Generic list base class for list responses
|
3
|
+
# @since 1.4.0
|
4
|
+
class PagedArray < Array
|
5
|
+
def initialize(paged_response, item_array = [])
|
6
|
+
self[0..item_array.length] = item_array
|
7
|
+
var_map = { 'pageNumber' => :@page_number,
|
8
|
+
'totalPages' => :@total_pages,
|
9
|
+
'pageSize' => :@page_size,
|
10
|
+
'totalCount' => :@item_total }
|
11
|
+
paged_response.each { |k, v| instance_variable_set(var_map[k.to_s], v) unless var_map[k.to_s].nil? }
|
12
|
+
@links = paged_response['links'].map { |l| NexosisApi::Link.new(l) } unless paged_response['links'].nil?
|
13
|
+
end
|
14
|
+
|
15
|
+
# The current page number represented by this collection
|
16
|
+
# @return [int]
|
17
|
+
attr_accessor :page_number
|
18
|
+
|
19
|
+
# The total number of pages given the current page size and item total
|
20
|
+
# @return [int]
|
21
|
+
attr_accessor :total_pages
|
22
|
+
|
23
|
+
# The total number of items per page
|
24
|
+
# @return [int]
|
25
|
+
attr_accessor :page_size
|
26
|
+
|
27
|
+
# The total number of items available on the server for this collection
|
28
|
+
# @return [int]
|
29
|
+
attr_accessor :item_total
|
30
|
+
|
31
|
+
# paging links to first, last pages
|
32
|
+
# @return [Array of NexosisApi::Link]
|
33
|
+
attr_accessor :links
|
34
|
+
end
|
35
|
+
end
|
data/lib/nexosis_api/session.rb
CHANGED
@@ -1,37 +1,41 @@
|
|
1
1
|
module NexosisApi
|
2
2
|
# Class for parsing the results of a session based request
|
3
3
|
class Session
|
4
|
-
def initialize(
|
5
|
-
|
4
|
+
def initialize(session_hash)
|
5
|
+
val_map = { 'resultInterval' => :@result_interval,
|
6
|
+
'dataSourceName' => :@datasource_name,
|
7
|
+
'modelId' => :@model_id,
|
8
|
+
'sessionId' => :@session_id,
|
9
|
+
'availablePredictionIntervals' => :@prediction_intervals,
|
10
|
+
'startDate' => :@start_date,
|
11
|
+
'endDate' => :@end_date }
|
12
|
+
session_hash.each do |k, v|
|
6
13
|
if (k == 'links')
|
7
|
-
links =
|
8
|
-
v.each { |l| links << NexosisApi::Link.new(l) }
|
9
|
-
instance_variable_set("@#{k}", links) unless v.nil?
|
10
|
-
elsif (k == 'isEstimate')
|
11
|
-
instance_variable_set('@is_estimate', v) unless v.nil?
|
14
|
+
@links = v.map { |l| NexosisApi::Link.new(l) }
|
12
15
|
elsif (k == 'columns')
|
13
16
|
@column_metadata = v.reject { |_key, value| value.nil? }
|
14
17
|
.map do |col_key, col_val|
|
15
18
|
NexosisApi::Column.new(col_key, v[col_key])
|
16
19
|
end
|
17
|
-
elsif (k == 'resultInterval')
|
18
|
-
@result_interval = v
|
19
|
-
elsif (k == 'dataSourceName')
|
20
|
-
@datasource_name = v
|
21
|
-
elsif (k == 'modelId')
|
22
|
-
@model_id = v
|
23
20
|
elsif (k == 'requestedDate')
|
24
21
|
@requested_date = DateTime.parse(v)
|
25
22
|
else
|
26
23
|
instance_variable_set("@#{k}", v) unless v.nil?
|
27
24
|
end
|
25
|
+
instance_variable_set(val_map[k], v) unless val_map[k].nil?
|
28
26
|
end
|
29
27
|
end
|
30
28
|
|
31
29
|
# identifier for this sesssion
|
32
30
|
# @return [String]
|
31
|
+
# @deprecated use session_id instead
|
33
32
|
attr_accessor :sessionId
|
34
33
|
|
34
|
+
# identifier for this sesssion
|
35
|
+
# @return [String]
|
36
|
+
# @since 1.4.0
|
37
|
+
attr_accessor :session_id
|
38
|
+
|
35
39
|
# What type of analysis was run during this session
|
36
40
|
# @return [String]
|
37
41
|
attr_accessor :type
|
@@ -59,12 +63,24 @@ module NexosisApi
|
|
59
63
|
|
60
64
|
# The start date of analysis in this session
|
61
65
|
# @return [DateTime]
|
66
|
+
# @deprecated use start_date instead
|
62
67
|
attr_accessor :startDate
|
63
68
|
|
64
69
|
# The end date of analysis in this session
|
65
70
|
# @return [DateTime]
|
71
|
+
# @deprecated use end_date instead
|
66
72
|
attr_accessor :endDate
|
67
73
|
|
74
|
+
# The start date of analysis in this session
|
75
|
+
# @return [DateTime]
|
76
|
+
# @since 1.4.0
|
77
|
+
attr_accessor :start_date
|
78
|
+
|
79
|
+
# The end date of analysis in this session
|
80
|
+
# @return [DateTime]
|
81
|
+
# @since 1.4.0
|
82
|
+
attr_accessor :end_date
|
83
|
+
|
68
84
|
# associated hypermedia
|
69
85
|
# @return [Array of NexosisApi::Link]
|
70
86
|
attr_accessor :links
|
@@ -96,7 +112,14 @@ module NexosisApi
|
|
96
112
|
# @since 1.3.0
|
97
113
|
# @note This is always empty in time-series sessions (forecast/impact)
|
98
114
|
# The model id returned here should be used in all future calls
|
99
|
-
# to model endpoints - primarily the /models/{
|
115
|
+
# to model endpoints - primarily the /models/{model_id}/predict endpoint.
|
100
116
|
attr_accessor :model_id
|
117
|
+
|
118
|
+
# An array of the prediction intervals available for this session's results
|
119
|
+
# @return [Array]
|
120
|
+
# @note - by default the .5 interval will be returned in results. Consult
|
121
|
+
# this list for other intervals which can be requested.
|
122
|
+
# @since 1.4.0
|
123
|
+
attr_accessor :prediction_intervals
|
101
124
|
end
|
102
125
|
end
|
data/nexosisapi.gemspec
CHANGED
@@ -16,6 +16,6 @@ Gem::Specification.new do |spec|
|
|
16
16
|
spec.require_paths = ['lib']
|
17
17
|
spec.required_ruby_version = '>= 2.0.0'
|
18
18
|
spec.summary = "Ruby client for working with the Nexosis API"
|
19
|
-
spec.version = '1.
|
19
|
+
spec.version = '1.4.0'
|
20
20
|
spec.metadata["yard.run"] = "yri"
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nexosis_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nexosis,Inc
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -71,6 +71,7 @@ files:
|
|
71
71
|
- lib/nexosis_api/link.rb
|
72
72
|
- lib/nexosis_api/metric.rb
|
73
73
|
- lib/nexosis_api/model_summary.rb
|
74
|
+
- lib/nexosis_api/paged_array.rb
|
74
75
|
- lib/nexosis_api/predict_response.rb
|
75
76
|
- lib/nexosis_api/session.rb
|
76
77
|
- lib/nexosis_api/session_response.rb
|