zillabyte-cli 0.1.1 → 0.1.2

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,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 284b1b673fa8e9159a4f9f5ac108ffdf2f158fe0
4
- data.tar.gz: a8d5398aa5b99320f6d050c797c952b977b10dc1
5
- SHA512:
6
- metadata.gz: 5786156d1bb899860e7a8c9468b1e0a4ac5dcb4f7d4afe7b59bf4174b455eaefe2d3764db9bfc7c056f972cb7e1bec8c570bf48fc378ab5d5d2b049a7dbbc2f2
7
- data.tar.gz: f56ec56c826a691b1b911264e38358ec66efe9ee77e0560e09690f95bf93605a99d5f58262d8254e33d8ecc981c8e4c7c8ab30edc248966786a9780f88bc6c71
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YTI2YjEzZTdjZGM4MDczNjkyOWE1ZDEwNWFkYzJhOTFhOTkxNWExNg==
5
+ data.tar.gz: !binary |-
6
+ MTM3OTA2NDM3MzJlMDUxZTgwNDJjOGFmYjAyOWVkN2E1OTUwNjFiZg==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ODVhOWQ4ZmYxNWM4MzY5OWFkYWFjM2JlNWRmNmJjN2JiMzc0N2Q5OTNjNTBk
10
+ NjEwZjRjNjE1NWNlNWJmMmMwMGRmYmU0YjA5OGJkM2MxM2M3OWJkMmQyNTk2
11
+ OGMwODliYzVlN2VmMDgwMDNkZTkwOTdhMjJjYjFhOWI4YjdmMmM=
12
+ data.tar.gz: !binary |-
13
+ NDNjMzAxZmFhYThiNTUwNDE0ODAxMzVlOWIyMTM5M2EyOTE5ZWQwMTRiMGEz
14
+ M2JiZWQ3ZjZjZDZlZDNiYTBmYTIxNGJlNDg4NDYyNGFjYmRlZWFlZGY2NDcy
15
+ YjVhMWZiMWM4Mjg0ZWQ2MTQyZmFhZjEyMDdlMTVkNzQ5NTYzNjQ=
@@ -100,7 +100,9 @@ class Zillabyte::API::Flows < Zillabyte::API::Base
100
100
  )
101
101
 
102
102
  hash = res.body
103
- unless hash['status'] == 'error'
103
+ if hash['status'] == 'error'
104
+ error hash['error_message']
105
+ else
104
106
  if(hash['tar'])
105
107
  session.display "unpacking to #{dir}" if type.nil?
106
108
  tar = StringIO.new(Base64.decode64(hash['tar']))
@@ -19,8 +19,9 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
19
19
 
20
20
  # apps
21
21
  #
22
- # list custom apps
23
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
22
+ # List custom apps.
23
+ #
24
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
24
25
  #
25
26
  def index
26
27
  self.list
@@ -30,8 +31,10 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
30
31
 
31
32
  # apps
32
33
  #
33
- # list custom apps
34
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
34
+ # List custom apps.
35
+ #
36
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
37
+ #
35
38
  def list
36
39
  type = options[:output_type]
37
40
 
@@ -53,8 +56,9 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
53
56
 
54
57
  # apps:details ID
55
58
  #
56
- # list details for an app, including percentage complete
57
- # if the source is an existing relation
59
+ # List details for an app, including percentage complete, if the
60
+ # source is an existing dataset.
61
+ #
58
62
  def details
59
63
 
60
64
  app_id = options[:id] || shift_argument
@@ -106,20 +110,20 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
106
110
  # combine the arrays
107
111
  rows = type_name.zip(stats).map{|x,y| x.concat y}
108
112
 
109
- # check if it's from a relation.
110
- # if the source is a relation, there's a sharder.
113
+ # check if it's from a dataset.
114
+ # if the source is a dataset, there's a sharder.
111
115
  # remove source types, and hardcode sharder-named instances as source
112
116
 
113
- from_relation = false
117
+ from_dataset = false
114
118
 
115
119
  rows.each do | row |
116
120
  if row[1].scan("sharder").length != 0
117
- from_relation = true
121
+ from_dataset = true
118
122
  break
119
123
  end
120
124
  end
121
125
 
122
- if from_relation == true
126
+ if from_dataset == true
123
127
 
124
128
  rows = rows.each do |row|
125
129
  if row[0].scan("source").length != 0
@@ -146,7 +150,7 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
146
150
  attempts = 0
147
151
  total = 0
148
152
 
149
- if from_relation == true
153
+ if from_dataset == true
150
154
 
151
155
  rows.each do |instance|
152
156
  if instance[0] == "source"
@@ -171,23 +175,21 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
171
175
  # output on the CLI
172
176
  display "details:"
173
177
  display TableOutputBuilder.build_table(headings, rows, type)
174
- if from_relation == true
178
+ if from_dataset == true
175
179
  display "percent complete: #{completion}%\n"
176
180
  end
177
181
  end
178
182
 
179
183
 
180
-
181
-
182
184
  # apps:push [DIR]
183
185
  #
184
- # uploads an app
186
+ # Uploads an app.
185
187
  #
186
- # --config CONFIG_FILE # use the given config file
187
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
188
- # --directory DIR # app directory
188
+ # --config CONFIG_FILE # Use the given config file
189
+ # --directory DIR # App directory
190
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
189
191
  #
190
- #Examples:
192
+ # Examples:
191
193
  #
192
194
  # $ zillabyte apps:push .
193
195
  #
@@ -223,14 +225,13 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
223
225
  alias_command "push", "apps:push"
224
226
 
225
227
 
226
-
227
228
  # apps:pull ID DIR
228
229
  #
229
- # pulls an app source to a directory.
230
+ # Pulls an app source to a directory.
230
231
  #
231
- # --force # pulls even if the directory exists
232
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
233
- # --directory DIR # Directory of the app
232
+ # --force # Pulls even if the directory exists
233
+ # --directory DIR # App directory
234
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
234
235
  #
235
236
  # Examples:
236
237
  #
@@ -243,10 +244,10 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
243
244
 
244
245
  # apps:delete ID
245
246
  #
246
- # deletes an app. if the app is running, this command will kill it.
247
+ # Deletes an app. If the app is running, this command will kill it.
247
248
  #
248
- # -f, --force # don't ask for confirmation
249
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
249
+ # -f, --force # Don't ask for confirmation
250
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
250
251
  #
251
252
  def delete
252
253
  super
@@ -255,10 +256,11 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
255
256
 
256
257
  # apps:prep [DIR]
257
258
  #
258
- # performs any necessary initialization for the app
259
+ # Performs any necessary initialization for the app.
259
260
  #
260
- # --directory DIR # app directory
261
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
261
+ # --directory DIR # App directory
262
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
263
+ # --mode MODE # Specify development or production mode for dependencies #HIDDEN
262
264
  #
263
265
  def prep
264
266
  super
@@ -267,12 +269,12 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
267
269
 
268
270
  # apps:init [NAME]
269
271
  #
270
- # initializes a new app
272
+ # Initializes a new app.
271
273
  #
272
- # --lang LANG # which language to use [ruby, python]. default 'ruby'.
273
- # --dir DIR # target directory of the app.
274
+ # --lang LANG # Specify which language to use (ruby, python) [default: 'ruby']
275
+ # --dir DIR # Target directory of the app
274
276
  #
275
- #Examples:
277
+ # Examples:
276
278
  #
277
279
  # $ zillabyte apps:init contact_extractor --lang python
278
280
  #
@@ -315,8 +317,9 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
315
317
 
316
318
  # apps:errors ID
317
319
  #
318
- # show recent errors generated by the app
319
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
320
+ # Show recent errors generated by the app.
321
+ #
322
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
320
323
  #
321
324
  def errors
322
325
  super
@@ -324,11 +327,11 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
324
327
 
325
328
  # apps:logs ID [OPERATION_NAME]
326
329
  #
327
- # streams logs from the distributed workers
330
+ # Streams logs for the app from our cluster.
328
331
  #
329
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
330
- # --operation OPERATION_NAME # specify the operation to show logs for
331
- # -v, --verbose LEVEL # sets the verbosity (error, info, debug) (default: info)
332
+ # --operation OPERATION_NAME # Specify the operation to show logs for
333
+ # -v, --verbose LEVEL # Sets the verbosity (error, info, debug) [default: info]
334
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
332
335
  #
333
336
  def logs
334
337
  super
@@ -337,11 +340,12 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
337
340
 
338
341
  # apps:cycles ID [OPTIONS]
339
342
  #
340
- # operations on the app's cycles (batches).
341
- # with no options, the command lists the apps cycles
342
- # -n, --next # request the app to move to the next cycle
343
- # -f, --forever # don't wait on cycles any more
344
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
343
+ # Operations on the app's cycles.
344
+ # With no options, the command lists the apps cycles.
345
+ #
346
+ # -n, --next # Request the app to move to the next cycle
347
+ # -f, --forever # Automatically start new cycles when previous cycles ends
348
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
345
349
  #
346
350
  def cycles
347
351
  app_id = options[:id] || shift_argument
@@ -424,13 +428,13 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
424
428
 
425
429
  # apps:test
426
430
  #
427
- # tests a local app with sample data
431
+ # Tests a local app with sample data.
428
432
  #
429
- # --config CONFIG_FILE # use the given config file
430
- # --output OUTPUT_FILE # writes sink output to a file
431
- # --cycles CYCLES # number of cycles to emit (default 1)
432
- # --directory DIR # app directory
433
- # -i, --interactive # allow user to control input and read output
433
+ # --config CONFIG_FILE # Use the given config file
434
+ # --output OUTPUT_FILE # Writes sink output to a file
435
+ # --cycles CYCLES # Number of cycles to emit [default: 1]
436
+ # --directory DIR # App directory
437
+ # -i, --interactive # Interactively control input and read output
434
438
  #
435
439
  def test
436
440
  super
@@ -439,10 +443,10 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
439
443
 
440
444
  # apps:kill ID
441
445
  #
442
- # kills the given app
446
+ # Kills the given app.
443
447
  #
444
- # --config CONFIG_FILE # use the given config file
445
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
448
+ # --config CONFIG_FILE # Use the given config file
449
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
446
450
  #
447
451
  def kill
448
452
  super
@@ -451,11 +455,11 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
451
455
 
452
456
  # apps:live_run [OPERATION_NAME] [PIPE_NAME] [DIR]
453
457
  #
454
- # runs a local app with live data
458
+ # Runs a local app with live data.
455
459
  #
456
- # --config CONFIG_FILE # use the given config file
457
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
458
- # --directory DIR # Directory of the app
460
+ # --config CONFIG_FILE # Use the given config file
461
+ # --directory DIR # App directory
462
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
459
463
  #
460
464
  # HIDDEN:
461
465
  def live_run
@@ -463,13 +467,12 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
463
467
  end
464
468
 
465
469
 
466
-
467
470
  # apps:status [DIR]
468
471
  #
469
- # fetches detailed status of the app
472
+ # Fetches detailed status of the app.
470
473
  #
471
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
472
- # --directory DIR # Directory of the app
474
+ # --directory DIR # App directory
475
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
473
476
  #
474
477
  def status
475
478
  super
@@ -479,23 +482,19 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
479
482
 
480
483
  # apps:info [DIR]
481
484
  #
482
- # outputs the info for the app in the dir.
485
+ # Outputs the info for the app in the dir.
483
486
  #
484
- # --pretty # Pretty prints the info output
485
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
486
- # --directory DIR # Directory of the app
487
+ # --pretty # Pretty prints the info output
488
+ # --directory DIR # App directory
489
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
487
490
  #
488
491
  def info
489
492
  super
490
493
  end
491
494
 
492
495
 
493
-
494
496
  private
495
497
 
496
- #
497
- #
498
- #
499
498
  def describe_app(meta, colors = {})
500
499
  @colors ||= [:green, :yellow, :magenta, :cyan, :light_black, :light_green, :light_yellow, :light_blue, :light_magenta, :light_cyan]
501
500
  rjust = 20
@@ -7,10 +7,9 @@ require "pp"
7
7
  class Zillabyte::Command::Auth < Zillabyte::Command::Base
8
8
 
9
9
 
10
-
11
10
  # auth:login
12
11
  #
13
- # set the authentication token
12
+ # Set the authentication token.
14
13
  #
15
14
  def login
16
15
  Zillabyte::Auth.ask_for_and_save_credentials
@@ -20,7 +19,7 @@ class Zillabyte::Command::Auth < Zillabyte::Command::Base
20
19
 
21
20
  # auth:logout
22
21
  #
23
- # clear the authentication token
22
+ # Clear the authentication token.
24
23
  #
25
24
  def logout
26
25
  Zillabyte::Auth.logout
@@ -28,6 +27,5 @@ class Zillabyte::Command::Auth < Zillabyte::Command::Base
28
27
 
29
28
  alias_command "logout", "auth:logout"
30
29
 
31
-
32
30
 
33
31
  end
@@ -7,6 +7,8 @@ class Zillabyte::Command::Base
7
7
  include Zillabyte::Helpers
8
8
  include ActionView::Helpers::DateHelper
9
9
 
10
+ META_COLUMNS = ["since", "confidence", "source"]
11
+
10
12
  def self.namespace
11
13
  self.to_s.split("::").last.downcase
12
14
  end
@@ -9,26 +9,24 @@ class Zillabyte::Command::Components < Zillabyte::Command::Flows
9
9
 
10
10
  # components
11
11
  #
12
- # list custom components
13
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
12
+ # List custom components.
13
+ #
14
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
14
15
  #
15
16
  def index
16
17
  self.list
17
18
  end
18
-
19
-
20
-
21
19
 
22
20
 
23
21
  # components:init [NAME]
24
22
  #
25
- # initializes a new component
23
+ # Initializes a new component.
26
24
  #
27
- # --lang LANG # which language to use [ruby, python]. default 'ruby'.
28
- # --dir DIR # target directory of the app.
29
- # --remote REMOTE # the git remote name. default 'zillabyte'
25
+ # --lang LANG # Specify which language to use (ruby, python) [default: 'ruby']
26
+ # --dir DIR # Target directory of the app
27
+ # --remote REMOTE # The git remote name [default: 'zillabyte']
30
28
  #
31
- #Examples:
29
+ # Examples:
32
30
  #
33
31
  # $ zillabyte components:init domain_extractor --lang ruby
34
32
  #
@@ -71,8 +69,10 @@ class Zillabyte::Command::Components < Zillabyte::Command::Flows
71
69
 
72
70
  # components
73
71
  #
74
- # list custom components
75
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
72
+ # List custom components.
73
+ #
74
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
75
+ #
76
76
  def list
77
77
  type = options[:output_type]
78
78
 
@@ -95,11 +95,11 @@ class Zillabyte::Command::Components < Zillabyte::Command::Flows
95
95
 
96
96
  # components:pull ID DIR
97
97
  #
98
- # pulls a component source to a directory.
98
+ # Pulls a component source to a directory.
99
99
  #
100
- # --force # pulls even if the directory exists
101
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
102
- # --directory DIR # Directory of the component
100
+ # --force # Pulls even if the directory exists
101
+ # --directory DIR # Component directory
102
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
103
103
  #
104
104
  # Examples:
105
105
  #
@@ -111,10 +111,10 @@ class Zillabyte::Command::Components < Zillabyte::Command::Flows
111
111
 
112
112
  # components:status [DIR]
113
113
  #
114
- # fetches detailed status of the component
114
+ # Fetches detailed status of the component.
115
115
  #
116
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
117
- # --directory DIR # Directory of the component
116
+ # --directory DIR # Component directory
117
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
118
118
  #
119
119
  def status
120
120
  super
@@ -124,10 +124,10 @@ class Zillabyte::Command::Components < Zillabyte::Command::Flows
124
124
 
125
125
  # components:delete ID
126
126
  #
127
- # deletes a component.
127
+ # Deletes a component. If the rpc is currently running, this command will kill it.
128
128
  #
129
- # -f, --force # don't ask for confirmation
130
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
129
+ # -f, --force # Don't ask for confirmation
130
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
131
131
  #
132
132
  def delete
133
133
  super
@@ -135,10 +135,10 @@ class Zillabyte::Command::Components < Zillabyte::Command::Flows
135
135
 
136
136
  # components:kill ID
137
137
  #
138
- # kills the given component rpc
138
+ # Kills the given component rpc.
139
139
  #
140
- # --config CONFIG_FILE # use the given config file
141
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
140
+ # --config CONFIG_FILE # Use the given config file
141
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
142
142
  #
143
143
  def kill
144
144
  super
@@ -146,11 +146,11 @@ class Zillabyte::Command::Components < Zillabyte::Command::Flows
146
146
 
147
147
  # components:info [DIR]
148
148
  #
149
- # outputs the info for the component in the dir.
149
+ # Outputs the info for the component in the dir.
150
150
  #
151
- # --pretty # Pretty prints the info output
152
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
153
- # --directory DIR # Directory of the component
151
+ # --pretty # Pretty prints the info output
152
+ # --directory DIR # Component directory
153
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
154
154
  #
155
155
  def info
156
156
  super
@@ -159,12 +159,12 @@ class Zillabyte::Command::Components < Zillabyte::Command::Flows
159
159
 
160
160
  # components:test
161
161
  #
162
- # tests a local component with sample data
162
+ # Tests a local component with sample data.
163
163
  #
164
- # --config CONFIG_FILE # use the given config file
165
- # --input INPUT_FILE # uses a CSV for component input
166
- # --output OUTPUT_FILE # write output to a CSV
167
- # --directory DIR # component directory
164
+ # --config CONFIG_FILE # Use the given config file
165
+ # --input INPUT_FILE # Uses a CSV for component input
166
+ # --output OUTPUT_FILE # Write output to a CSV
167
+ # --directory DIR # Component directory
168
168
  #
169
169
  def test
170
170
  super
@@ -172,10 +172,10 @@ class Zillabyte::Command::Components < Zillabyte::Command::Flows
172
172
 
173
173
  # components:prep [DIR]
174
174
  #
175
- # performs any necessary initialization for the component
175
+ # Performs any necessary initialization for the component.
176
176
  #
177
- # --directory DIR # component directory
178
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
177
+ # --directory DIR # Component directory
178
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json HIDDEN
179
179
  #
180
180
  def prep
181
181
  super
@@ -183,27 +183,115 @@ class Zillabyte::Command::Components < Zillabyte::Command::Flows
183
183
 
184
184
  # components:errors ID
185
185
  #
186
- # show recent errors generated by the componeny rpc
186
+ # Show recent errors generated by the componeny rpc.
187
187
  #
188
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
188
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json HIDDEN
189
189
  #
190
190
  def errors
191
191
  super
192
192
  end
193
193
 
194
+ # components:logs ID [OPERATION_NAME]
195
+ #
196
+ # Streams logs for the component from our cluster.
197
+ #
198
+ # --operation OPERATION_NAME # Specify the operation to show logs for
199
+ # -v, --verbose LEVEL # Sets the verbosity (error, info, debug) [default: info]
200
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json #HIDDEN
201
+ #
202
+ def logs
203
+ super
204
+ end
205
+
194
206
  # components:live_run [OPERATION_NAME] [PIPE_NAME] [DIR]
195
207
  #
196
- # runs a local component with live data
208
+ # Runs a local component with live data.
197
209
  #
198
- # --config CONFIG_FILE # use the given config file
199
- # --output_type OUTPUT_TYPE # specify an output type i.e. json
200
- # --directory DIR # Directory of the component
210
+ # --config CONFIG_FILE # Use the given config file
211
+ # --directory DIR # Component directory
212
+ # --output_type OUTPUT_TYPE # Specify an output type i.e. json HIDDEN
201
213
  #
202
214
  # HIDDEN:
203
215
  def live_run
204
216
  super
205
217
  end
206
218
 
219
+
220
+ # components:push [DIR]
221
+ #
222
+ # Uploads a component.
223
+ #
224
+ # --config CONFIG_FILE # Use the given config file
225
+ # --directory DIR # Component directory
226
+ #
227
+ # Examples:
228
+ #
229
+ # $ zillabyte components:push .
230
+ #
231
+ # HIDDEN: This is only meant for local testing. You must be an admin.
232
+ def push
233
+
234
+ since = Time.now.utc.to_s
235
+ dir = options[:directory] || Dir.pwd
236
+ dir = File.expand_path(dir)
237
+
238
+ hash = Zillabyte::API::Flows.get_rich_meta_info_from_script(dir, session, options)
239
+ name = hash['name']
240
+
241
+ options[:directory] = dir
242
+ options[:component_id] = dir
243
+ options[:schema] = hash
244
+ options[:meta] = hash
245
+ options[:name] = name
246
+ type = options[:output_type]
247
+
248
+ # Push the component...
249
+ session.display("packaging directory... ") if session && type.nil?
250
+ tar = Zillabyte::Common::Tar.tar(dir)
251
+
252
+ # Create the component
253
+ res = self.api.request(
254
+ :expects => 200,
255
+ :method => :post,
256
+ :path => "/components/",
257
+ :body => options.to_json
258
+ ).body
259
+
260
+ error("error: #{res['error_message']}", type) if res['error']
261
+ comp_id = res['id']
262
+
263
+ # Push the tar...
264
+ if(res['uri'])
265
+ uri = URI(res['uri'])
266
+ try_again = 1
267
+ while(try_again)
268
+ Net::HTTP.start(uri.host, uri.port, :use_ssl => true) do |http|
269
+ request = Net::HTTP::Put.new(uri.request_uri)
270
+ request.body_stream = tar
271
+ request['Content-Length'] = request.body_stream.size
272
+ request['Content-Type'] = ''
273
+ response = http.request(request)
274
+ if response.code.to_i >= 300
275
+ try_again = 1
276
+ break
277
+ end
278
+ try_again = nil
279
+ end
280
+ end
281
+ res.delete('uri')
282
+ session.display( "pushed")
283
+ else
284
+ error "unable to push"
285
+ end
286
+
287
+ sleep 2
288
+ hash = self.api.logs.get(comp_id, nil, options)
289
+ fetch_logs(hash, "_ALL_", "Component registered")
290
+
291
+ display "{}" if type == "json"
292
+
293
+ end
294
+
207
295
 
208
296
  # components:rpc [ID] [INPUT_1] [INPUT_2] ...
209
297
  #
@@ -214,9 +302,9 @@ class Zillabyte::Command::Components < Zillabyte::Command::Flows
214
302
  # the command line. Each line of the file should correspond to a
215
303
  # unique query.
216
304
  #
217
- # --async # run the command asynchronously
218
- # --input_file INTPUT_FILE # input csv file containing parameters for multiple queries
219
- # --output_file OUTPUT_FILE # output csv file containing query parameters and run ids
305
+ # --async # Run the command asynchronously
306
+ # --input_file INTPUT_FILE # Input csv file containing parameters for multiple queries
307
+ # --output_file OUTPUT_FILE # Output csv file containing query parameters and run ids
220
308
  #
221
309
  # Examples:
222
310
  #
@@ -323,7 +411,7 @@ class Zillabyte::Command::Components < Zillabyte::Command::Flows
323
411
  # may also be specified in an input csv file like that generated by
324
412
  # components:rpc with the --output_file flag.
325
413
  #
326
- # --input_file INTPUT_FILE # input csv file containing query parameters and run ids (this can be generated automatically by components:rpc using the --output_file flag)
414
+ # --input_file INTPUT_FILE # Input csv file containing query parameters and run ids (this can be generated automatically by components:rpc using the --output_file flag)
327
415
  #
328
416
  def results
329
417
  component_id = options[:id] || shift_argument