omniai-google 2.7.8 → 2.7.9

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,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '01641329c02a60a611515c1ad844f8579d9d36587cbf585cf4376d7998028cab'
4
- data.tar.gz: ededa3cb75ca8c99a081ac1eee248849f8a76d98d326e16c687e7a81d2acf7ca
3
+ metadata.gz: 9b718eb7991b71acbb1339523addc4b6336af98a93a978336cf79e696a838fbe
4
+ data.tar.gz: 61a97b3e556841f7880fc0f2ca3eb832940a02098e7a55dcf41eb976766ab791
5
5
  SHA512:
6
- metadata.gz: 3446423742db9d3b9a8b55351baecdd585362b7c3fe09cf4bee27d7eee295964a89b59975998812744c498e7c260d42ef45be84e053e03fdb37121329763e2f0
7
- data.tar.gz: 852ca384c413a01ed037e9338a2706b5aa1d4a87ac587cc62d4327920b74772dc5e94cded9a91fd408c4ee25fe9340c481d21afd9f4ff45c6e2ffca9a59ad50d
6
+ metadata.gz: 65504958cd3c74f5302c6362a72d86d9506637889a4005de4a92ac462567ea7925cfe774e12399bae64eba012cbbf1fa70fcac2e30010d869d1b3ed099b5d6dc
7
+ data.tar.gz: 680380f9201edf0a4bc4d6ebfe3a1e08c4b8c30c34b8a99d4d70dbed4beac6eb0a453bd2b2a75efc774628ff79359b7cc616e7fe91a9d1f07c3afe3a6778cae5
@@ -190,13 +190,13 @@ module OmniAI
190
190
  # Add authentication if using credentials
191
191
  connection = connection.auth("Bearer #{@client.send(:auth).split.last}") if @client.credentials?
192
192
 
193
- max_attempts = 60 # Maximum 15 minutes (15 second intervals)
193
+ max_attempts = calculate_max_polling_attempts
194
194
  attempt = 0
195
195
 
196
196
  loop do
197
197
  attempt += 1
198
198
 
199
- raise HTTPError, "Operation timed out after #{max_attempts * 15} seconds" if attempt > max_attempts
199
+ raise StandardError, "Operation timed out after #{max_attempts * 15} seconds" if attempt > max_attempts
200
200
 
201
201
  operation_response = connection.get("/v2/#{operation_name}", params: operation_params)
202
202
 
@@ -454,6 +454,17 @@ module OmniAI
454
454
  credentials = @client.instance_variable_get(:@credentials)
455
455
  ::Google::Cloud::Storage.new(project_id:, credentials:)
456
456
  end
457
+
458
+ # @return [Integer]
459
+ def calculate_max_polling_attempts
460
+ file_size_bytes = calculate_file_size
461
+ assumed_bitrate_bps = 48_000
462
+ estimated_duration_seconds = (file_size_bytes * 8.0) / assumed_bitrate_bps
463
+ estimated_processing_seconds = estimated_duration_seconds * 0.3
464
+ total_wait_seconds = estimated_processing_seconds + 90
465
+ final_wait_seconds = total_wait_seconds.clamp(180, 10_800)
466
+ (final_wait_seconds / 15).ceil
467
+ end
457
468
  end
458
469
  end
459
470
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module OmniAI
4
4
  module Google
5
- VERSION = "2.7.8"
5
+ VERSION = "2.7.9"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: omniai-google
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.8
4
+ version: 2.7.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kevin Sylvestre