gd_bam 0.1.26 → 0.1.27
Sign up to get free protection for your applications and to get access to all the features.
- data/bin/bam +10 -1
- data/lib/bam/version.rb +1 -1
- data/lib/base/errors.rb +1 -1
- data/lib/base/graph.rb +22 -8
- data/lib/base/repo.rb +15 -0
- data/lib/base/tap.rb +28 -12
- data/lib/commands/gd_commands.rb +3 -3
- data/lib/compiler/compiler.rb +1 -0
- data/lib/compiler/etl_visitor.rb +0 -1
- metadata +2 -2
data/bin/bam
CHANGED
@@ -326,7 +326,16 @@ command :model_sync do |c|
|
|
326
326
|
c.switch :dry
|
327
327
|
|
328
328
|
c.action do |global_options,options,args|
|
329
|
-
|
329
|
+
|
330
|
+
params = PARAMS.merge({
|
331
|
+
:project_name => "downloaders-#{PARAMS[:project_name]}",
|
332
|
+
:graph_repos => [
|
333
|
+
GoodData::Bam::Repository.create(:type => :file, :base => './local_graphs'),
|
334
|
+
GoodData::Bam::Repository.create(:type => :file, :base => GoodData::CloverGenerator::BAM_DEFINED_GRAPHS_ROOT)]
|
335
|
+
})
|
336
|
+
home = '.'
|
337
|
+
home = Pathname(home)
|
338
|
+
GoodData::Bam::Commands::model_sync('.', params)
|
330
339
|
end
|
331
340
|
end
|
332
341
|
|
data/lib/bam/version.rb
CHANGED
data/lib/base/errors.rb
CHANGED
@@ -15,7 +15,7 @@ module GoodData
|
|
15
15
|
class IdInTapNotPresentError < RuntimeError
|
16
16
|
|
17
17
|
def initialize(tap)
|
18
|
-
super("
|
18
|
+
super("Tap \"#{tap[:id]}\" does not have Id field. Every non direct tap has to have field name Id on the output. Consider adding an appropriate field and/or using acts_as.")
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
data/lib/base/graph.rb
CHANGED
@@ -4,14 +4,28 @@ module GoodData
|
|
4
4
|
|
5
5
|
def self.create(graph)
|
6
6
|
fail "Graph should have graph to execute. You defined \"#{graph}\"" if graph[:path].blank?
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
7
|
+
if(!URI.parse(graph[:path].to_s).absolute?)
|
8
|
+
# it is a path
|
9
|
+
{
|
10
|
+
:inputs => [],
|
11
|
+
:outputs => []
|
12
|
+
}.merge(graph).merge({
|
13
|
+
:path => Pathname(graph[:path]),
|
14
|
+
:name => Pathname(graph[:path]).basename.to_s,
|
15
|
+
:type => :graph
|
16
|
+
})
|
17
|
+
else
|
18
|
+
# it is a URI
|
19
|
+
# binding.pry
|
20
|
+
{
|
21
|
+
:inputs => [],
|
22
|
+
:outputs => []
|
23
|
+
}.merge(graph).merge({
|
24
|
+
:path => URI(graph[:path]),
|
25
|
+
:name => URI(graph[:path]),
|
26
|
+
:type => :graph
|
27
|
+
})
|
28
|
+
end
|
15
29
|
end
|
16
30
|
|
17
31
|
def self.get_path(graph)
|
data/lib/base/repo.rb
CHANGED
@@ -11,6 +11,9 @@ module GoodData
|
|
11
11
|
when :hash
|
12
12
|
fail "Repo has to have content defined" if repository[:content].nil? || !repository[:content].is_a?(Hash)
|
13
13
|
repository
|
14
|
+
when :http
|
15
|
+
repository.merge({
|
16
|
+
:base => URI(repository[:base])})
|
14
17
|
end
|
15
18
|
end
|
16
19
|
|
@@ -26,6 +29,18 @@ module GoodData
|
|
26
29
|
end
|
27
30
|
when :hash
|
28
31
|
Graph.create(repository[:content][path])
|
32
|
+
when :http
|
33
|
+
path = repository[:base] + URI(path)
|
34
|
+
puts path
|
35
|
+
begin
|
36
|
+
RestClient.get(path.to_s)
|
37
|
+
Graph.create({
|
38
|
+
:path => path,
|
39
|
+
:repository => repository
|
40
|
+
})
|
41
|
+
rescue RestClient::ResourceNotFound => e
|
42
|
+
nil
|
43
|
+
end
|
29
44
|
else
|
30
45
|
fail "not implemented"
|
31
46
|
end
|
data/lib/base/tap.rb
CHANGED
@@ -139,19 +139,23 @@ module GoodData
|
|
139
139
|
}))
|
140
140
|
end
|
141
141
|
|
142
|
+
|
143
|
+
#
|
144
|
+
# This method prepares the tap for data after downloading from SF but BEFORE it goes to ES
|
145
|
+
# We want to be able to load to ES as unchanged data as posible. Only Id and Timestamp (if provided is needed)
|
146
|
+
# other acts as should be used on the output of ES. The reason is that even if we change acts_as we should still pick up the same data
|
142
147
|
def self.prepare_for_sf_downloader(tap)
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
}))
|
148
|
+
id_field = Tap.find_output_field(tap, "Id")
|
149
|
+
Tap.validate(tap)
|
150
|
+
time_field = Tap.find_output_field(tap, "Timestamp")
|
151
|
+
tap = Tap.remove_acts_as(tap)
|
152
|
+
fields = tap[:fields].map {|f| f[:name] == id_field[:name] ? f.merge(:acts_as => ["Id"]) : f}
|
153
|
+
if time_field
|
154
|
+
fields = fields.map {|f| f[:name] == time_field[:name] ? f.merge(:acts_as => ["Timestamp"]) : f}
|
155
|
+
end
|
156
|
+
Tap.create(tap.merge({
|
157
|
+
:fields => fields
|
158
|
+
}))
|
155
159
|
end
|
156
160
|
|
157
161
|
def self.prepare_for_es_downloader(tap)
|
@@ -168,6 +172,18 @@ module GoodData
|
|
168
172
|
tap[:fields].reject {|f| f[:is_mandatory] == false }
|
169
173
|
end
|
170
174
|
|
175
|
+
def self.validate(tap)
|
176
|
+
assert_presence_of_id_field(tap)
|
177
|
+
end
|
178
|
+
|
179
|
+
# Every incremental tap has to have
|
180
|
+
def self.assert_presence_of_id_field(tap)
|
181
|
+
id_present = Tap.has_output_field?(tap, "Id")
|
182
|
+
|
183
|
+
direct = tap[:direct]
|
184
|
+
fail IdInTapNotPresentError.new(tap) if (!id_present && !direct)
|
185
|
+
end
|
186
|
+
|
171
187
|
end
|
172
188
|
end
|
173
189
|
end
|
data/lib/commands/gd_commands.rb
CHANGED
@@ -20,8 +20,8 @@ module GoodData
|
|
20
20
|
|
21
21
|
def self.model_sync(path, options)
|
22
22
|
dry_run = options[:dry]
|
23
|
-
project = build_project(path, options)
|
24
|
-
datasets = project
|
23
|
+
project = GoodData::Bam::Project.build_project(path, options)
|
24
|
+
datasets = project[:sinks]
|
25
25
|
model_update_dir = Pathname('model_update')
|
26
26
|
cl_home = ENV['CL_HOME'] || PARAMS['CL_HOME'] || fail("Home of cl tool cannot be found. Either set up CL_HOME in your env with 'export CL_HOME=path/to/cl or set it up in your params.json. Point to the directory of CL not to the bin dir.'")
|
27
27
|
cl_home = Pathname(cl_home) + 'bin/gdi.sh'
|
@@ -56,7 +56,7 @@ module GoodData
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
template_name = dry_run ? "update_dataset_dry.script.erb" : "update_dataset.script.erb"
|
59
|
-
render_template(template_name, PARAMS.merge({"config_file" => dataset_path.expand_path}), :to_file => 'update_dataset.script')
|
59
|
+
Utils::render_template(template_name, PARAMS.merge({"config_file" => dataset_path.expand_path}), :to_file => 'update_dataset.script')
|
60
60
|
puts "Generate #{ds[:id]}"
|
61
61
|
|
62
62
|
system("#{cl_home} update_dataset.script --username #{PARAMS[:gd_login]} --password #{PARAMS[:gd_pass]}")
|
data/lib/compiler/compiler.rb
CHANGED
@@ -51,6 +51,7 @@ module GoodData
|
|
51
51
|
when :tap
|
52
52
|
tap = Project.find_tap_by_id(project, id)
|
53
53
|
fail "Tap \"#{id}\" which was used in flow \"#{current_step[:flow_id]}\" is not defined" if tap.nil?
|
54
|
+
Tap.validate(tap)
|
54
55
|
Flow.add_step(flow_memo, Tap.create(tap.merge(current_step)))
|
55
56
|
when :sink
|
56
57
|
sink = Project.find_sink_by_id(project, id)
|
data/lib/compiler/etl_visitor.rb
CHANGED
@@ -140,7 +140,6 @@ module GoodData
|
|
140
140
|
|
141
141
|
def visit_direct_file_tap(node, state)
|
142
142
|
graph_path = Step.get_graph_path(node)
|
143
|
-
tap = Tap.prepare_for_sf_downloader(node)
|
144
143
|
GoodData::Bam::Generators::Etl::create_file_downloading_graph(graph_path, node, state)
|
145
144
|
state.merge({
|
146
145
|
:graphs => state[:graphs].concat([graph_path]),
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: gd_bam
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.27
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|