|
5 | 5 |
|
6 | 6 | import { send_to_py } from "./py_vue_bridge.js"
|
7 | 7 | import {get_tokens} from './clip_tokeniser/clip_encoder.js'
|
| 8 | +import {compute_time_remaining} from "./utils.js" |
8 | 9 | const moment = require('moment')
|
9 | 10 |
|
10 | 11 | let notification_sound = new Audio(require('@/assets/notification.mp3'))
|
@@ -146,29 +147,14 @@ export default {
|
146 | 147 | this.times.push(iter_time);
|
147 | 148 | let median = this.times.sort((a, b) => a - b)[Math.floor(this.times.length / 2)];
|
148 | 149 | let time_remaining = moment.duration(median*((100-p)*this.nb_its/100));
|
149 |
| -
|
150 |
| - if(time_remaining > 1){ |
151 |
| - if (time_remaining.hours() > 0) { |
152 |
| - this.remaining_times = `(${time_remaining.hours()}h${time_remaining.minutes()}m left)`; |
153 |
| - } else { |
154 |
| - this.remaining_times = `(${time_remaining.minutes()}m${time_remaining.seconds()}s left)`; |
155 |
| - } |
156 |
| - if (this.generation_loop) { |
157 |
| - clearInterval(this.generation_loop); |
158 |
| - } |
159 |
| - this.generation_loop = setInterval(() => { |
160 |
| - time_remaining.subtract(1, 'seconds'); |
161 |
| - if (time_remaining.hours() > 0) { |
162 |
| - this.remaining_times = `(${time_remaining.hours()}h${time_remaining.minutes()}m left)`; |
163 |
| - } else { |
164 |
| - this.remaining_times = `(${time_remaining.minutes()}m${time_remaining.seconds()}s left)`; |
165 |
| - } |
166 |
| - if (time_remaining < 1) { |
167 |
| - clearInterval(this.generation_loop); |
168 |
| - this.remaining_times = ""; |
169 |
| - } |
170 |
| - }, 1000); |
171 |
| - } |
| 150 | + |
| 151 | + this.remaining_times = compute_time_remaining(time_remaining); |
| 152 | + clearInterval(this.generation_loop); |
| 153 | + this.generation_loop = setInterval(() => { |
| 154 | + time_remaining.subtract(1, 'seconds'); |
| 155 | + this.remaining_times = compute_time_remaining(time_remaining); |
| 156 | + }, 1000); |
| 157 | + |
172 | 158 | }
|
173 | 159 | this.attached_cbs.on_progress(p, iter_time);
|
174 | 160 | }
|
|
0 commit comments