etna 0.1.49 → 0.1.51

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4e6abb600dd6cd4dd0986021317933f8b782b94f03d30315383bc74b052613ab
4
- data.tar.gz: 909e5c67319a91dd11db4d081ec721f9438b13b8fb15dbc9d19cef2e5a5197b1
3
+ metadata.gz: be19e727959bd06d5af503f7a3bbc30fde48fe7aa0db200b93c32f656bd1a642
4
+ data.tar.gz: 179736a0638b7e200bb9a55aeae79fddf852a9d5e0fb33c7650a11e06bfc11f7
5
5
  SHA512:
6
- metadata.gz: 4ef5fff5973c32b570306cab9292b7107e16c9f158dc6e3828fb19e6e4d8441f315e075091d39ce13641f81f3ecbdb428f3add61238d9c4043527e6139212702
7
- data.tar.gz: 66d797cdfc76684f325aa37299e82de323b966f337d3b7e68b5ed8542cc1cb766d6b05c740256c2da63a586d240a8a2dbe9c8a1af9df3b9d0712b1a59f66ef0b
6
+ metadata.gz: a7ac565d1132f522d6f955f250c0e23762909294ede0370f5d2e3ff3fad503f78c4e26de5cd95d035defff96ab8c533ca72fd339d998ce2306e48b1cf955cc9a
7
+ data.tar.gz: a765da090dafc236beace6473fb6c18b56060406ed3d6f0f50b92cc2c06cde29cb1e86b35a0f14015cdcdfaa28c6aa598cb4881a8f54be6ac607c7da61925137
data/lib/commands.rb CHANGED
@@ -250,9 +250,10 @@ class EtnaApp
250
250
  string_flags << "--log-file"
251
251
  string_flags << "--log-level"
252
252
  string_flags << "--concurrency"
253
+ string_flags << "--page-size"
254
+ boolean_flags << "--list-only"
253
255
 
254
-
255
- def execute(project_name:, log_file:'/dev/stdout', log_level: ::Logger::INFO, concurrency: 1)
256
+ def execute(project_name:, log_file:'/dev/stdout', log_level: ::Logger::INFO, concurrency: 1, page_size: 20, list_only: false)
256
257
  logger = Etna::Logger.new(log_file, 0, 1048576)
257
258
 
258
259
  logger.level = log_level
@@ -266,6 +267,8 @@ class EtnaApp
266
267
  logger: logger,
267
268
  project_name: project_name,
268
269
  model_name: 'project', filesystem: filesystem,
270
+ list_only: list_only,
271
+ page_size: page_size.to_i,
269
272
  concurrency: concurrency.to_i)
270
273
 
271
274
  workflow.materialize_all(project_name)
@@ -9,10 +9,10 @@ module Etna
9
9
  :metis_client, :magma_client, :project_name,
10
10
  :model_name, :model_filters, :model_attributes_mask,
11
11
  :filesystem, :logger, :stub_files, :concurrency,
12
- :record_names, keyword_init: true)
12
+ :page_size, :record_names, :list_only, keyword_init: true)
13
13
 
14
14
  def initialize(**kwds)
15
- super(**({filesystem: Etna::Filesystem.new, concurrency: 10, record_names: "all"}.update(kwds)))
15
+ super(**({filesystem: Etna::Filesystem.new, page_size: 20, concurrency: 10, record_names: "all", list_only: false}.update(kwds)))
16
16
  end
17
17
 
18
18
  def magma_crud
@@ -34,7 +34,7 @@ module Etna
34
34
  record_names,
35
35
  model_attributes_mask: model_attributes_mask,
36
36
  model_filters: model_filters,
37
- page_size: 20,
37
+ page_size: page_size,
38
38
  ) do |template, document|
39
39
  logger&.info("Materializing #{template.name}##{document[template.identifier]}")
40
40
  templates[template.name] = template
@@ -108,17 +108,27 @@ module Etna
108
108
  end
109
109
 
110
110
  dest_file = File.join(dest_dir, metadata_file_name(record_name: record[template.identifier], record_model_name: template.name, ext: "_#{attr_name}_#{idx}#{File.extname(filename)}"))
111
- filesystem.mkdir_p(File.dirname(dest_file))
112
- sync_metis_data_workflow.copy_file(dest: dest_file, url: url, stub: stub_files)
113
- record_to_serialize[attr_name] << {file: dest_file, original_filename: filename}
111
+
112
+ if list_only
113
+ puts dest_file
114
+ else
115
+ filesystem.mkdir_p(File.dirname(dest_file))
116
+ sync_metis_data_workflow.copy_file(dest: dest_file, url: url, stub: stub_files)
117
+ record_to_serialize[attr_name] << {file: dest_file, original_filename: filename}
118
+ end
114
119
  end
115
120
 
116
121
  dest_file = File.join(dest_dir, metadata_file_name(record_name: record[template.identifier], record_model_name: template.name, ext: '.json'))
117
- filesystem.mkdir_p(File.dirname(dest_file))
118
- json = record_to_serialize.to_json
119
122
 
120
- filesystem.with_writeable(dest_file, "w", size_hint: json.bytes.length) do |io|
121
- io.write(json)
123
+ if list_only
124
+ puts dest_file
125
+ else
126
+ filesystem.mkdir_p(File.dirname(dest_file))
127
+ json = record_to_serialize.to_json
128
+
129
+ filesystem.with_writeable(dest_file, "w", size_hint: json.bytes.length) do |io|
130
+ io.write(json)
131
+ end
122
132
  end
123
133
  end
124
134
 
@@ -63,12 +63,21 @@ module Etna
63
63
  page_size: 100,
64
64
  &block)
65
65
  q = [ { model_name: model_name, from: nil, record_names: record_names } ]
66
- seen = Set.new
66
+ seen = {}
67
67
 
68
68
  while (path = q.pop)
69
69
  model_name = path[:model_name]
70
- next if seen.include?([path[:from], model_name])
71
- seen.add([path[:from], model_name])
70
+ seen[model_name] ||= Set.new
71
+
72
+ new_record_names = path[:record_names]
73
+
74
+ if new_record_names.is_a?(Array)
75
+ new_record_names -= seen[model_name].to_a
76
+
77
+ next if new_record_names.empty?
78
+
79
+ seen[model_name].merge(new_record_names)
80
+ end
72
81
 
73
82
  template = template_for(model_name)
74
83
  query_attributes, walk_attributes = masked_attributes(
@@ -80,7 +89,7 @@ module Etna
80
89
  request = RetrievalRequest.new(
81
90
  project_name: magma_crud.project_name,
82
91
  model_name: model_name,
83
- record_names: path[:record_names],
92
+ record_names: new_record_names,
84
93
  filter: model_filters[model_name],
85
94
  attribute_names: query_attributes,
86
95
  page_size: page_size, page: 1
@@ -96,6 +105,8 @@ module Etna
96
105
  attributes = []
97
106
  model = response.models.model(model_name)
98
107
 
108
+ seen[model_name].merge( model.documents.document_keys )
109
+
99
110
  template.attributes.attribute_keys.each do |attr_name|
100
111
  attr = template.attributes.attribute(attr_name)
101
112
  if attr.attribute_type == AttributeType::TABLE && attribute_included?(walk_attributes, attr_name)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: etna
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.49
4
+ version: 0.1.51
5
5
  platform: ruby
6
6
  authors:
7
7
  - Saurabh Asthana
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-02-13 00:00:00.000000000 Z
11
+ date: 2023-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack