zillabyte-cli 0.1.1 → 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +14 -6
- data/lib/zillabyte/api/flows.rb +3 -1
- data/lib/zillabyte/cli/apps.rb +70 -71
- data/lib/zillabyte/cli/auth.rb +2 -4
- data/lib/zillabyte/cli/base.rb +2 -0
- data/lib/zillabyte/cli/components.rb +135 -47
- data/lib/zillabyte/cli/{relations.rb → data.rb} +70 -98
- data/lib/zillabyte/cli/flows.rb +50 -50
- data/lib/zillabyte/cli/git.rb +6 -7
- data/lib/zillabyte/cli/help.rb +3 -5
- data/lib/zillabyte/cli/keys.rb +18 -15
- data/lib/zillabyte/cli/nuke.rb +4 -6
- data/lib/zillabyte/cli/query.rb +26 -50
- data/lib/zillabyte/cli/repl.rb +6 -4
- data/lib/zillabyte/cli/templates/apps/ruby/README.md +123 -0
- data/lib/zillabyte/cli/templates/apps/ruby/zillabyte.conf.yaml +3 -0
- data/lib/zillabyte/cli/templates/ruby/Gemfile.lock +81 -0
- data/lib/zillabyte/helpers.rb +22 -0
- data/lib/zillabyte-cli/version.rb +1 -1
- data/zillabyte-cli.gemspec +0 -1
- metadata +50 -66
- data/lib/#zillabyte-cli.rb# +0 -5
- data/lib/zillabyte/cli/#logs.rb# +0 -12
- data/lib/zillabyte/cli/#repl.rb# +0 -43
- data/lib/zillabyte/cli/templates/python/#simple_function.py# +0 -27
checksums.yaml
CHANGED
@@ -1,7 +1,15 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
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=
|
data/lib/zillabyte/api/flows.rb
CHANGED
@@ -100,7 +100,9 @@ class Zillabyte::API::Flows < Zillabyte::API::Base
|
|
100
100
|
)
|
101
101
|
|
102
102
|
hash = res.body
|
103
|
-
|
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']))
|
data/lib/zillabyte/cli/apps.rb
CHANGED
@@ -19,8 +19,9 @@ class Zillabyte::Command::Apps < Zillabyte::Command::Flows
|
|
19
19
|
|
20
20
|
# apps
|
21
21
|
#
|
22
|
-
#
|
23
|
-
#
|
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
|
-
#
|
34
|
-
#
|
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
|
-
#
|
57
|
-
#
|
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
|
110
|
-
# if the source is a
|
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
|
-
|
117
|
+
from_dataset = false
|
114
118
|
|
115
119
|
rows.each do | row |
|
116
120
|
if row[1].scan("sharder").length != 0
|
117
|
-
|
121
|
+
from_dataset = true
|
118
122
|
break
|
119
123
|
end
|
120
124
|
end
|
121
125
|
|
122
|
-
if
|
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
|
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
|
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
|
-
#
|
186
|
+
# Uploads an app.
|
185
187
|
#
|
186
|
-
# --config CONFIG_FILE
|
187
|
-
# --
|
188
|
-
# --
|
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
|
-
#
|
230
|
+
# Pulls an app source to a directory.
|
230
231
|
#
|
231
|
-
# --force
|
232
|
-
# --
|
233
|
-
# --
|
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
|
-
#
|
247
|
+
# Deletes an app. If the app is running, this command will kill it.
|
247
248
|
#
|
248
|
-
# -f, --force
|
249
|
-
# --output_type OUTPUT_TYPE
|
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
|
-
#
|
259
|
+
# Performs any necessary initialization for the app.
|
259
260
|
#
|
260
|
-
# --directory DIR
|
261
|
-
# --output_type OUTPUT_TYPE
|
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
|
-
#
|
272
|
+
# Initializes a new app.
|
271
273
|
#
|
272
|
-
# --lang LANG
|
273
|
-
# --dir DIR
|
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
|
-
#
|
319
|
-
#
|
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
|
-
#
|
330
|
+
# Streams logs for the app from our cluster.
|
328
331
|
#
|
329
|
-
# --
|
330
|
-
# --
|
331
|
-
#
|
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
|
-
#
|
341
|
-
#
|
342
|
-
#
|
343
|
-
# -
|
344
|
-
# --
|
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
|
-
#
|
431
|
+
# Tests a local app with sample data.
|
428
432
|
#
|
429
|
-
# --config CONFIG_FILE
|
430
|
-
# --output OUTPUT_FILE
|
431
|
-
# --cycles CYCLES
|
432
|
-
# --directory DIR
|
433
|
-
# -i, --interactive
|
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
|
-
#
|
446
|
+
# Kills the given app.
|
443
447
|
#
|
444
|
-
# --config CONFIG_FILE
|
445
|
-
# --output_type OUTPUT_TYPE
|
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
|
-
#
|
458
|
+
# Runs a local app with live data.
|
455
459
|
#
|
456
|
-
# --config CONFIG_FILE
|
457
|
-
# --
|
458
|
-
# --
|
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
|
-
#
|
472
|
+
# Fetches detailed status of the app.
|
470
473
|
#
|
471
|
-
# --
|
472
|
-
# --
|
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
|
-
#
|
485
|
+
# Outputs the info for the app in the dir.
|
483
486
|
#
|
484
|
-
# --pretty
|
485
|
-
# --
|
486
|
-
# --
|
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
|
data/lib/zillabyte/cli/auth.rb
CHANGED
@@ -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
|
-
#
|
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
|
-
#
|
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
|
data/lib/zillabyte/cli/base.rb
CHANGED
@@ -9,26 +9,24 @@ class Zillabyte::Command::Components < Zillabyte::Command::Flows
|
|
9
9
|
|
10
10
|
# components
|
11
11
|
#
|
12
|
-
#
|
13
|
-
#
|
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
|
-
#
|
23
|
+
# Initializes a new component.
|
26
24
|
#
|
27
|
-
# --lang LANG
|
28
|
-
# --dir DIR
|
29
|
-
# --remote REMOTE
|
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
|
-
#
|
75
|
-
#
|
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
|
-
#
|
98
|
+
# Pulls a component source to a directory.
|
99
99
|
#
|
100
|
-
# --force
|
101
|
-
# --
|
102
|
-
# --
|
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
|
-
#
|
114
|
+
# Fetches detailed status of the component.
|
115
115
|
#
|
116
|
-
# --
|
117
|
-
# --
|
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
|
-
#
|
127
|
+
# Deletes a component. If the rpc is currently running, this command will kill it.
|
128
128
|
#
|
129
|
-
# -f, --force
|
130
|
-
# --output_type OUTPUT_TYPE
|
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
|
-
#
|
138
|
+
# Kills the given component rpc.
|
139
139
|
#
|
140
|
-
# --config CONFIG_FILE
|
141
|
-
# --output_type OUTPUT_TYPE
|
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
|
-
#
|
149
|
+
# Outputs the info for the component in the dir.
|
150
150
|
#
|
151
|
-
# --pretty
|
152
|
-
# --
|
153
|
-
# --
|
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
|
-
#
|
162
|
+
# Tests a local component with sample data.
|
163
163
|
#
|
164
|
-
# --config CONFIG_FILE
|
165
|
-
# --input INPUT_FILE
|
166
|
-
# --output OUTPUT_FILE
|
167
|
-
# --directory DIR
|
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
|
-
#
|
175
|
+
# Performs any necessary initialization for the component.
|
176
176
|
#
|
177
|
-
# --directory DIR
|
178
|
-
# --output_type OUTPUT_TYPE
|
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
|
-
#
|
186
|
+
# Show recent errors generated by the componeny rpc.
|
187
187
|
#
|
188
|
-
# --output_type OUTPUT_TYPE
|
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
|
-
#
|
208
|
+
# Runs a local component with live data.
|
197
209
|
#
|
198
|
-
# --config CONFIG_FILE
|
199
|
-
# --
|
200
|
-
# --
|
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
|
218
|
-
# --input_file INTPUT_FILE
|
219
|
-
# --output_file OUTPUT_FILE
|
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
|
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
|