active_encode 0.8.0 → 0.8.1
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5347f6f8d85a2181c8a2a8961edfaea95c4e29606ef02b13eaa44145e322bfb2
|
4
|
+
data.tar.gz: '05810638aea1f82ae53098c06099990e07ee1bc7c0c513d7088e90ab79b7f8b8'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e4447428944fb5a156ed73d13f5b6a9480b237fc6021ddcbee3d7975bb7d390793a3796fe41cd6b2f2f55486d148aac157850168ea215e34fc5debbb536cd41
|
7
|
+
data.tar.gz: 63911ec850c0648e57d3b180b629464e26ee7ffe623f0f787cd2ee79b69ca1af5e06d0e7569a5e975a6d6540b325f44410d2830aadf1f309374bb779101990ef
|
@@ -51,6 +51,15 @@ module ActiveEncode
|
|
51
51
|
cmaf: { fragment_length: 2, segment_control: "SEGMENTED_FILES", segment_length: 10 }
|
52
52
|
}.freeze
|
53
53
|
|
54
|
+
class ResultsNotAvailable < RuntimeError
|
55
|
+
attr_reader :encode
|
56
|
+
|
57
|
+
def initialize(msg = nil, encode = nil)
|
58
|
+
@encode = encode
|
59
|
+
super(msg)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
54
63
|
attr_accessor :role, :output_bucket
|
55
64
|
attr_writer :log_group, :queue
|
56
65
|
|
@@ -167,11 +176,23 @@ module ActiveEncode
|
|
167
176
|
encode.updated_at = job.timing.finish_time || job.timing.start_time || encode.created_at
|
168
177
|
encode.percent_complete = convert_percent_complete(job)
|
169
178
|
encode.errors = [job.error_message].compact
|
179
|
+
encode.output = []
|
170
180
|
|
171
181
|
encode.input.created_at = encode.created_at
|
172
182
|
encode.input.updated_at = encode.updated_at
|
173
183
|
|
174
|
-
encode
|
184
|
+
encode = complete_encode(encode, job) if encode.state == :completed
|
185
|
+
encode
|
186
|
+
end
|
187
|
+
|
188
|
+
def complete_encode(encode, job)
|
189
|
+
result = convert_output(job)
|
190
|
+
if result.nil?
|
191
|
+
raise ResultsNotAvailable.new("Unable to load progress for job #{job.id}", encode) if job.timing.finish_time < 10.minutes.ago
|
192
|
+
encode.state = :running
|
193
|
+
else
|
194
|
+
encode.output = result
|
195
|
+
end
|
175
196
|
encode
|
176
197
|
end
|
177
198
|
|
@@ -192,6 +213,11 @@ module ActiveEncode
|
|
192
213
|
|
193
214
|
def convert_output(job)
|
194
215
|
results = get_encode_results(job)
|
216
|
+
return nil if results.nil?
|
217
|
+
convert_encode_results(job, results)
|
218
|
+
end
|
219
|
+
|
220
|
+
def convert_encode_results(job, results)
|
195
221
|
settings = job.settings.output_groups.first.outputs
|
196
222
|
|
197
223
|
outputs = results.dig('detail', 'outputGroupDetails', 0, 'outputDetails').map.with_index do |detail, index|
|
@@ -228,7 +254,7 @@ module ActiveEncode
|
|
228
254
|
|
229
255
|
def get_encode_results(job)
|
230
256
|
start_time = job.timing.submit_time
|
231
|
-
end_time = job.timing.finish_time || Time.now.utc
|
257
|
+
end_time = (job.timing.finish_time || Time.now.utc) + 10.minutes
|
232
258
|
|
233
259
|
response = cloudwatch_logs.start_query(
|
234
260
|
log_group_name: log_group,
|
@@ -243,7 +269,8 @@ module ActiveEncode
|
|
243
269
|
sleep(0.5)
|
244
270
|
response = cloudwatch_logs.get_query_results(query_id: query_id)
|
245
271
|
end
|
246
|
-
|
272
|
+
|
273
|
+
return nil if response.results.empty?
|
247
274
|
|
248
275
|
JSON.parse(response.results.first.first.value)
|
249
276
|
end
|
@@ -0,0 +1 @@
|
|
1
|
+
{"results":[],"statistics":{"records_matched":1.0,"records_scanned":13.0,"bytes_scanned":10750.0},"status":"Complete"}
|
@@ -87,6 +87,16 @@ describe ActiveEncode::EngineAdapters::MediaConvertAdapter do
|
|
87
87
|
ActiveEncode::Base.find(job_id)
|
88
88
|
end
|
89
89
|
|
90
|
+
let(:recent_completed_job_without_results) do
|
91
|
+
job_response = reconstitute_response("media_convert/job_completed.json")
|
92
|
+
job_response["job"]["timing"]["finish_time"] = 5.minutes.ago
|
93
|
+
mediaconvert.stub_responses(:get_job, job_response)
|
94
|
+
cloudwatch_logs.stub_responses(:start_query, reconstitute_response("media_convert/job_completed_detail_query.json"))
|
95
|
+
cloudwatch_logs.stub_responses(:get_query_results, reconstitute_response("media_convert/job_completed_empty_detail.json"))
|
96
|
+
|
97
|
+
ActiveEncode::Base.find(job_id)
|
98
|
+
end
|
99
|
+
|
90
100
|
let(:failed_job) do
|
91
101
|
mediaconvert.stub_responses(:get_job, reconstitute_response("media_convert/job_failed.json"))
|
92
102
|
|
@@ -122,5 +132,21 @@ describe ActiveEncode::EngineAdapters::MediaConvertAdapter do
|
|
122
132
|
end
|
123
133
|
end
|
124
134
|
end
|
135
|
+
|
136
|
+
it "has no logging entries but finished within the last 10 minutes" do
|
137
|
+
expect(recent_completed_job_without_results.state).to eq(:running)
|
138
|
+
end
|
139
|
+
|
140
|
+
it "finished more than 10 minutes ago but has no logging entries" do
|
141
|
+
mediaconvert.stub_responses(:get_job, reconstitute_response("media_convert/job_completed.json"))
|
142
|
+
cloudwatch_logs.stub_responses(:start_query, reconstitute_response("media_convert/job_completed_detail_query.json"))
|
143
|
+
cloudwatch_logs.stub_responses(:get_query_results, reconstitute_response("media_convert/job_completed_empty_detail.json"))
|
144
|
+
|
145
|
+
expect { ActiveEncode::Base.find(job_id) }.to raise_error do |error|
|
146
|
+
expect(error).to be_a(ActiveEncode::EngineAdapters::MediaConvertAdapter::ResultsNotAvailable)
|
147
|
+
expect(error.encode).to be_a(ActiveEncode::Base)
|
148
|
+
expect(error.encode.state).to eq(:completed)
|
149
|
+
end
|
150
|
+
end
|
125
151
|
end
|
126
152
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_encode
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Klein, Chris Colvard, Phuong Dinh
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -344,6 +344,7 @@ files:
|
|
344
344
|
- spec/fixtures/media_convert/job_completed.json
|
345
345
|
- spec/fixtures/media_convert/job_completed_detail.json
|
346
346
|
- spec/fixtures/media_convert/job_completed_detail_query.json
|
347
|
+
- spec/fixtures/media_convert/job_completed_empty_detail.json
|
347
348
|
- spec/fixtures/media_convert/job_created.json
|
348
349
|
- spec/fixtures/media_convert/job_failed.json
|
349
350
|
- spec/fixtures/media_convert/job_progressing.json
|
@@ -469,6 +470,7 @@ test_files:
|
|
469
470
|
- spec/fixtures/media_convert/job_completed.json
|
470
471
|
- spec/fixtures/media_convert/job_completed_detail.json
|
471
472
|
- spec/fixtures/media_convert/job_completed_detail_query.json
|
473
|
+
- spec/fixtures/media_convert/job_completed_empty_detail.json
|
472
474
|
- spec/fixtures/media_convert/job_created.json
|
473
475
|
- spec/fixtures/media_convert/job_failed.json
|
474
476
|
- spec/fixtures/media_convert/job_progressing.json
|