Skip to content
This repository has been archived by the owner on Feb 22, 2020. It is now read-only.

Commit

Permalink
feat(client): add progress bar and speed metric to cli
Browse files Browse the repository at this point in the history
  • Loading branch information
hanhxiao committed Aug 23, 2019
1 parent f6e0a48 commit 9d488e3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions gnes/client/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,19 +81,23 @@ def update(self):
elapsed = time.perf_counter() - self.start_time
elapsed_str = colored('elapsed', 'yellow')
speed_str = colored('speed', 'yellow')
estleft_str = colored('est left', 'yellow')
self.num_batch += 1
percent = self.num_batch / self.total_batch
num_bytes = sum(self.all_bytes_len[((self.num_batch - 1) * self.batch_size):(self.num_batch * self.batch_size)])
sys.stdout.write(
'{:>10} [{:<{}}] {:3.0f}% {:>10}: {:3.1f}s {:>10}: {:3.1f} bytes/s'.format(
'{:>10} [{:<{}}] {:3.0f}% {:>8}: {:3.1f}s {:>8}: {:3.1f} bytes/s {:3.1f} batch/s {:>8}: {:3.1f}s'.format(
colored(self.task_name, 'cyan'),
colored('=' * int(self.bar_len * percent), 'green'),
self.bar_len + 9,
percent * 100,
elapsed_str,
elapsed,
speed_str,
num_bytes / elapsed
num_bytes / elapsed,
self.num_batch / elapsed,
estleft_str,
(self.total_batch - self.num_batch) / (self.num_batch / elapsed)
))
sys.stdout.flush()

Expand All @@ -104,4 +108,4 @@ def __enter__(self):
return self

def __exit__(self, exc_type, exc_val, exc_tb):
sys.stdout.write('\n')
sys.stdout.write('\t%s\n' % colored('done!', 'green'))

0 comments on commit 9d488e3

Please sign in to comment.